[Prev][Next][Index]

transforming expressions




I am writting a program using sage++ (version 1.3) which attempts to
perform the following translation of C++ programs:

input expression e1:

a + b

output expression:

operator+(a, b)

I am doing all of the necessary querying of type info for a and b to
make sure that there is an operator+ for the relavent types.

The problem I am encountering is how to replace the input expression
(e1) with the output expression.  The input expression will be an
SgExpression and the output expression should be an SgFunctionCallExp.

In my attempts so far I have tried to change the variant viz:

e1->setVariant(FUNC_CALL);

However this is an attempt to change an SgExpression into the derived
class SgFunctionCallExp call expression and although the
SgFunctionCallExp seems to have no new fields over SgExpression this
seems dangerous as the constructor for SgFunctionCallExp may
initialise things differently from the SgExpression constructor.
Indeed sage++ gives the warning:

Warning : Variant of a low level node node should not be change

Is there an easy way to change the expression or do I need to resort
to the lower level C interface to do something which the C++ interface
does not seem to provide?

Adam

______________________________________________________________
email: aba@dcs.exeter.ac.uk      http://dcs.exeter.ac.uk/~aba/