Re: [Jastadd] Expr, Stmt and coll attributes

From: Emma Söderberg <emma.soderberg_at_cs.lth.se>
Date: Sat, 24 Mar 2012 10:08:32 +0100

Hi Patrick,

The behavior you get depends on the definition of, for example, cdd():

coll SmallSet CFGNode.cdd() [emptySmallSet().mutable()] with add root Stmt;
VarAccess contributes deck() when isDest() to CFGNode.cdd() for this;

If you change the contribution part to:

VarAccess contributes deck() when isDest() to CFGNode.cdd() for
enclosingStmt();

You get contributions to, for example, ExprStmt. The enclosingStmt() is
declared in JastAddJ/Java1.4Frontend/TypeAnalysis.jrag. If you were to
define it again, or something similar, your could do:

inh Stmt Expr.enclosingStmt();
eq Stmt.getChild().enclosingStmt() = this;
// and then you need some kind of default behavior for expressions
outside of statements, you could do this:
eq Program.getChild().enclosingStmt() = null;
// or this:
eq Program.getChild().enclosingStmt() = throw new Error("Expression has
no enclosing statement");

Hope this helps.

Regards,
Emma


On 03/23/2012 06:26 PM, Patrick Lam wrote:
> Hi Emma,
>
> Thanks for the quick reply.
>
> I can successfully run your example, and I do see that Expr gets the
> cdd() value. However, I don't see any propagation from Expr to the
> containing Stmt. (I'm working on adding a rule to manually propagate
> it, but I haven't managed to get that working yet).
>
> I changed the example so that it prints out the def() and cdd() sets
> for Stmts instead, and they are set for the VariableDeclaration
> statements, but not for the ExprStmts, which is what I'm trying to
> compute.
>
> Wouldn't one normally want to know about the variables that are
> defined at a Stmt level, not at an Expr level?
>
> pat
>
> On 03/23/2012 05:51 AM, Emma Söderberg wrote:
>> Hi Patrick,
>>
>> I have trouble reproducing your problem. Which revision of the IntraFlow
>> module are you using? I'm using r769, and then r9236 for the JastAddJ
>> frontend. I tested to run your example but I get contributions for all
>> roots: BodyDecl, Stmt and Expr. I'm attaching the example so that you
>> can compare. The example program ("Analyzer.java") will print the
>> content of "cdd()" and "def()" for expression nodes in methods. Hope
>> this helps.
>>
>> Regards,
>> Emma
>>
>> On 03/23/2012 08:19 AM, Patrick Lam wrote:
>>> Hi,
>>>
>>> Thanks for the work on JastAdd. It makes certain things a lot easier
>>> to express.
>>>
>>> Using code from SVN, I'm encountering something strange.
>>>
>>> In particular I'm using r9236 of the Java1.4Frontend, and I'm trying
>>> to use def() from the IntraFlow extension. But I can reproduce the
>>> problem with the following two lines:
>>>
>>> coll SmallSet CFGNode.cdd() [emptySmallSet().mutable()] with add root
>>> BodyDecl;
>>> VarAccess contributes decl() when isDest() to CFGNode.cdd() for this;
>>>
>>>
>>> I'm not getting any contributions from VarAccess with a simple method
>>> like this one:
>>>
>>> class Foo {
>>> public Foo fob() {
>>> Foo tt, rr;
>>> tt = this;
>>> rr = tt;
>>> return rr;
>>> }
>>> }
>>>
>>> def() from JavaDeadAssigns doesn't seem to work right either; it only
>>> catches VariableDeclaration and not VarAccess.
>>>
>>> In particular, if I collect on Stmt, then I get a bunch of
>>> contributions. But if I collect on Expr or any descendant, I get
>>> nothing. Am I doing something wrong?
>>>
>>> Thanks!
>>>
>>> pat
>>> _______________________________________________
>>> JastAdd mailing list
>>> JastAdd_at_cs.lth.se
>>> https://mail1.cs.lth.se/cgi-bin/mailman/listinfo/jastadd
>>
>>
>>
>> _______________________________________________
>> JastAdd mailing list
>> JastAdd_at_cs.lth.se
>> https://mail1.cs.lth.se/cgi-bin/mailman/listinfo/jastadd
>
> _______________________________________________
> JastAdd mailing list
> JastAdd_at_cs.lth.se
> https://mail1.cs.lth.se/cgi-bin/mailman/listinfo/jastadd
Received on Sat Mar 24 2012 - 10:09:53 CET

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST