From fc216ba552a66287b7c2f0dd4ce919472542b392 Mon Sep 17 00:00:00 2001 From: bdemsky <bdemsky> Date: Sun, 17 Apr 2011 08:13:37 +0000 Subject: [PATCH] changes --- Robust/src/IR/Tree/BuildIR.java | 55 +++++++++++++++++++++------------ Robust/src/Parse/java14.cup | 29 +++++++++++------ Robust/src/buildscript | 2 +- 3 files changed, 55 insertions(+), 31 deletions(-) diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 5014d877..8acca7b2 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -1,11 +1,8 @@ package IR.Tree; import IR.*; import Util.Lattice; - import java.util.*; - - public class BuildIR { State state; @@ -148,27 +145,27 @@ public class BuildIR { } } -public void parseInitializers(ClassDescriptor cn){ - Vector fv=cn.getFieldVec(); + public void parseInitializers(ClassDescriptor cn){ + Vector fv=cn.getFieldVec(); int pos = 0; - for(int i=0;i<fv.size();i++) { + for(int i=0;i<fv.size();i++) { FieldDescriptor fd=(FieldDescriptor)fv.get(i); if(fd.getExpressionNode()!=null) { - Iterator methodit = cn.getMethods(); - while(methodit.hasNext()){ - MethodDescriptor currmd=(MethodDescriptor)methodit.next(); - if(currmd.isConstructor()){ - BlockNode bn=state.getMethodBody(currmd); - NameNode nn=new NameNode(new NameDescriptor(fd.getSymbol())); - AssignmentNode an=new AssignmentNode(nn,fd.getExpressionNode(),new AssignOperation(1)); - bn.addBlockStatementAt(new BlockExpressionNode(an), pos); - } - } - pos++; + Iterator methodit = cn.getMethods(); + while(methodit.hasNext()){ + MethodDescriptor currmd=(MethodDescriptor)methodit.next(); + if(currmd.isConstructor()){ + BlockNode bn=state.getMethodBody(currmd); + NameNode nn=new NameNode(new NameDescriptor(fd.getSymbol())); + AssignmentNode an=new AssignmentNode(nn,fd.getExpressionNode(),new AssignOperation(1)); + bn.addBlockStatementAt(new BlockExpressionNode(an), pos); + } + } + pos++; } - } - } - + } + } + private ClassDescriptor parseEnumDecl(ClassDescriptor cn, ParseNode pn) { ClassDescriptor ecd=new ClassDescriptor(pn.getChild("name").getTerminal(), false); ecd.setAsEnum(); @@ -747,6 +744,8 @@ public void parseInitializers(ClassDescriptor cn){ } } + int innerCount=0; + private ExpressionNode parseExpression(ParseNode pn) { if (isNode(pn,"assignment")) return parseAssignmentExpression(pn); @@ -825,6 +824,22 @@ public void parseInitializers(ClassDescriptor cn){ con.addFlagEffects(fe); } + return con; + } else if (isNode(pn,"createobjectcls")) { + //TODO::: FIX BUG!!! static fields in caller context need to become parameters + TypeDescriptor td=parseTypeDescriptor(pn); + innerCount++; + ClassDescriptor cnnew=new ClassDescriptor(td.getSymbol()+"$"+innerCount, false); + cnnew.setSuper(td.getSymbol()); + parseClassBody(cnnew, pn.getChild("decl").getChild("classbody")); + Vector args=parseArgumentList(pn); + + CreateObjectNode con=new CreateObjectNode(td, false, null); + con.setNumLine(pn.getLine()); + for(int i=0; i<args.size(); i++) { + con.addArgument((ExpressionNode)args.get(i)); + } + return con; } else if (isNode(pn,"createarray")) { //System.out.println(pn.PPrint(3,true)); diff --git a/Robust/src/Parse/java14.cup b/Robust/src/Parse/java14.cup index e72d7c9d..f2de1ea0 100644 --- a/Robust/src/Parse/java14.cup +++ b/Robust/src/Parse/java14.cup @@ -70,6 +70,7 @@ terminal TRY; // try_statement terminal CATCH; // catch_clause terminal FINALLY; // finally terminal NEW; // class_instance_creation_expression +terminal NEWFLAG; // class_instance_creation_expression terminal PLUSPLUS; // postincrement_expression terminal MINUSMINUS; // postdecrement_expression terminal PLUS, MINUS, COMP, NOT, DIV, MOD; @@ -1910,19 +1911,24 @@ primary_no_new_array ::= // | name DOT THIS ; class_instance_creation_expression ::= - NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: + NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: ParseNode pn=new ParseNode("createobject",parser.lexer.line_num); pn.addChild(type); pn.addChild(args); pn.addChild(feo); RESULT=pn; + :} | + NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {: + ParseNode pn=new ParseNode("createobject",parser.lexer.line_num); + pn.addChild(type); + pn.addChild(args); + RESULT=pn; :} //Global object - | GLOBAL NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: + | GLOBAL NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {: ParseNode pn=new ParseNode("createobject",parser.lexer.line_num); pn.addChild(type); pn.addChild(args); - pn.addChild(feo); pn.addChild("global"); RESULT=pn; :} @@ -1930,27 +1936,25 @@ class_instance_creation_expression ::= ParseNode pn=new ParseNode("createobject",parser.lexer.line_num); pn.addChild(type); pn.addChild(args); - pn.addChild(feo); pn.addChild("scratch"); RESULT=pn; :} // Objects we want to track in disjointness analysis - | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: + | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {: ParseNode pn=new ParseNode("createobject",parser.lexer.line_num); pn.addChild(type); pn.addChild(args); - pn.addChild(feo); pn.addChild("disjoint").addChild(id); RESULT=pn; :} - | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {: + | NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {: ParseNode pn=new ParseNode("createobject",parser.lexer.line_num); pn.addChild(type); pn.addChild(args); pn.addChild(tl); RESULT=pn; :} - | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {: + | NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {: ParseNode pn=new ParseNode("createobject",parser.lexer.line_num); pn.addChild(type); pn.addChild(args); @@ -1958,8 +1962,13 @@ class_instance_creation_expression ::= pn.addChild(tl); RESULT=pn; :} - -// | NEW class_or_interface_type LPAREN argument_list_opt RPAREN class_body + | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN class_body:body {: + ParseNode pn=new ParseNode("createobjectcls",parser.lexer.line_num); + pn.addChild(type); + pn.addChild(args); + pn.addChild("decl").addChild("classbody").addChild(body); + RESULT=pn; + :} // | primary DOT NEW IDENTIFIER // LPAREN argument_list_opt RPAREN {: // diff --git a/Robust/src/buildscript b/Robust/src/buildscript index aedf1b02..4af2cb7b 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -767,7 +767,7 @@ fi # Setup class path if $JNI then -JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/classpath/java/lang/ -classlibrary $ROBUSTROOT/ClassLibrary/java/io/" +JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/classpath/java/lang/ -classlibrary $ROBUSTROOT/classpath/java/io/ -classlibrary $ROBUSTROOT/classpath/java/lang/reflect/ -classlibrary $ROBUSTROOT/classpath/java/text/ -classlibrary $ROBUSTROOT/classpath/java/security/ -classlibrary $ROBUSTROOT/classpath/java/net/" elif $MGCINTELFLAG then JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/MGC/ -classlibrary $ROBUSTROOT/ClassLibrary/MGC/gnu/" -- 2.34.1