[Prev][Next][Index]

SgCastExp Questions



I have the following problem with the SgCastExp.

A program just to show the problem:
------------------------------------
#include <stdio.h>
 
typedef double MyDouble;
 
void *myproc(void)
{return 0;}
 
int main(int argc, char **argv)
{
  MyDouble *a;
 
  sizeof(MyDouble);
  a = (MyDouble *) myproc();
  return 0;
}
-------------------------------------

The representation of "sizeof(MyDouble);" in Sage
                 variant  unparsestdout
SgExprListExp
  SgUnaryExp     var 400 :sizeof(MyDouble)
    SgCastExp    var 407 :MyDouble

The representation of "a = (MyDouble *) myproc();" in Sage
                  variant  unparsestdout
SgExprListExp
  SgExpression    var ASSGN_OP
    lhs
    rhs = SgCastExp var 407 :(MyDouble *) myproc()

The documentation to Sage says the following:
"The expression nodes that have their own subclass do so because they have a
 special type of constructor or special fields."

Now the subclass SgCastExp should have "a special type of constructor or special
fields", but the class itself has no methods for accessing the special-fields 
(supposing that for the above problem it would be "(MyDouble *) myproc()" ) so
it must have a special type of constructor.
One could access the encapsulated expression nodes with the methods
lhs,rhs,operand(i) from SgExpression. But is this always correct.

Why is a new Type a castExp in sizeof()?
By the way, how can one access the expression nodes of SgInitListExp (the source
of numberOfArgs, ... is commented out with #ifdef/not existent ).

Thanks for any comments,
Andre Christanell