From f270d9e315bd95e673b6b7c4c60d853c90f01f22 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 21 Dec 2006 20:07:46 +0100 Subject: use ssubst() from stringproc for variable translation --- src/expr2c.mac | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/expr2c.mac') diff --git a/src/expr2c.mac b/src/expr2c.mac index 2a33090..b1fe8d1 100644 --- a/src/expr2c.mac +++ b/src/expr2c.mac @@ -1,17 +1,21 @@ +load("stringproc")$ + +varsubst(v) := ssubst("_", "%", string(v))$ + printdecl(vars) := ( - sprint("double", first(vars)), - for v in rest(vars) do sprint(",", v), + sprint("double", varsubst(first(vars))), + for v in rest(vars) do sprint(",", varsubst(v)), sprint(";"))$ -printdef(expr) := sprint(first(expr), "=", second(expr), ";")$ +printdef(expr) := sprint(varsubst(first(expr)), "=", varsubst(second(expr)), ";")$ block2c(expr) := if ?equal(op(expr), block) then ( printdecl(first(expr)), for d in reverse(rest(reverse(rest(expr)))) do printdef(d), - sprint("return", string(last(expr)), ";")) + sprint("return", varsubst(last(expr)), ";")) else - sprint("return", string(expr), ";")$ + sprint("return", varsubst(expr), ";")$ expr2c(funcname, argstr, expr) := ( sprint("double", funcname, "(", argstr, ") {"), -- cgit v1.2.3