Nice/src/bossa/syntax typedef.nice,1.20,1.21 tools.nice,1.106,1.107 scope.nice,1.5,1.6 retypedMethod.nice,1.8,1.9 overloadedsymbol.nice,1.15,1.16 methodbody.nice,1.13,1.14 javaclass.nice,1.7,1.8 javaMethod.nice,1.9,1.10 dispatch.java.bootstrap,1.54,1.55 Node.java,1.69,1.70 Module.java,1.25,1.26
Daniel Bonniot <[email protected]>
| 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-serv23334/src/bossa/syntax
Modified Files:
typedef.nice tools.nice scope.nice retypedMethod.nice
overloadedsymbol.nice methodbody.nice javaclass.nice
javaMethod.nice dispatch.java.bootstrap Node.java Module.java
Log Message:
Each module (and package) now has its own Scope.
All symbols are still public, but only visible to packages that import their
englobing package.
Index: dispatch.java.bootstrap
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** dispatch.java.bootstrap 6 Mar 2005 01:34:26 -0000 1.54
--- dispatch.java.bootstrap 11 Mar 2005 17:35:52 -0000 1.55
***************
*** 28,32 ****
public static void resetJavaClasses() {}
! public static VarScope createGlobalVarScope()
{ return null; }
--- 28,32 ----
public static void resetJavaClasses() {}
! public static VarScope createGlobalVarScope(int dummy, nice.tools.visibility.Scope scope)
{ return null; }
Index: methodbody.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodbody.nice,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** methodbody.nice 6 Mar 2005 01:34:26 -0000 1.13
--- methodbody.nice 11 Mar 2005 17:35:52 -0000 1.14
***************
*** 255,259 ****
resolvePatterns(notNull(typeScope), module.scope, formals);
! symbols = notNull(scope).lookup(name);
}
--- 255,259 ----
resolvePatterns(notNull(typeScope), module.scope, formals);
! symbols = module.scope.lookup(name);
}
Index: scope.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/scope.nice,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** scope.nice 6 Mar 2005 12:55:57 -0000 1.5
--- scope.nice 11 Mar 2005 17:35:52 -0000 1.6
***************
*** 22,26 ****
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);
--- 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);
***************
*** 31,42 ****
// 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);
}
--- 32,40 ----
// If there is any method by that name waiting, load it.
! loadJavaMethods(s);
! // Return all visible symbols with the given name, without preference
! // for those in the current module or package.
! return impl.getFlat(s);
}
***************
*** 49,52 ****
--- 47,55 ----
}
+ VarScope createGlobalVarScope(int, Scope<VarSymbol> scope)
+ {
+ return new GlobalVarScope(impl: scope);
+ }
+
/**
The global, toplevel type scope.
***************
*** 129,133 ****
return res;
! return cast(lookupJavaClass(notNull(name), loc, Module.javaScope));
}
}
--- 132,136 ----
return res;
! return cast(lookupJavaClass(notNull(name), loc));
}
}
Index: overloadedsymbol.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** overloadedsymbol.nice 17 Jan 2005 13:16:57 -0000 1.15
--- overloadedsymbol.nice 11 Mar 2005 17:35:52 -0000 1.16
***************
*** 456,460 ****
}
! List<VarSymbol> removeNonMinimal(List<VarSymbol> symbols)
{
List<VarSymbol> removed = new ArrayList();
--- 456,460 ----
}
! List<VarSymbol> removeNonMinimal(Collection<VarSymbol> symbols)
{
List<VarSymbol> removed = new ArrayList();
Index: retypedMethod.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/retypedMethod.nice,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** retypedMethod.nice 6 Mar 2005 01:34:26 -0000 1.8
--- retypedMethod.nice 11 Mar 2005 17:35:52 -0000 1.9
***************
*** 291,295 ****
private void removeFromScope(MethodDeclaration m)
{
! Module.javaScope.removeSymbol(m.getSymbol());
unregisterDispatchTest(m);
}
--- 291,296 ----
private void removeFromScope(MethodDeclaration m)
{
! let sym = m.getSymbol();
! Node.compilation.javaScope.remove(sym.getName().toString(), sym);
unregisterDispatchTest(m);
}
Index: typedef.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** typedef.nice 6 Mar 2005 01:34:26 -0000 1.20
--- typedef.nice 11 Mar 2005 17:35:51 -0000 1.21
***************
*** 56,59 ****
--- 56,68 ----
this.createTC();
+ // Add the symbol immediately, to make sure another one is not created
+ // for the same (bytecode) class.
+ try {
+ Node.getGlobalTypeScope().addSymbol(tc);
+ }
+ catch(TypeScope.DuplicateName e){
+ User.error(this.location(), e.getMessage());
+ }
+
typeParametersVariances = null;
***************
*** 131,135 ****
tcToTypeDef.put(tc, this);
mlsub.typing.Typing.introduce(tc);
- this.addTypeSymbol(tc);
}
--- 140,143 ----
Index: javaMethod.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/javaMethod.nice,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** javaMethod.nice 6 Mar 2005 01:34:26 -0000 1.9
--- javaMethod.nice 11 Mar 2005 17:35:52 -0000 1.10
***************
*** 208,212 ****
* to make them available to the nice code.
*/
! void fetchMethods(mlsub.typing.TypeConstructor tc, gnu.bytecode.ClassType classType, VarScope scope)
{
try {
--- 208,212 ----
* to make them available to the nice code.
*/
! void fetchMethods(mlsub.typing.TypeConstructor tc, gnu.bytecode.ClassType classType)
{
try {
***************
*** 215,219 ****
for (?gnu.bytecode.Field f = classType.getFields(); f != null; f = f.getNext())
if (retyped.get(f) == null)
! addJavaSymbol(f, makeJavaFieldAccess(f), scope);
for (?gnu.bytecode.Method m = classType.getMethods(); m != null; m = m.getNext())
--- 215,219 ----
for (?gnu.bytecode.Field f = classType.getFields(); f != null; f = f.getNext())
if (retyped.get(f) == null)
! addJavaSymbol(f, makeJavaFieldAccess(f));
for (?gnu.bytecode.Method m = classType.getMethods(); m != null; m = m.getNext())
***************
*** 301,305 ****
/** Called when the given name is going to be needed. */
! void loadJavaMethods(String name, VarScope scope)
{
?List<gnu.bytecode.Method> methods = knownMethods.get(name);
--- 301,305 ----
/** Called when the given name is going to be needed. */
! void loadJavaMethods(String name)
{
?List<gnu.bytecode.Method> methods = knownMethods.get(name);
***************
*** 316,329 ****
continue;
! addJavaSymbol(m, makeJavaMethod(m, false), scope);
}
}
! void addJavaSymbol(gnu.bytecode.AttrContainer m, ?MethodDeclaration def, VarScope scope)
{
if (def == null)
return;
! scope.addSymbol(def.getSymbol());
retyped.put(m, def);
}
--- 316,330 ----
continue;
! addJavaSymbol(m, makeJavaMethod(m, false));
}
}
! void addJavaSymbol(gnu.bytecode.AttrContainer m, ?MethodDeclaration def)
{
if (def == null)
return;
! Node.compilation.javaScope.add
! (def.getName().toString(), def.getSymbol(), visibility: general);
retyped.put(m, def);
}
Index: javaclass.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/javaclass.nice,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** javaclass.nice 6 Mar 2005 01:34:26 -0000 1.7
--- javaclass.nice 11 Mar 2005 17:35:52 -0000 1.8
***************
*** 59,63 ****
let old = setTypeConstructorForJavaClass
! (definition.compilation(), definition.getTC(), classType);
if (old != null)
--- 59,63 ----
let old = setTypeConstructorForJavaClass
! (definition.getTC(), classType, definition.compilation());
if (old != null)
***************
*** 72,76 ****
return;
! fetchMethods(definition.getTC(), cast(definition.getJavaType()), Module.javaScope);
}
--- 72,76 ----
return;
! fetchMethods(definition.getTC(), cast(definition.getJavaType()));
}
***************
*** 86,90 ****
*/
?mlsub.typing.TypeConstructor setTypeConstructorForJavaClass
! (bossa.modules.Compilation compilation, mlsub.typing.TypeConstructor tc, gnu.bytecode.Type type) =
compilation.javaTypeConstructors.put(type, tc);
--- 86,91 ----
*/
?mlsub.typing.TypeConstructor setTypeConstructorForJavaClass
! (mlsub.typing.TypeConstructor tc, gnu.bytecode.Type type,
! bossa.modules.Compilation compilation) =
compilation.javaTypeConstructors.put(type, tc);
***************
*** 115,120 ****
mlsub.typing.TypeConstructor createJavaType
! (bossa.modules.Compilation compilation, String className,
! gnu.bytecode.Type javaType, VarScope scope)
{
if (bossa.util.Debug.javaTypes)
--- 116,122 ----
mlsub.typing.TypeConstructor createJavaType
! (String className,
! gnu.bytecode.Type javaType,
! bossa.modules.Compilation compilation)
{
if (bossa.util.Debug.javaTypes)
***************
*** 208,212 ****
if (javaType instanceof gnu.bytecode.ClassType)
! fetchMethods(res, javaType, scope);
return res;
--- 210,214 ----
if (javaType instanceof gnu.bytecode.ClassType)
! fetchMethods(res, javaType);
return res;
***************
*** 235,240 ****
}
! ?mlsub.typing.TypeConstructor lookupJavaClass(String className, ?Location loc,
! VarScope scope)
{
let classType = nice.tools.code.TypeImport.lookup(className, loc);
--- 237,241 ----
}
! ?mlsub.typing.TypeConstructor lookupJavaClass(String className, ?Location loc)
{
let classType = nice.tools.code.TypeImport.lookup(className, loc);
***************
*** 248,251 ****
return compilation.javaTypeConstructors.get(classType);
! return createJavaType(compilation, classType.getName(), classType, scope);
}
--- 249,252 ----
return compilation.javaTypeConstructors.get(classType);
! return createJavaType(classType.getName(), classType, compilation);
}
Index: tools.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v
retrieving revision 1.106
retrieving revision 1.107
diff -C2 -d -r1.106 -r1.107
*** tools.nice 8 Mar 2005 19:33:19 -0000 1.106
--- tools.nice 11 Mar 2005 17:35:52 -0000 1.107
***************
*** 164,167 ****
--- 164,168 ----
native mlsub.typing.Polytype Expression.getType();
GlobalTypeScope getGlobalTypeScope() = native GlobalTypeScope Node.getGlobalTypeScope();
+ bossa.modules.Compilation compilation() = native Node.compilation;
<T> String map(String, String, String, T[]) = native String bossa.util.Util.map(String, String, String, Object[]);
<T> String map(String, String, String, ?Collection<T>) = native String bossa.util.Util.map(String, String, String, Collection);
***************
*** 189,192 ****
--- 190,194 ----
List<VarSymbol> globalLookup(VarScope, LocatedString) = native List VarScope.globalLookup(LocatedString);
Map<gnu.bytecode.Type,mlsub.typing.TypeConstructor> javaTypeConstructors(bossa.modules.Compilation ) = native bossa.modules.Compilation.javaTypeConstructors;
+ Scope<VarSymbol> javaScope(bossa.modules.Compilation) = native bossa.modules.Compilation.javaScope;
?LocatedString name(Symbol) = native Symbol.name;
?mlsub.typing.TypeConstructor associatedTC(mlsub.typing.Interface) = native mlsub.typing.TypeConstructor mlsub.typing.Interface.associatedTC();
***************
*** 219,223 ****
gnu.expr.QuoteExp QuoteExp_undefined_exp() = native gnu.expr.QuoteExp.undefined_exp;
GlobalVarScope scope(Module) = native Module.scope;
- GlobalVarScope javaScope() = native Module.javaScope;
void addSymbol(VarScope, VarSymbol) = native void VarScope.addSymbol(Symbol);
--- 221,224 ----
Index: Node.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Node.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -C2 -d -r1.69 -r1.70
*** Node.java 6 Mar 2005 12:55:57 -0000 1.69
--- Node.java 11 Mar 2005 17:35:52 -0000 1.70
***************
*** 118,135 ****
*/
- private static TypeScope globalTypeScope;
public static final TypeScope getGlobalTypeScope()
{
! return globalTypeScope;
}
public static final bossa.modules.Package getGlobalTypeScopeModule()
{
! return globalTypeScope.getPackage();
}
public static mlsub.typing.TypeConstructor globalTypeScopeLookup(String name, Location loc)
{
! return globalTypeScope.globalLookup(name, loc);
}
--- 118,134 ----
*/
public static final TypeScope getGlobalTypeScope()
{
! return compilation.globalTypeScope;
}
public static final bossa.modules.Package getGlobalTypeScopeModule()
{
! return compilation.globalTypeScope.getPackage();
}
public static mlsub.typing.TypeConstructor globalTypeScopeLookup(String name, Location loc)
{
! return compilation.globalTypeScope.globalLookup(name, loc);
}
***************
*** 143,149 ****
{
compilation = pkg.getCompilation();
! globalTypeScope = dispatch.createGlobalTypeScope();
}
! globalTypeScope.setPackage(pkg);
}
--- 142,149 ----
{
compilation = pkg.getCompilation();
! if (compilation.globalTypeScope == null)
! compilation.globalTypeScope = dispatch.createGlobalTypeScope();
}
! compilation.globalTypeScope.setPackage(pkg);
}
***************
*** 151,155 ****
{
setPackage(pkg);
! buildScope(null, globalTypeScope);
}
--- 151,155 ----
{
setPackage(pkg);
! buildScope(null, compilation.globalTypeScope);
}
***************
*** 179,183 ****
this.scope = outer;
this.scope.addSymbols(varSymbols);
! typeOuter = globalTypeScope;
this.typeScope = typeOuter;
break;
--- 179,183 ----
this.scope = outer;
this.scope.addSymbols(varSymbols);
! typeOuter = compilation.globalTypeScope;
this.typeScope = typeOuter;
break;
***************
*** 305,309 ****
}
catch(UserError ex){
! globalTypeScope.getPackage().getCompilation().error(ex);
}
}
--- 305,309 ----
}
catch(UserError ex){
! compilation.globalTypeScope.getPackage().getCompilation().error(ex);
}
}
Index: Module.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Module.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** Module.java 6 Mar 2005 01:34:26 -0000 1.25
--- Module.java 11 Mar 2005 17:35:52 -0000 1.26
***************
*** 25,37 ****
String name;
! static VarScope javaScope;
!
! public Module(bossa.modules.Package pkg, String name, VarScope scope)
{
this.pkg = pkg;
this.name = name;
! this.scope = scope;
!
! javaScope = scope;
}
--- 25,34 ----
String name;
! public Module(bossa.modules.Package pkg, String name,
! nice.tools.visibility.Scope scope)
{
this.pkg = pkg;
this.name = name;
! this.scope = dispatch.createGlobalVarScope(0, scope);
}
-------------------------------------------------------
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