changes
authorbdemsky <bdemsky>
Sun, 17 Apr 2011 08:13:37 +0000 (08:13 +0000)
committerbdemsky <bdemsky>
Sun, 17 Apr 2011 08:13:37 +0000 (08:13 +0000)
Robust/src/IR/Tree/BuildIR.java
Robust/src/Parse/java14.cup
Robust/src/buildscript

index 5014d8775d57019cf101670151814a814e369525..8acca7b2a17ad735432f8f19f25abc303283e1b4 100644 (file)
@@ -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));
index e72d7c9db8c827bd5c4963556f13cc0ef0024a95..f2de1ea088a626fa9c22c61f66006db1259f2afa 100644 (file)
@@ -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 {: 
 //             
index aedf1b0252c76dad2e0ace7f3850dae43ce31a0f..4af2cb7b67688082f590b1634b0d3192d39eb2fc 100755 (executable)
@@ -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/"