Meta-AspectJ

David Zook, Shan Shan Huang, Yannis Smaragdakis

Using infer

If all the AST classes used to represent entry points overwhelms you, here's some good news -- you don't have to remember these cumbersome classes at all! infer is your friend! You can use infer in place of a type name in declaring variables. The variable's type will then be inferred by MAJ during parsing. For example:
    infer myVarDec = `[ int x = 0; ];
    infer myStmt = `[ { #myVarDec 
                        x++; } ]; 
In the example above, myVarDec has the inferred type of VarDec, while myStmt has the inferred type of Stmt. You can use them as such in the code that follows their declarations.

The one caveat of using infer is that you must initialize the variables right away. You can not declare a variable having type infer and initalize it later as in this example:

    infer myVarDec; // ILLEGAL!
    ...
    myVarDec = `[ int x = 0; ];
This is a limitation in the current version of MAJ. We should be able to amend it in future versions and still keep the type-safety MAJ provides.