[Nice-commit] Nice/src/bossa/syntax MethodBodyDefinition.java,1.112,1.113 AST.java,1.39,1.40
Brought to you by:
bonniot
|
From: <bo...@us...> - 2003-03-04 16:50:28
|
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv26840/src/bossa/syntax
Modified Files:
MethodBodyDefinition.java AST.java
Log Message:
Fixed compilation of packages cyclically importing each other (exhibited by
some code written by Alex).
Index: MethodBodyDefinition.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v
retrieving revision 1.112
retrieving revision 1.113
diff -C2 -d -r1.112 -r1.113
*** MethodBodyDefinition.java 16 Jan 2003 01:52:32 -0000 1.112
--- MethodBodyDefinition.java 4 Mar 2003 16:50:18 -0000 1.113
***************
*** 465,468 ****
--- 465,469 ----
gnu.expr.ReferenceExp ref;
+ gnu.expr.LambdaExp compiledMethod;
public gnu.expr.ReferenceExp getRefExp()
***************
*** 481,498 ****
public void compile()
{
! if(Debug.codeGeneration)
Debug.println("Compiling method body " + this);
getRefExp();
}
private gnu.expr.ReferenceExp compile (NiceMethod definition)
{
! gnu.expr.LambdaExp lexp = createMethod(name.toString(), false);
! gnu.expr.ReferenceExp ref = module.addMethod(lexp, true);
! lexp.addBytecodeAttribute
(new MiscAttr("definition", definition.getFullName().getBytes()));
! lexp.addBytecodeAttribute
(new MiscAttr("patterns",
Pattern.bytecodeRepresentation(formals).getBytes()));
--- 482,500 ----
public void compile()
{
! if (Debug.codeGeneration)
Debug.println("Compiling method body " + this);
getRefExp();
+ Gen.setMethodBody(compiledMethod, body.generateCode());
}
private gnu.expr.ReferenceExp compile (NiceMethod definition)
{
! createMethod(name.toString(), false);
! gnu.expr.ReferenceExp ref = module.addMethod(compiledMethod, true);
! compiledMethod.addBytecodeAttribute
(new MiscAttr("definition", definition.getFullName().getBytes()));
! compiledMethod.addBytecodeAttribute
(new MiscAttr("patterns",
Pattern.bytecodeRepresentation(formals).getBytes()));
***************
*** 520,532 ****
private void compile (JavaMethod declaration)
{
! gnu.expr.LambdaExp lexp = createMethod(declaration.getName().toString(), true);
// Compile as a method in the class of the first argument
! declaringClass().addJavaMethod(lexp);
}
! private gnu.expr.LambdaExp createMethod (String bytecodeName, boolean member)
{
! gnu.expr.LambdaExp lexp =
Gen.createMethod(bytecodeName,
javaArgTypes(),
--- 522,534 ----
private void compile (JavaMethod declaration)
{
! createMethod(declaration.getName().toString(), true);
// Compile as a method in the class of the first argument
! declaringClass().addJavaMethod(compiledMethod);
}
! private void createMethod (String bytecodeName, boolean member)
{
! compiledMethod =
Gen.createMethod(bytecodeName,
javaArgTypes(),
***************
*** 534,539 ****
parameters,
true, member);
- Gen.setMethodBody(lexp, body.generateCode());
- return lexp;
}
--- 536,539 ----
Index: AST.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** AST.java 12 Feb 2003 12:48:34 -0000 1.39
--- AST.java 4 Mar 2003 16:50:19 -0000 1.40
***************
*** 83,90 ****
nice.tools.compiler.OutputMessages.exitIfErrors();
}
!
! public void typechecking()
{
Node.setModule(module);
for(Iterator i = children.iterator(); i.hasNext();)
{
--- 83,91 ----
nice.tools.compiler.OutputMessages.exitIfErrors();
}
!
! public void typedResolve()
{
Node.setModule(module);
+
for(Iterator i = children.iterator(); i.hasNext();)
{
***************
*** 99,120 ****
}
nice.tools.compiler.OutputMessages.exitIfErrors();
! module.unfreezeGlobalContext();
! try{
! for(Iterator i = children.iterator(); i.hasNext();)
! {
! Definition d = (Definition) i.next();
! try{
! d.resolveBody();
! }
! catch(UserError ex){
! nice.tools.compiler.OutputMessages.error(ex.getMessage());
! }
}
! } finally {
! module.freezeGlobalContext();
! }
nice.tools.compiler.OutputMessages.exitIfErrors();
// Classes are typechecked first, since code can depend on them.
for(int i = 0; i < classes.length; i++)
--- 100,130 ----
}
nice.tools.compiler.OutputMessages.exitIfErrors();
+ }
! public void localResolve()
! {
! Node.setModule(module);
!
! for (Iterator i = children.iterator(); i.hasNext();)
! {
! Definition d = (Definition) i.next();
! try{
! d.resolveBody();
}
! catch(UserError ex){
! nice.tools.compiler.OutputMessages.error(ex.getMessage());
! }
! }
!
nice.tools.compiler.OutputMessages.exitIfErrors();
+ for (int i = 0; i < classes.length; i++)
+ classes[i].precompile();
+ }
+
+ public void typechecking()
+ {
+ Node.setModule(module);
+
// Classes are typechecked first, since code can depend on them.
for(int i = 0; i < classes.length; i++)
***************
*** 136,142 ****
public void compile(boolean generateCode)
{
- for(int i = 0; i < classes.length; i++)
- classes[i].precompile();
-
if (! generateCode)
return;
--- 146,149 ----
|