[Nice-commit] Nice/src/bossa/syntax fieldAccess.nice,NONE,1.1 Expression.java,1.57,1.58 NiceUtils.ja
Brought to you by:
bonniot
|
From: Arjan B. <ar...@us...> - 2005-01-01 16:36:42
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3659/F:/nice/src/bossa/syntax Modified Files: Expression.java NiceUtils.java VarSymbol.java call.nice increment.nice javaFieldAccess.nice nicefieldaccess.nice symbol.nice symbolexp.nice tools.nice typecheck.nice Added Files: fieldAccess.nice Removed Files: FieldAccess.java Log Message: Converted FieldAccess. --- FieldAccess.java DELETED --- Index: Expression.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Expression.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** Expression.java 5 Aug 2004 10:45:29 -0000 1.57 --- Expression.java 1 Jan 2005 16:36:31 -0000 1.58 *************** *** 59,63 **** * @return the FieldAccess behind this expression, or null */ ! FieldAccess getFieldAccessMethod() { return null; --- 59,63 ---- * @return the FieldAccess behind this expression, or null */ ! /*FieldAccess*/Object getFieldAccessMethod() { return null; *************** *** 69,73 **** value. Returns null otherwise. */ ! FieldAccess getField() { return null; --- 69,73 ---- value. Returns null otherwise. */ ! /*FieldAccess*/Object getField() { return null; Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** typecheck.nice 30 Dec 2004 20:58:37 -0000 1.119 --- typecheck.nice 1 Jan 2005 16:36:31 -0000 1.120 *************** *** 73,77 **** } ! ?FieldAccess field = to.getField(); String toName; if (field == null) --- 73,77 ---- } ! ?FieldAccess field = cast(to.getField()); String toName; if (field == null) Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** tools.nice 30 Dec 2004 18:49:01 -0000 1.86 --- tools.nice 1 Jan 2005 16:36:31 -0000 1.87 *************** *** 215,221 **** ?mlsub.typing.lowlevel.Kind getKind(mlsub.typing.lowlevel.Element) = native mlsub.typing.lowlevel.Kind mlsub.typing.lowlevel.Element.getKind(); ?gnu.expr.Declaration getDeclaration(Expression) = native gnu.expr.Declaration Expression.getDeclaration(); ! ?FieldAccess getFieldAccessMethod(Expression) = native FieldAccess Expression.getFieldAccessMethod(); ! ?FieldAccess getField(Expression) = native FieldAccess Expression.getField(); ! ?FieldAccess getFieldAccessMethod(VarSymbol) = native FieldAccess VarSymbol.getFieldAccessMethod(); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Polytype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Polytype, int); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Monotype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Monotype, int); --- 215,221 ---- ?mlsub.typing.lowlevel.Kind getKind(mlsub.typing.lowlevel.Element) = native mlsub.typing.lowlevel.Kind mlsub.typing.lowlevel.Element.getKind(); ?gnu.expr.Declaration getDeclaration(Expression) = native gnu.expr.Declaration Expression.getDeclaration(); ! ?Object getFieldAccessMethod(Expression) = native Object Expression.getFieldAccessMethod(); ! ?Object getField(Expression) = native Object Expression.getField(); ! ?Object getFieldAccessMethod(VarSymbol) = native Object VarSymbol.getFieldAccessMethod(); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Polytype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Polytype, int); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Monotype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Monotype, int); Index: NiceUtils.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NiceUtils.java 29 Dec 2004 20:22:27 -0000 1.4 --- NiceUtils.java 1 Jan 2005 16:36:31 -0000 1.5 *************** *** 15,18 **** --- 15,23 ---- public final class NiceUtils { + public static gnu.expr.Expression doInline(gnu.mapping.Procedure1 proc) + { + return nice.tools.code.Inline.inline(proc); + } + public static gnu.expr.Expression doInline(gnu.mapping.Procedure1 proc, gnu.expr.Expression arg1) { --- NEW FILE: fieldAccess.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.*; /** A field access. In terms of scoping, this is the symbol that is returned when the access to a field is done, either a 'get' or a 'set'. */ abstract class FieldAccess extends MethodDeclaration { ?gnu.expr.Declaration fieldDecl = null; /** * true if this method represent the access to the field of an object. */ isFieldAccess() = true; public boolean isFinal(); public boolean isStatic() = false; computeCode() { throw new UsingFieldAsValue(); } public gnu.expr.Expression compileAccess(gnu.expr.Expression[] arguments) { if (arguments.length == 0) return NiceUtils.doInline(new nice.tools.code.GetFieldProc(fieldDecl)); else return NiceUtils.doInline(new nice.tools.code.GetFieldProc(fieldDecl), arguments[0]); } public gnu.expr.Expression compileAssign(gnu.expr.Expression value) { return NiceUtils.doInline( new nice.tools.code.SetStaticFieldProc(fieldDecl), value); } public gnu.expr.Expression compileAssign(gnu.expr.Expression parameter, gnu.expr.Expression value) { return NiceUtils.doInline( new nice.tools.code.SetFieldProc(fieldDecl), parameter, value); } } class UsingFieldAsValue extends Error {} Index: symbolexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbolexp.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** symbolexp.nice 4 Dec 2004 19:38:18 -0000 1.1 --- symbolexp.nice 1 Jan 2005 16:36:31 -0000 1.2 *************** *** 49,53 **** return symbol.compile(); } ! catch(FieldAccess.UsingAsValue e) { throw User.error(this, "You must supply the object that contains this field"); --- 49,53 ---- return symbol.compile(); } ! catch(UsingFieldAsValue e) { throw User.error(this, "You must supply the object that contains this field"); *************** *** 62,66 **** return res; } ! catch(FieldAccess.UsingAsValue e) { throw User.error(this, "You must supply the object that contains this field"); --- 62,66 ---- return res; } ! catch(UsingFieldAsValue e) { throw User.error(this, "You must supply the object that contains this field"); Index: symbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbol.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** symbol.nice 15 Dec 2004 03:45:59 -0000 1.2 --- symbol.nice 1 Jan 2005 16:36:31 -0000 1.3 *************** *** 239,240 **** --- 239,253 ---- LocatedString name, mlsub.typing.Polytype type ) = new ConstructorCallSymbol(declaration,name,type); + + + boolean isNonStaticFieldAccess(VarSymbol sym) + { + FieldAccess access = cast(sym.getFieldAccessMethod()); + return access != null && ! access.isStatic(); + } + + boolean isStaticFieldAccess(VarSymbol sym) + { + FieldAccess access = cast(sym.getFieldAccessMethod()); + return access != null && access.isStatic(); + } Index: javaFieldAccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/javaFieldAccess.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** javaFieldAccess.nice 23 Dec 2004 15:22:05 -0000 1.2 --- javaFieldAccess.nice 1 Jan 2005 16:36:31 -0000 1.3 *************** *** 107,118 **** } ! new JavaFieldAccess(LocatedString className,String fieldName, LocatedString name,Constraint cst, Monotype returnType, FormalParameters parameters) { ! this(name, cst, parameters, returnType, className : className, fieldName : fieldName ); } new JavaFieldAccess(gnu.bytecode.Field field, mlsub.typing.Monotype[?] parameters) --- 107,119 ---- } ! JavaFieldAccess createJavaFieldAccess(LocatedString className,String fieldName, LocatedString name,Constraint cst, Monotype returnType, FormalParameters parameters) { ! return new JavaFieldAccess(name, cst, returnType, parameters, className : className, fieldName : fieldName ); } + new JavaFieldAccess(gnu.bytecode.Field field, mlsub.typing.Monotype[?] parameters) Index: nicefieldaccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefieldaccess.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nicefieldaccess.nice 25 Nov 2004 19:28:18 -0000 1.2 --- nicefieldaccess.nice 1 Jan 2005 16:36:31 -0000 1.3 *************** *** 48,53 **** return new NiceFieldAccess(field.getName(), Constraint.create(classDef.getBinders()), new FormalParameters([new FormalParameters.Parameter(Monotype.create(argType))]), ! field.sym.syntacticType, field: field); } --- 48,54 ---- return new NiceFieldAccess(field.getName(), Constraint.create(classDef.getBinders()), + field.sym.syntacticType, new FormalParameters([new FormalParameters.Parameter(Monotype.create(argType))]), ! field: field); } Index: VarSymbol.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarSymbol.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** VarSymbol.java 21 Nov 2004 23:24:37 -0000 1.38 --- VarSymbol.java 1 Jan 2005 16:36:31 -0000 1.39 *************** *** 49,65 **** } ! final boolean isNonStaticFieldAccess() ! { ! FieldAccess access = getFieldAccessMethod(); ! return access != null && ! access.isStatic(); ! } ! ! final boolean isStaticFieldAccess() ! { ! FieldAccess access = getFieldAccessMethod(); ! return access != null && access.isStatic(); ! } ! ! FieldAccess getFieldAccessMethod() { return null; --- 49,53 ---- } ! Object getFieldAccessMethod() { return null; Index: increment.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/increment.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** increment.nice 13 Oct 2004 23:22:22 -0000 1.3 --- increment.nice 1 Jan 2005 16:36:31 -0000 1.4 *************** *** 48,52 **** CallExp call = cast(variable); ! let access = call.function.getFieldAccessMethod(); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + --- 48,52 ---- CallExp call = cast(variable); ! let ?FieldAccess access = cast(call.function.getFieldAccessMethod()); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + Index: call.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/call.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** call.nice 4 Dec 2004 19:38:18 -0000 1.6 --- call.nice 1 Jan 2005 16:36:31 -0000 1.7 *************** *** 111,115 **** { this.resolveOverloading(); ! let ?FieldAccess fa = function.getFieldAccessMethod(); return fa != null && ! fa.isFinal(); } --- 111,115 ---- { this.resolveOverloading(); ! let ?FieldAccess fa = cast(function.getFieldAccessMethod()); return fa != null && ! fa.isFinal(); } *************** *** 156,160 **** gnu.expr.Expression res; if (function.isFieldAccess()) ! res = notNull(function.getFieldAccessMethod()).compileAccess(this.compileParams()); else res = new gnu.expr.ApplyExp(function.generateCodeInCallPosition(), this.compileParams()); --- 156,160 ---- gnu.expr.Expression res; if (function.isFieldAccess()) ! res = cast(function.getFieldAccessMethod()).compileAccess(this.compileParams()); else res = new gnu.expr.ApplyExp(function.generateCodeInCallPosition(), this.compileParams()); *************** *** 198,202 **** Internal.error(this, "Assignment to a call that is not a field access"); ! FieldAccess access = notNull(function.getFieldAccessMethod()); if (access.isFinal()) --- 198,202 ---- Internal.error(this, "Assignment to a call that is not a field access"); ! FieldAccess access = cast(function.getFieldAccessMethod()); if (access.isFinal()) |