[Nice-commit] Nice/src/bossa/syntax symbolexp.nice,NONE,1.1 DefaultMethodImplementation.java,1.10,1.
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-12-04 19:38:29
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28773/F:/nice/src/bossa/syntax Modified Files: DefaultMethodImplementation.java FormalParameters.java MethodImplementation.java analyse.nice call.nice dispatch.java.bootstrap methodbody.nice new.nice niceclass.nice overloadedsymbol.nice tools.nice Added Files: symbolexp.nice Removed Files: SymbolExp.java Log Message: Converted SymbolExp. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.115 retrieving revision 1.116 diff -C2 -d -r1.115 -r1.116 *** analyse.nice 1 Dec 2004 02:00:31 -0000 1.115 --- analyse.nice 4 Dec 2004 19:38:18 -0000 1.116 *************** *** 503,507 **** return createOverloadedSymbolExp(sym, notNull(e.ident)); else ! return new SymbolExp(sym, e.location()); } } --- 503,507 ---- return createOverloadedSymbolExp(sym, notNull(e.ident)); else ! return createSymbolExp(sym, e.location()); } } *************** *** 526,530 **** if (state == 1/*XXX: FormalParameters.Parameter.Symbol.ARGUMENT_REFERENCE*/) ! return new FormalParameters.Parameter.AccessExp(sym, e.location()); // Otherwise, we are in the normal case. } --- 526,530 ---- if (state == 1/*XXX: FormalParameters.Parameter.Symbol.ARGUMENT_REFERENCE*/) ! return createParameterAccessExp(sym, e.location()); // Otherwise, we are in the normal case. } *************** *** 547,551 **** } ! return new SymbolExp(sym, e.location()); } else --- 547,551 ---- } ! return createSymbolExp(sym, e.location()); } else Index: methodbody.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodbody.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** methodbody.nice 1 Dec 2004 02:00:32 -0000 1.2 --- methodbody.nice 4 Dec 2004 19:38:18 -0000 1.3 *************** *** 415,419 **** Node.currentFunction = this; if (this.hasThis()) ! Node.thisExp = new SymbolExp(notNull(parameters)[0], this.location()); typecheck(body); --- 415,419 ---- Node.currentFunction = this; if (this.hasThis()) ! Node.thisExp = createSymbolExp(notNull(parameters)[0], this.location()); typecheck(body); Index: MethodImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodImplementation.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MethodImplementation.java 25 Nov 2004 19:28:18 -0000 1.10 --- MethodImplementation.java 4 Dec 2004 19:38:18 -0000 1.11 *************** *** 114,118 **** { if (hasThis()) ! Node.thisExp = new SymbolExp(parameters[0], location()); try { --- 114,118 ---- { if (hasThis()) ! Node.thisExp = dispatch.createSymbolExp(parameters[0], location()); try { Index: DefaultMethodImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/DefaultMethodImplementation.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DefaultMethodImplementation.java 10 Oct 2004 12:48:42 -0000 1.10 --- DefaultMethodImplementation.java 4 Dec 2004 19:38:18 -0000 1.11 *************** *** 92,96 **** Node.currentFunction = this; if (hasThis()) ! Node.thisExp = new SymbolExp(parameters[0], location()); try{ --- 92,96 ---- Node.currentFunction = this; if (hasThis()) ! Node.thisExp = dispatch.createSymbolExp(parameters[0], location()); try{ --- SymbolExp.java DELETED --- Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** niceclass.nice 25 Nov 2004 19:28:18 -0000 1.6 --- niceclass.nice 4 Dec 2004 19:38:18 -0000 1.7 *************** *** 233,237 **** thisSymbol = new ThisSymbol(FormalParameters.thisName, thisType, declaringClass: this); ! Node.thisExp = new SymbolExp(thisSymbol, definition.location()); scope.addSymbol(thisSymbol); --- 233,237 ---- thisSymbol = new ThisSymbol(FormalParameters.thisName, thisType, declaringClass: this); ! Node.thisExp = createSymbolExp(notNull(thisSymbol), definition.location()); scope.addSymbol(thisSymbol); *************** *** 295,299 **** { this.enterTypingContext(); ! Node.thisExp = new SymbolExp(thisSymbol, definition.location()); for (init : initializers) typecheck(init); --- 295,299 ---- { this.enterTypingContext(); ! Node.thisExp = createSymbolExp(notNull(thisSymbol), definition.location()); for (init : initializers) typecheck(init); Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** overloadedsymbol.nice 7 Nov 2004 01:07:26 -0000 1.7 --- overloadedsymbol.nice 4 Dec 2004 19:38:18 -0000 1.8 *************** *** 35,44 **** private Expression uniqueExpression() { ! return new SymbolExp(symbols.get(0), this.location()); } private Expression uniqueExpression(VarSymbol sym, mlsub.typing.Polytype t) { ! SymbolExp res = new SymbolExp(sym, this.location()); res.type = t; return res; --- 35,44 ---- private Expression uniqueExpression() { ! return createSymbolExp(symbols.get(0), this.location()); } private Expression uniqueExpression(VarSymbol sym, mlsub.typing.Polytype t) { ! SymbolExp res = cast(createSymbolExp(sym, this.location())); res.type = t; return res; Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** tools.nice 1 Dec 2004 02:00:32 -0000 1.67 --- tools.nice 4 Dec 2004 19:38:18 -0000 1.68 *************** *** 36,40 **** localVariable(SymbolExp e) { ! let sym = e.getSymbol(); if (! (sym instanceof bossa.syntax.MonoSymbol)) return null; --- 36,40 ---- localVariable(SymbolExp e) { ! let sym = e.symbol; if (! (sym instanceof bossa.syntax.MonoSymbol)) return null; Index: new.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/new.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** new.nice 25 Nov 2004 19:28:18 -0000 1.7 --- new.nice 4 Dec 2004 19:38:18 -0000 1.8 *************** *** 80,84 **** JavaMethod method = JavaClasses.getObjectConstructor(); ! function = new SymbolExp(method.getSymbol(), ti.location()); } --- 80,84 ---- JavaMethod method = JavaClasses.getObjectConstructor(); ! function = createSymbolExp(method.getSymbol(), ti.location()); } --- NEW FILE: symbolexp.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** Access to a symbol (variable, function parameter). */ public class SymbolExp extends Expression { final VarSymbol symbol; isAssignable() = symbol.isAssignable(); getFieldAccessMethod() = symbol.getFieldAccessMethod(); checkSpecialRequirements(arguments) { symbol.checkSpecialRequirements(arguments); } computeType() { // Very important: each SymbolExp gets a copy of the type of the symbol. // Thus it has fresh binders. // Otherwise there would be an "aliasing" effect. // An important supposition is that two uses of a symbol // are two different SymbolExp objects // (with a reference to the same symbol). // So they hold different (but equivalent) types. type = symbol.getType().cloneType(); } compile() { try { return symbol.compile(); } catch(FieldAccess.UsingAsValue e) { throw User.error(this, "You must supply the object that contains this field"); } } generateCodeInCallPosition() { try { gnu.expr.Expression res = symbol.compileInCallPosition(); this.location().write(res); return res; } catch(FieldAccess.UsingAsValue e) { throw User.error(this, "You must supply the object that contains this field"); } } getDeclaration() { let decl = symbol.getDeclaration(); if(decl==null) Internal.error(this+" has no bytecode declaration"); return decl; } public LocatedString getName() { return symbol.name; } toString() = symbol.name.toQuotedString(); } Expression createSymbolExp(VarSymbol symbol, Location loc) { let res = new SymbolExp(symbol: symbol); res.setLocation(loc); return res; } /** Access to a symbol of a previous formal parameter. */ class ParameterAccessExp extends SymbolExp { override FormalParameters.Parameter.Symbol symbol; isAssignable() = false; compile () { return new gnu.expr.CopyArgument(this.symbol.copies); } } SymbolExp createParameterAccessExp(FormalParameters.Parameter.Symbol symbol, Location loc) { let res = new ParameterAccessExp(symbol: symbol); res.setLocation(loc); return res; } Index: call.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/call.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** call.nice 1 Dec 2004 02:00:32 -0000 1.5 --- call.nice 4 Dec 2004 19:38:18 -0000 1.6 *************** *** 224,228 **** { SymbolExp func = cast(function); ! Definition def = func.getSymbol().getDefinition(); if (def instanceof RetypedJavaMethod) --- 224,228 ---- { SymbolExp func = cast(function); ! Definition def = func.symbol.getDefinition(); if (def instanceof RetypedJavaMethod) Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** dispatch.java.bootstrap 26 Nov 2004 20:26:02 -0000 1.28 --- dispatch.java.bootstrap 4 Dec 2004 19:38:18 -0000 1.29 *************** *** 13,16 **** --- 13,19 ---- public class dispatch { + public static Expression createSymbolExp(VarSymbol symbol, bossa.util.Location loc) + { return null; } + public static Expression createCallExp(Expression function, Expression param1) { return null; } Index: FormalParameters.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FormalParameters.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** FormalParameters.java 21 Nov 2004 23:24:36 -0000 1.44 --- FormalParameters.java 4 Dec 2004 19:38:18 -0000 1.45 *************** *** 120,124 **** } ! private java.util.Stack copies; public void setDeclaration (gnu.expr.Declaration declaration, --- 120,124 ---- } ! java.util.Stack copies; public void setDeclaration (gnu.expr.Declaration declaration, *************** *** 130,148 **** private Symbol symbol; - - static class AccessExp extends SymbolExp - { - AccessExp (Symbol symbol, Location location) - { - super(symbol, location); - } - - public boolean isAssignable () { return false; } - - public gnu.expr.Expression compile () - { - return new gnu.expr.CopyArgument(((Symbol) this.getSymbol()).copies); - } - } } --- 130,133 ---- |