diff options
author | jthorn <jthorn@0f49ee68-0e4f-0410-9b9c-b2c123ded7ef> | 2003-07-06 11:16:19 +0000 |
---|---|---|
committer | jthorn <jthorn@0f49ee68-0e4f-0410-9b9c-b2c123ded7ef> | 2003-07-06 11:16:19 +0000 |
commit | a07489dec7a4e1153624e158a2c5f2837b9247de (patch) | |
tree | 83be503e3cdaf39c578202c0fcdcf71337845e42 /archive/C_str.maple | |
parent | 892b8a2d121db4c1e436177cb19baa06eb8d0e4a (diff) |
This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches.
git-svn-id: http://svn.aei.mpg.de/numrel/AEIThorns/AEILocalInterp/trunk@3 0f49ee68-0e4f-0410-9b9c-b2c123ded7ef
Diffstat (limited to 'archive/C_str.maple')
-rw-r--r-- | archive/C_str.maple | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/archive/C_str.maple b/archive/C_str.maple new file mode 100644 index 0000000..e0335a6 --- /dev/null +++ b/archive/C_str.maple @@ -0,0 +1,42 @@ +# +# This function is a wrapper around codegen[C]() which returns the +# genenerated code explictly as a Maple string. +# +# Arguments: +# expr = (in) The expression for which code is to be generated. +# ... = (in) Any further arguments are taken as options to be passed +# to codegen[C]() +# +# Results: +# The function returns a maple string of C code. +# +C_str := +proc(expr::algebraic) +local tempname, str, temp; + +# name of temp file +# FIXME: should use process number to ensure uniqueness +tempname := "/tmp/C_str.tmp.c"; + +# truncate temp file to zero length +fopen(tempname, WRITE); +fclose(tempname); + +# generate the code +codegen[C](args, filename=tempname); + +# read the code back in +str := ""; + while true + do + temp := readline(tempname); + if (temp = 0) + then break; + end if; + str := cat(str, temp); + end do; +fclose(tempname); + +# strip off the leading " t0 = " +return op(2,sscanf(str, "%s = %[^;];")); +end proc; |