From dfb56295226e3b8ed74c134d8fcf0c78009c4933 Mon Sep 17 00:00:00 2001 From: jzhou Date: Tue, 15 Nov 2011 20:45:39 +0000 Subject: [PATCH] a missing check --- Robust/src/IR/Tree/SemanticCheck.java | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java index 406591e6..7a660ad4 100644 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ b/Robust/src/IR/Tree/SemanticCheck.java @@ -1196,10 +1196,10 @@ public class SemanticCheck { for (Iterator method_it = cd.getMethods(); method_it.hasNext(); ) { MethodDescriptor md = (MethodDescriptor) method_it.next(); try { - checkMethodBody(cd, md); + checkMethodBody(cd, md); } catch (Error e) { - System.out.println("Error in " + md); - throw e; + System.out.println("Error in " + md); + throw e; } } trialcheck = false; @@ -1218,7 +1218,7 @@ public class SemanticCheck { for(Iterator it_methods = cd.getMethods(); it_methods.hasNext();) { MethodDescriptor imd = (MethodDescriptor)it_methods.next(); if(imd.isConstructor()) { - cd_construtor = imd; // an inline class should only have one anonymous constructor + cd_construtor = imd; // an inline class should only have one anonymous constructor } } MethodInvokeNode min = null; @@ -1242,19 +1242,22 @@ public class SemanticCheck { // do a round of semantic check trial to get all the live vars required by the inline class trialSemanticCheck(cd); Vector vars = this.inlineClass2LiveVars.remove(cd); + if(vars == null) { + return; + } for(int i = 0; i < vars.size(); i++) { Descriptor d = vars.elementAt(i); if(d instanceof VarDescriptor && !d.getSymbol().equals("this")) { - con.addArgument(new NameNode(new NameDescriptor(d.getSymbol()))); - cd.addField(new FieldDescriptor(new Modifiers(Modifiers.PUBLIC), ((VarDescriptor)d).getType(), d.getSymbol(), null, false)); - cd_construtor.addParameter(((VarDescriptor)d).getType(), d.getSymbol()+"_p"); - // add the initialize statement into this constructor - BlockNode obn = state.getMethodBody(cd_construtor); - NameNode nn=new NameNode(new NameDescriptor(d.getSymbol())); - NameNode fn = new NameNode (new NameDescriptor(d.getSymbol()+"_p")); - AssignmentNode an=new AssignmentNode(nn,fn,new AssignOperation(1)); - obn.addFirstBlockStatement(new BlockExpressionNode(an)); - state.addTreeCode(cd_construtor, obn); + con.addArgument(new NameNode(new NameDescriptor(d.getSymbol()))); + cd.addField(new FieldDescriptor(new Modifiers(Modifiers.PUBLIC), ((VarDescriptor)d).getType(), d.getSymbol(), null, false)); + cd_construtor.addParameter(((VarDescriptor)d).getType(), d.getSymbol()+"_p"); + // add the initialize statement into this constructor + BlockNode obn = state.getMethodBody(cd_construtor); + NameNode nn=new NameNode(new NameDescriptor(d.getSymbol())); + NameNode fn = new NameNode (new NameDescriptor(d.getSymbol()+"_p")); + AssignmentNode an=new AssignmentNode(nn,fn,new AssignOperation(1)); + obn.addFirstBlockStatement(new BlockExpressionNode(an)); + state.addTreeCode(cd_construtor, obn); } } } @@ -1328,12 +1331,12 @@ public class SemanticCheck { // of the inline class InlineClassAddParamToCtor( (MethodDescriptor)md, classtolookin, nametable, con, td, tdarray ); } - tdarray = new TypeDescriptor[con.numArgs()]; - for (int i = 0; i < con.numArgs(); i++) { - ExpressionNode en = con.getArg(i); - checkExpressionNode(md, nametable, en, null); - tdarray[i] = en.getType(); - } + tdarray = new TypeDescriptor[con.numArgs()]; + for (int i = 0; i < con.numArgs(); i++) { + ExpressionNode en = con.getArg(i); + checkExpressionNode(md, nametable, en, null); + tdarray[i] = en.getType(); + } } Set methoddescriptorset = classtolookin.getMethodTable().getSet(classtolookin.getSymbol()); MethodDescriptor bestmd = null; -- 2.34.1