[Nice-commit] Nice/src/bossa/syntax analyse.nice,1.74,1.75 ToplevelFunction.java,1.17,1.18 Overloade
Brought to you by:
bonniot
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv20817/src/bossa/syntax Modified Files: analyse.nice ToplevelFunction.java OverloadedSymbolExp.java NiceFieldAccess.java NiceClass.java MethodBodyDefinition.java FormalParameters.java Log Message: Reimplemented field access with implicit 'this', without using the special ThisParameter (similar to default value of field accesses). Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** analyse.nice 24 Jun 2003 15:28:19 -0000 1.74 --- analyse.nice 26 Jul 2003 22:02:01 -0000 1.75 *************** *** 442,448 **** } ! if (sym.isFieldAccess()) ! return new CallExp(newOverloadedSymbolExp(symbols, e.ident), ! Arguments.noArguments()); return new SymbolExp(sym, e.location()); --- 442,449 ---- } ! if (sym.isFieldAccess() && Node.thisExp != null) ! return new CallExp ! (newOverloadedSymbolExp(symbols, e.ident), ! new Arguments([new Arguments.Argument(Node.thisExp)])); return new SymbolExp(sym, e.location()); Index: ToplevelFunction.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ToplevelFunction.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ToplevelFunction.java 28 May 2003 12:57:26 -0000 1.17 --- ToplevelFunction.java 26 Jul 2003 22:02:01 -0000 1.18 *************** *** 84,88 **** { if (body != null) ! body = dispatch.analyse(body, thisScope, thisTypeScope, !voidReturn); } --- 84,98 ---- { if (body != null) ! { ! if (parameters.hasThis()) ! Node.thisExp = new SymbolExp(getSymbols()[0], location()); ! ! try { ! body = dispatch.analyse(body, thisScope, thisTypeScope, !voidReturn); ! } ! finally { ! Node.thisExp = null; ! } ! } } Index: OverloadedSymbolExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/OverloadedSymbolExp.java,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** OverloadedSymbolExp.java 25 Jul 2003 16:59:24 -0000 1.56 --- OverloadedSymbolExp.java 26 Jul 2003 22:02:01 -0000 1.57 *************** *** 262,273 **** { if (fieldAccesses.size() != 0) ! try { ! CallExp res = new CallExp ! (new OverloadedSymbolExp(fieldAccesses, ident), ! Arguments.noArguments()); ! res.resolveOverloading(); ! return res; ! } ! catch (UserError e) { symbols.removeAll(filterFieldAccesses()); --- 262,278 ---- { if (fieldAccesses.size() != 0) ! { ! if (Node.thisExp != null) ! try { ! CallExp res = new CallExp ! (new OverloadedSymbolExp(fieldAccesses, ident), ! //Arguments.noArguments()); ! new Arguments(new Arguments.Argument[]{new Arguments.Argument(Node.thisExp)})); ! ! res.resolveOverloading(); ! return res; ! } ! catch (UserError e) {} ! symbols.removeAll(filterFieldAccesses()); Index: NiceFieldAccess.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceFieldAccess.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** NiceFieldAccess.java 28 May 2003 12:57:26 -0000 1.14 --- NiceFieldAccess.java 26 Jul 2003 22:02:01 -0000 1.15 *************** *** 46,50 **** { List res = new LinkedList(); ! res.add(new FormalParameters.ThisParameter(Monotype.create(t))); return new FormalParameters(res); } --- 46,50 ---- { List res = new LinkedList(); ! res.add(new FormalParameters.Parameter(Monotype.create(t))); return new FormalParameters(res); } Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** NiceClass.java 25 Jul 2003 16:13:10 -0000 1.50 --- NiceClass.java 26 Jul 2003 22:02:01 -0000 1.51 *************** *** 221,225 **** } }; ! scope.addSymbol(thisSymbol); --- 221,225 ---- } }; ! Node.thisExp = new SymbolExp(thisSymbol, definition.location()); scope.addSymbol(thisSymbol); *************** *** 227,230 **** --- 227,231 ---- initializers[i] = bossa.syntax.dispatch.analyse (initializers[i], definition.scope, localScope, false); + Node.thisExp = null; } Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.135 retrieving revision 1.136 diff -C2 -d -r1.135 -r1.136 *** MethodBodyDefinition.java 25 Jul 2003 16:13:10 -0000 1.135 --- MethodBodyDefinition.java 26 Jul 2003 22:02:01 -0000 1.136 *************** *** 369,374 **** void resolveBody() { ! body = bossa.syntax.dispatch.analyse ! (body, scope, typeScope, !Types.isVoid(declaration.getReturnType())); } --- 369,382 ---- void resolveBody() { ! if (insideClass) ! Node.thisExp = new SymbolExp(parameters[0], location()); ! ! try { ! body = bossa.syntax.dispatch.analyse ! (body, scope, typeScope, !Types.isVoid(declaration.getReturnType())); ! } ! finally { ! Node.thisExp = null; ! } } Index: FormalParameters.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FormalParameters.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** FormalParameters.java 26 Jul 2003 12:04:13 -0000 1.27 --- FormalParameters.java 26 Jul 2003 22:02:01 -0000 1.28 *************** *** 222,235 **** } - static class ThisParameter extends Parameter - { - ThisParameter(Monotype type) - { - super(type); - } - - Expression value() { return Node.thisExp; } - } - /**************************************************************** * Main class --- 222,225 ---- |