[Prev][Next][Index]

Possible problem with sage 1.7?



At the bottom of this email, I've included a tiny program that
I think demonstrates a possible problem with sage1.7 (or at
least a problem with how I'm using it). The problem occurs
when my tool tries to generate new variables of pointer types.
Internally in the tool, the type appears to be set up fine, but
when the declaration is generated at the end, the variable is
declared not as a pointer but as an instance of the base type.
E.g., in the tool I try to generate a declaration of the form
"int *X", but what I get at the end is "int X".
Is this a known problem? I'd be grateful for any help.

-Adam Ferrari
ferrari@virginia.edu



// Example progam that demonstrates the problem. The expected output
// is:
//                           int *X;
// The actual output is:
//                           int  X;
#include "sage++user.h"
int
main()
{
        SgProject proj("dummy.proj");
        SgFile *file = &(proj.file(0));

        // Create a new type - "pointer to int"
        SgType *type = new SgPointerType(SgTypeInt());

        // Create a new symbol called X, set the type to "pointer to int"
        SgSymbol *sym = new SgSymbol(VARIABLE_NAME,"X",file->firstStatement());
        sym->setType(*type);

        // Set up a declaration of the new variable
        SgVarRefExp *varRef = new SgVarRefExp(*sym);
        SgExprListExp *exprList = new SgExprListExp(*varRef);
        SgStatement *decl = new SgVarDeclStmt(*exprList, *type);

        // Print it out. The right answer is "int *X;"
        decl->unparsestdout();

        return 0;
}