[Nice-commit] Nice/src/bossa/syntax tools.nice,1.104,1.105 scope.nice,1.4,1.5 VarScope.java,1.22,1.2
Brought to you by:
bonniot
|
From: Daniel B. <bo...@us...> - 2005-03-06 12:56:12
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24573/src/bossa/syntax Modified Files: tools.nice scope.nice VarScope.java Node.java Log Message: Added the nice.tools.visibility package. Use it for global scoping of (non-type) symbols. No functionality change yet. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** tools.nice 6 Mar 2005 01:34:26 -0000 1.104 --- tools.nice 6 Mar 2005 12:55:57 -0000 1.105 *************** *** 220,223 **** --- 220,226 ---- GlobalVarScope javaScope() = native Module.javaScope; + void addSymbol(VarScope, VarSymbol) = native void VarScope.addSymbol(Symbol); + void removeSymbol(VarScope, VarSymbol) = native void VarScope.removeSymbol(Symbol); + // Local Variables: // nice-xprogram: "../bin/nicec -d ../classes" Index: Node.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Node.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** Node.java 6 Mar 2005 01:34:26 -0000 1.68 --- Node.java 6 Mar 2005 12:55:57 -0000 1.69 *************** *** 171,176 **** this.typeScope = typeOuter; break; ! case down: ! this.scope = new VarScope(outer,varSymbols); this.typeScope = new TypeScope(typeOuter); break; --- 171,176 ---- this.typeScope = typeOuter; break; ! case down: ! this.scope = VarScope.create(outer, varSymbols); this.typeScope = new TypeScope(typeOuter); break; *************** *** 182,189 **** this.typeScope = typeOuter; break; ! case upper: if(outer==null) ! outer = new VarScope(null); outer.addSymbols(varSymbols); this.scope = outer; --- 182,189 ---- this.typeScope = typeOuter; break; ! case upper: if(outer==null) ! outer = VarScope.create(null); outer.addSymbols(varSymbols); this.scope = outer; Index: VarScope.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarScope.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** VarScope.java 6 Mar 2005 01:34:26 -0000 1.22 --- VarScope.java 6 Mar 2005 12:55:57 -0000 1.23 *************** *** 22,45 **** @author Daniel Bonniot (d.b...@ma...) */ ! public class VarScope { ! public VarScope(VarScope outer) ! { ! this.outer = outer; ! this.defs = new HashMultiTable(); ! } ! ! public VarScope(VarScope outer, ! Collection /* of VarSymbol */ defs) ! { ! this(outer); ! addSymbols(defs); ! } - void addSymbol(/*VarSymbol*/Symbol s) - { - this.defs.put(s.name,s); - } - /** Adds a collection of VarSymbols --- 22,29 ---- @author Daniel Bonniot (d.b...@ma...) */ ! public abstract class VarScope { ! abstract void addSymbol(/*VarSymbol*/Symbol s); /** Adds a collection of VarSymbols *************** *** 57,61 **** } } ! void removeSymbol(/*VarSymbol*/Symbol sym) { --- 41,81 ---- } } ! ! abstract void removeSymbol(/*VarSymbol*/Symbol sym); ! ! public abstract List lookup(LocatedString i); ! ! abstract List globalLookup(LocatedString i); ! ! static VarScope create(VarScope outer) ! { ! return new LocalVarScope(outer); ! } ! ! static VarScope create(VarScope outer, Collection /* of VarSymbol */ defs) ! { ! return new LocalVarScope(outer, defs); ! } ! } ! ! class LocalVarScope extends VarScope ! { ! public LocalVarScope(VarScope outer) ! { ! this.outer = outer; ! this.defs = new HashMultiTable(); ! } ! ! public LocalVarScope(VarScope outer, Collection /* of VarSymbol */ defs) ! { ! this(outer); ! addSymbols(defs); ! } ! ! void addSymbol(/*VarSymbol*/Symbol s) ! { ! this.defs.put(s.name,s); ! } ! void removeSymbol(/*VarSymbol*/Symbol sym) { Index: scope.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/scope.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** scope.nice 6 Mar 2005 01:34:26 -0000 1.4 --- scope.nice 6 Mar 2005 12:55:57 -0000 1.5 *************** *** 13,36 **** package bossa.syntax; /** The global scope of symbols. - */ public class GlobalVarScope extends VarScope { ! lookup(i) { // If there is any method by that name waiting, load it. ! loadJavaMethods(i.toString(), this); ! return super; } ! globalLookup(i) = this.lookup(i); } VarScope createGlobalVarScope() { ! return new GlobalVarScope(null); } --- 13,50 ---- package bossa.syntax; + import nice.tools.visibility; + /** The global scope of symbols. */ public class GlobalVarScope extends VarScope { ! private Scope<VarSymbol> impl = new Scope(name: "", parent: null); ! ! addSymbol(VarSymbol sym) = impl.add(sym.getName().toString(), sym); ! ! removeSymbol(VarSymbol sym) = impl.remove(sym.getName().toString(), sym); ! ! lookup(LocatedString name) { + let s = name.toString(); + // If there is any method by that name waiting, load it. ! loadJavaMethods(s, this); ! let res = impl[s]; ! ! if (res == null) ! return Collections.EMPTY_LIST; ! else ! return new LinkedList(res); } ! globalLookup(name) = this.lookup(name); } VarScope createGlobalVarScope() { ! return new GlobalVarScope(); } |