+
+ // add all the vars in the surrounding context of the inline class into the inline
+ // classes field table and pass them to the inline class' constructors
+ // TODO: BUGFIX. There need not add all the local vars of the surrounding context
+ // into the inline class. Should only add those that are referred to inside the inline
+ // class. Also these local vars should be final. But currently we've lost those
+ // information, so we cannot have that checked.
+ void InlineClassAddParamToCtor(MethodDescriptor md, ClassDescriptor cd , SymbolTable nametable, CreateObjectNode con, TypeDescriptor td ) {
+ Iterator it_values = nametable.getAllValueSet().iterator();
+ while(it_values.hasNext()) {
+ Descriptor d = (Descriptor)it_values.next();
+ 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));
+ for(Iterator it_methods = cd.getMethods(); it_methods.hasNext();) {
+ MethodDescriptor imd = (MethodDescriptor)it_methods.next();
+ if(imd.isConstructor()) {
+ imd.addParameter(((VarDescriptor)d).getType(), d.getSymbol()+"_p");
+ // add the initialize statement into this constructor
+ BlockNode obn = state.getMethodBody(imd);
+ 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(imd, obn);
+ }
+ }
+ }
+ }
+ }
+