Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv7901/src/bossa/syntax
Modified Files:
UserOperator.java CustomConstructor.java AST.java
Log Message:
Make custom constructors available for calls.
Index: UserOperator.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/UserOperator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** UserOperator.java 28 Nov 2003 13:52:08 -0000 1.6
--- UserOperator.java 13 Dec 2003 14:54:08 -0000 1.7
***************
*** 43,48 ****
--- 43,54 ----
****************************************************************/
+ private boolean resolved = false;
+
void doResolve()
{
+ if (resolved)
+ return;
+ resolved = true;
+
// the type must be found before
removeChild(getSymbol());
Index: CustomConstructor.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CustomConstructor.java 13 Dec 2003 13:31:42 -0000 1.2
--- CustomConstructor.java 13 Dec 2003 14:54:08 -0000 1.3
***************
*** 39,42 ****
--- 39,48 ----
}
+ void resolve()
+ {
+ classTC = Node.getGlobalTypeScope().globalLookup(className);
+ TypeConstructors.addConstructor(classTC, this);
+ }
+
public void printInterface(java.io.PrintWriter s)
{
***************
*** 46,54 ****
protected gnu.expr.Expression computeCode()
{
! return null;
}
LocatedString className;
Block body;
!
}
--- 52,60 ----
protected gnu.expr.Expression computeCode()
{
! return gnu.expr.QuoteExp.nullExp;
}
LocatedString className;
Block body;
! TypeConstructor classTC;
}
Index: AST.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** AST.java 28 Nov 2003 13:52:08 -0000 1.52
--- AST.java 13 Dec 2003 14:54:08 -0000 1.53
***************
*** 48,51 ****
--- 48,52 ----
ArrayList methods = new ArrayList(children.size());
ArrayList globals = new ArrayList(10);
+ ArrayList customConstructors = new ArrayList(10);
for(Iterator i = children.iterator(); i.hasNext();)
***************
*** 54,57 ****
--- 55,63 ----
if (node instanceof ClassDefinition)
classes.add(node);
+ else if (node instanceof CustomConstructor)
+ {
+ customConstructors.add(node);
+ methods.add(node);
+ }
else if (node instanceof MethodDeclaration)
methods.add(node);
***************
*** 72,75 ****
--- 78,84 ----
this.globals = (GlobalVarDeclaration[])
globals.toArray(new GlobalVarDeclaration[globals.size()]);
+
+ this.customConstructors = (CustomConstructor[])
+ customConstructors.toArray(new CustomConstructor[customConstructors.size()]);
}
***************
*** 97,100 ****
--- 106,113 ----
resolve(classes[i]);
+ // Custom constructors depend classes, and code can depend on them
+ for(int i = 0; i < customConstructors.length; i++)
+ resolve(customConstructors[i]);
+
for(Iterator i = children.iterator();i.hasNext();)
{
***************
*** 219,222 ****
--- 232,236 ----
private MethodDeclaration[] methods;
private GlobalVarDeclaration[] globals;
+ private CustomConstructor[] customConstructors;
}
|