[Nice-commit] Nice/src/bossa/syntax ToplevelFunction.java,1.18,1.19 Module.java,1.14,1.15 FormalPara
Brought to you by:
bonniot
From: <bo...@us...> - 2003-08-08 19:16:36
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv18726/src/bossa/syntax Modified Files: ToplevelFunction.java Module.java FormalParameters.java Log Message: Fixed default values of optional parameters refering to a previous one, when the function is imported from a compiled package. Fixed nested calls to such functions. Index: ToplevelFunction.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ToplevelFunction.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ToplevelFunction.java 26 Jul 2003 22:02:01 -0000 1.18 --- ToplevelFunction.java 8 Aug 2003 19:16:33 -0000 1.19 *************** *** 148,153 **** // Just get the handle to the already compiled function. ! gnu.expr.Expression res = module.lookupPackageMethod ! (name.toString(), getType().toString()); if (res != null) --- 148,152 ---- // Just get the handle to the already compiled function. ! gnu.expr.Expression res = module.lookupPackageMethod(this); if (res != null) *************** *** 160,163 **** --- 159,163 ---- LambdaExp code = Gen.createMethod (name.toString(), javaArgTypes(), javaReturnType(), getSymbols()); + code.parameterCopies = parameters.getParameterCopies(); code.addBytecodeAttribute (new MiscAttr("type", getType().toString().getBytes())); Index: Module.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Module.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Module.java 30 Apr 2003 19:39:04 -0000 1.14 --- Module.java 8 Aug 2003 19:16:33 -0000 1.15 *************** *** 32,36 **** gnu.expr.Declaration addGlobalVar(String name, gnu.bytecode.Type type, boolean constant); gnu.expr.Expression getDispatchMethod(NiceMethod def); ! gnu.expr.Expression lookupPackageMethod(String methodName, String type); gnu.expr.ReferenceExp addMethod(gnu.expr.LambdaExp method, boolean packageMethod); --- 32,36 ---- gnu.expr.Declaration addGlobalVar(String name, gnu.bytecode.Type type, boolean constant); gnu.expr.Expression getDispatchMethod(NiceMethod def); ! gnu.expr.Expression lookupPackageMethod(ToplevelFunction fun); gnu.expr.ReferenceExp addMethod(gnu.expr.LambdaExp method, boolean packageMethod); Index: FormalParameters.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FormalParameters.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** FormalParameters.java 31 Jul 2003 23:40:23 -0000 1.30 --- FormalParameters.java 8 Aug 2003 19:16:33 -0000 1.31 *************** *** 107,116 **** { if (state == ARGUMENT_REFERENCE) ! captured = true; return state; } ! private boolean captured = false; public void setDeclaration (gnu.expr.Declaration declaration, --- 107,118 ---- { if (state == ARGUMENT_REFERENCE) ! // This parameter is referenced by a later one. ! // We will need to copy its value. ! copies = new java.util.Stack(); return state; } ! private java.util.Stack copies; public void setDeclaration (gnu.expr.Declaration declaration, *************** *** 118,124 **** { super.setDeclaration(declaration, isThis); - - if (captured) - getDeclaration().mustCopyValue(true); } } --- 120,123 ---- *************** *** 137,141 **** public gnu.expr.Expression compile () { ! return new gnu.expr.CopyArgument(this.getSymbol().getDeclaration()); } } --- 136,140 ---- public gnu.expr.Expression compile () { ! return new gnu.expr.CopyArgument(((Symbol) this.getSymbol()).copies); } } *************** *** 504,507 **** --- 503,524 ---- } } + return res; + } + + public java.util.Stack[] getParameterCopies() + { + java.util.Stack[] res = null; + + for(int i = 0; i < size; i++) + { + Parameter param = parameters[i]; + if (param.symbol.copies != null) + { + if (res == null) + res = new java.util.Stack[parameters.length]; + res[i] = param.symbol.copies; + } + } + return res; } |