Thread: [Nice-commit] Nice/src/bossa/syntax Module.java,1.19,1.20 GlobalVarDeclaration.java,1.22,1.23 EnumDe
Brought to you by:
bonniot
From: <bo...@us...> - 2004-03-05 14:21:24
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4983/src/bossa/syntax Modified Files: Module.java GlobalVarDeclaration.java EnumDefinition.java AST.java Log Message: Compile global variables lazily, so that all direct dependencies are handled correctly (not just one level of dependency). Index: Module.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Module.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Module.java 27 Nov 2003 14:57:56 -0000 1.19 --- Module.java 5 Mar 2004 14:07:14 -0000 1.20 *************** *** 31,35 **** gnu.bytecode.ClassType createClass(String name); ! gnu.expr.Declaration addGlobalVar(String name, gnu.bytecode.Type type, boolean constant); gnu.expr.Expression getDispatchMethod(NiceMethod def); gnu.expr.ReferenceExp addMethod(gnu.expr.LambdaExp method, --- 31,35 ---- gnu.bytecode.ClassType createClass(String name); ! void addGlobalVar(gnu.expr.Declaration declaration, boolean constant); gnu.expr.Expression getDispatchMethod(NiceMethod def); gnu.expr.ReferenceExp addMethod(gnu.expr.LambdaExp method, Index: GlobalVarDeclaration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/GlobalVarDeclaration.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** GlobalVarDeclaration.java 15 Dec 2003 14:04:13 -0000 1.22 --- GlobalVarDeclaration.java 5 Mar 2004 14:07:14 -0000 1.23 *************** *** 26,30 **** @version $Date$ ! @author Daniel Bonniot (d.b...@ma...) */ public class GlobalVarDeclaration extends Definition --- 26,30 ---- @version $Date$ ! @author Daniel Bonniot (bo...@us...) */ public class GlobalVarDeclaration extends Definition *************** *** 63,71 **** if (res == null) { ! res = module.addGlobalVar ! (left.name.toString(), ! nice.tools.code.Types.javaType(left.type), ! constant); setDeclaration(res); } --- 63,78 ---- if (res == null) { ! res = new gnu.expr.Declaration ! (name.toString(), nice.tools.code.Types.javaType(type)); setDeclaration(res); + + if (! inInterfaceFile()) + { + // Compute the value first, which might use another global value, + // which will then be properly initialized before use. + res.noteValue(GlobalVarDeclaration.this.compileValue()); + } + + module.addGlobalVar(res, constant); } *************** *** 128,146 **** ****************************************************************/ ! public void precompile() { ! // Compute the value first, and this might use another global value, ! // which will then be properly initialized before use. ! gnu.expr.Expression value = ! this.value != null ? this.value.compile() : null; ! ! gnu.expr.Declaration declaration = left.getDeclaration(); ! if (constant) declaration.setFlag(Declaration.IS_CONSTANT); ! ! declaration.noteValue(value); } ! public void compile() { } --- 135,147 ---- ****************************************************************/ ! public void compile() { ! left.getDeclaration(); } ! private gnu.expr.Expression compileValue() { + return + this.value != null ? this.value.compile() : null; } Index: EnumDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/EnumDefinition.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EnumDefinition.java 16 Jan 2004 00:14:07 -0000 1.9 --- EnumDefinition.java 5 Mar 2004 14:07:14 -0000 1.10 *************** *** 122,127 **** if (res == null) { ! res = module.addGlobalVar(name.toString(), Types.javaType(type), true); setDeclaration(res); } --- 122,129 ---- if (res == null) { ! res = new gnu.expr.Declaration ! (name.toString(), Types.javaType(type)); setDeclaration(res); + module.addGlobalVar(res, true); } Index: AST.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** AST.java 28 Feb 2004 14:23:43 -0000 1.57 --- AST.java 5 Mar 2004 14:07:14 -0000 1.58 *************** *** 213,220 **** // dependencies, and initialize them in the right order. for (int i = 0; i < globals.length; i++) ! globals[i].precompile(); ! for(Iterator i = children.iterator();i.hasNext();) ! ((Definition)i.next()).compile(); } } --- 213,220 ---- // dependencies, and initialize them in the right order. for (int i = 0; i < globals.length; i++) ! globals[i].compile(); ! for (Iterator i = children.iterator();i.hasNext();) ! ((Definition) i.next()).compile(); } } |