[Nice-commit] Nice/src/bossa/syntax CustomConstructor.java,1.16,1.17 dispatch.java.bootstrap,1.14,1.
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-08-02 19:11:08
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9750/F:/nice/src/bossa/syntax Modified Files: CustomConstructor.java dispatch.java.bootstrap tools.nice Log Message: Don't use specific expression/statements in enumdefinition. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** tools.nice 30 Jul 2004 19:08:45 -0000 1.39 --- tools.nice 2 Aug 2004 19:10:58 -0000 1.40 *************** *** 142,145 **** --- 142,186 ---- } + void resolveCCThis(Statement stmt, Located thisLoc, NiceClass classe) + { + Block block = cast(stmt); + + Statement last = block.last; + if (last instanceof Block) + { + resolveCCThis(last, thisLoc, classe); + return; + } + + void missingThisError() + { + User.error(thisLoc, "The last statement must be a call to 'this' constructor"); + } + + if (! (last instanceof ExpressionStmt)) + missingThisError(); + + ExpressionStmt expstmt = cast(last); + + if (! (expstmt.exp instanceof CallExp)) + missingThisError(); + + CallExp call = cast(expstmt.exp); + + if (! (call.function instanceof IdentExp)) + missingThisError(); + + IdentExp ident = cast(call.function); + + if (! ident.toString().equals("this")) + missingThisError(); + + Location loc = ident.location(); + call.function = createOverloadedSymbolExp(classe.getConstructorCallSymbols(), + FormalParameters.thisName); + notNull(call.function).setLocation(loc); + } + + // For bootstrap void _printStackTraceWithSourceInfo(Throwable t) = *************** *** 168,171 **** --- 209,214 ---- <T> String map(String, String, String, T[]) = native String bossa.util.Util.map(String, String, String, Object[]); Stack<bossa.link.Alternative> sortedAlternatives(MethodDeclaration) = native Stack bossa.link.Alternative.sortedAlternatives(MethodDeclaration); + List<VarSymbol> getConstructorCallSymbols(NiceClass) = native List NiceClass.getConstructorCallSymbols(); + // Retypings needed since java types are not strict. Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** CustomConstructor.java 28 Jul 2004 14:40:33 -0000 1.16 --- CustomConstructor.java 2 Aug 2004 19:10:58 -0000 1.17 *************** *** 153,188 **** void resolveBody() { ! resolveThis((Block) body); body = bossa.syntax.dispatch.analyse (body, thisScope, thisTypeScope, false); } - private void resolveThis(Block block) - { - Statement last = block.statements[block.statements.length - 1]; - if (last instanceof Block) - { - resolveThis((Block) last); - return; - } - - try { - CallExp call = (CallExp) ((ExpressionStmt) last).exp; - IdentExp ident = (IdentExp) call.function; - if (! call.function.toString().equals("this")) - User.error(this, - "The last statement must be a call to 'this' constructor"); - - Location loc = ident.location(); - call.function = bossa.syntax.dispatch.createOverloadedSymbolExp - (classe.getConstructorCallSymbols(), FormalParameters.thisName); - call.function.setLocation(loc); - } - catch(ClassCastException ex) { - User.error(this, - "The last statement must be a call to 'this' constructor"); - } - } - void innerTypecheck() throws TypingEx { --- 153,161 ---- void resolveBody() { ! bossa.syntax.dispatch.resolveCCThis(body, this, classe); body = bossa.syntax.dispatch.analyse (body, thisScope, thisTypeScope, false); } void innerTypecheck() throws TypingEx { Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** dispatch.java.bootstrap 30 Jul 2004 13:06:21 -0000 1.14 --- dispatch.java.bootstrap 2 Aug 2004 19:10:58 -0000 1.15 *************** *** 34,37 **** --- 34,39 ---- { return null; } + static void resolveCCThis(Statement stmt, bossa.util.Located thisloc, NiceClass classe) {} + static Statement analyse(Statement s, VarScope v, TypeScope t, boolean r) { return null; } |