Nice/src/bossa/syntax visibility.nice,NONE,1.1 scope.nice,1.6,1.7 globalvar.nice,1.7,1.8 VarScope.java,1.24,1.25
Daniel Bonniot <[email protected]> Sat, 12 Mar 2005 02:41:49 +0000
| Newsgroups | gmane.comp.lang.nice.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5589/src/bossa/syntax Modified Files: scope.nice globalvar.nice VarScope.java Added Files: visibility.nice Log Message: Implemented visibility for toplevel variables and values. --- NEW FILE: visibility.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2005 */ /* */ /* 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 nice.tools.visibility; /** Utilities to manipulate visibilities. @author Daniel Bonniot ([email protected]) */ Visibility visibility(boolean pub, boolean priv) = pub ? general : priv ? intimate: familial; Index: globalvar.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/globalvar.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** globalvar.nice 6 Mar 2005 01:34:26 -0000 1.7 --- globalvar.nice 12 Mar 2005 02:41:47 -0000 1.8 *************** *** 24,30 **** --- 24,34 ---- Expression value; boolean constant; + Visibility visibility; resolve() { + left.typeScope = this.compilation.globalTypeScope; + left.resolve(); + value = analyse(value, notNull(scope), notNull(typeScope)); } *************** *** 44,50 **** } printInterface(s) { ! s.print((constant? "let ": "var ") +left +" = " +value.toString() +";\n"); } --- 48,59 ---- } + String modifier(Visibility); + modifier(intimate) = "private "; + modifier(familial) = ""; + modifier(general) = "public "; + printInterface(s) { ! s.print(this.modifier(visibility) + (constant? "let ": "var ") +left +" = " +value.toString() +";\n"); } *************** *** 62,66 **** { GlobalVarDeclaration definition; ! isAssignable() = ! definition.constant; --- 71,75 ---- { GlobalVarDeclaration definition; ! isAssignable() = ! definition.constant; *************** *** 92,102 **** } ! public GlobalVarDeclaration createGlobalVarDeclaration(LocatedString name, ! Monotype type, Expression value, boolean constant) { ! let res = new GlobalVarDeclaration(name, Node.global, left: cast(null), ! value: value, constant: constant); res.left = new GlobalVarSymbol(name, syntacticType: type, definition: res); ! res.addChild(res.left); return res; } --- 101,113 ---- } ! public GlobalVarDeclaration createGlobalVarDeclaration ! (LocatedString name, ! Monotype type, Expression value, boolean constant, Visibility vis) { ! let res = new GlobalVarDeclaration ! (name, Node.global, left: cast(null), value: value, constant: constant, ! visibility: vis); res.left = new GlobalVarSymbol(name, syntacticType: type, definition: res); ! res.module.scope.addSymbol(res.left, vis); return res; } Index: VarScope.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarScope.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** VarScope.java 6 Mar 2005 13:59:30 -0000 1.24 --- VarScope.java 12 Mar 2005 02:41:47 -0000 1.25 *************** *** 26,29 **** --- 26,34 ---- abstract void addSymbol(/*VarSymbol*/Symbol s); + void addSymbol(/*VarSymbol*/Symbol s, nice.tools.visibility.Visibility v) + { + this.addSymbol(s); + } + /** Adds a collection of VarSymbols Index: scope.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/scope.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** scope.nice 11 Mar 2005 17:35:52 -0000 1.6 --- scope.nice 12 Mar 2005 02:41:47 -0000 1.7 *************** *** 22,27 **** private Scope<VarSymbol> impl = new Scope(name: "", parent: null); ! addSymbol(VarSymbol sym) = ! impl.add(sym.getName().toString(), sym, visibility: general); removeSymbol(VarSymbol sym) = impl.remove(sym.getName().toString(), sym); --- 22,29 ---- private Scope<VarSymbol> impl = new Scope(name: "", parent: null); ! addSymbol(VarSymbol sym) = this.addSymbol(sym, general); ! ! addSymbol(VarSymbol sym, Visibility vis) = ! impl.add(sym.getName().toString(), sym, vis); removeSymbol(VarSymbol sym) = impl.remove(sym.getName().toString(), sym); ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click