[Nice-commit] Nice/src/bossa/syntax defaultconstructor.nice,1.1,1.2 niceclass.nice,1.1,1.2 nicefield
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-11-05 22:47:08
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23623/F:/nice/src/bossa/syntax Modified Files: defaultconstructor.nice niceclass.nice nicefield.nice tools.nice Log Message: Minor cleanup. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** tools.nice 5 Nov 2004 14:57:57 -0000 1.55 --- tools.nice 5 Nov 2004 22:46:55 -0000 1.56 *************** *** 29,36 **** { ?LocatedString f = identString(e.function); ! if (f == null) ! return false; ! else ! return f.toString().equals(name); } --- 29,33 ---- { ?LocatedString f = identString(e.function); ! return (f != null) && f.toString().equals(name); } *************** *** 40,58 **** { let sym = e.getSymbol(); ! if (sym instanceof bossa.syntax.MonoSymbol) { ! //don't allow nullness inference on global variables. ! if (sym instanceof GlobalVarDeclaration.GlobalVarSymbol && ! sym.isAssignable()) ! return null; ! // no type inference on captured variables ! if (sym.captured) ! return null; ! return sym; ! } ! return null; } ! localVariable(AssignExp e) = localVariable(notNull(e.to)); mlsub.typing.Monotype makeSure(mlsub.typing.Monotype m) = --- 37,54 ---- { let sym = e.getSymbol(); ! if (! (sym instanceof bossa.syntax.MonoSymbol)) ! return null; ! //don't allow nullness inference on global variables. ! if (sym instanceof GlobalVarDeclaration.GlobalVarSymbol && sym.isAssignable()) ! return null; ! // no type inference on captured variables ! if (sym.captured) ! return null; ! ! return sym; } ! localVariable(AssignExp e) = localVariable(e.to); mlsub.typing.Monotype makeSure(mlsub.typing.Monotype m) = *************** *** 100,105 **** return null; ! ?MonoSymbol sym = localVariable(condition.arguments.getExp(0)); ! if (sym == null) return null; --- 96,100 ---- return null; ! let sym = localVariable(condition.arguments.getExp(0)); if (sym == null) return null; *************** *** 109,126 **** return null; ! TypeConstantExp type = cast(arg2); ! if (type.getTC() == null) return null; - TypeConstructor tc = notNull(type.getTC()); - if (tc == PrimitiveType.arrayTC) ! return (sym, notNull(type.representedType)); ! mlsub.typing.Monotype[?] parameters; ! if (tc.arity() == 0) ! parameters = null; ! else { let originalType = nice.tools.typing.Types.rawType(sym.getMonotype()); --- 104,117 ---- return null; ! ?TypeConstructor tc = arg2.getTC(); ! if (tc == null) return null; if (tc == PrimitiveType.arrayTC) ! return (sym, notNull(arg2.representedType)); ! mlsub.typing.Monotype[?] parameters = null; ! if (tc.arity() != 0) { let originalType = nice.tools.typing.Types.rawType(sym.getMonotype()); *************** *** 175,182 **** missingThisError(); - Location loc = ident.location(); call.function = createOverloadedSymbolExp(new ArrayList(cast(classe).getConstructorCallSymbols()), FormalParameters.thisName); ! notNull(call.function).setLocation(loc); } --- 166,172 ---- missingThisError(); call.function = createOverloadedSymbolExp(new ArrayList(cast(classe).getConstructorCallSymbols()), FormalParameters.thisName); ! call.function.setLocation(ident.location()); } Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** niceclass.nice 5 Nov 2004 14:57:57 -0000 1.1 --- niceclass.nice 5 Nov 2004 22:46:55 -0000 1.2 *************** *** 55,59 **** */ classe = notNull(definition.module).getClassExp(this); - } --- 55,58 ---- Index: nicefield.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefield.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** nicefield.nice 5 Nov 2004 14:57:57 -0000 1.1 --- nicefield.nice 5 Nov 2004 22:46:55 -0000 1.2 *************** *** 11,14 **** --- 11,18 ---- /**************************************************************************/ + package bossa.syntax; + + import bossa.util.*; + /** A field or field override in a Nice class. *************** *** 42,46 **** bossa.util.User.error(sym, "A field cannot have void type"); ! value = dispatch.analyse(value, scope, typeScope); } --- 46,51 ---- bossa.util.User.error(sym, "A field cannot have void type"); ! if (value != null) ! value = analyse(notNull(value), scope, typeScope); } *************** *** 62,66 **** mlsub.typing.Polytype declaredType = sym.getType(); value = notNull(value).resolveOverloading(declaredType); ! dispatch.typecheck(notNull(value)); try { --- 67,71 ---- mlsub.typing.Polytype declaredType = sym.getType(); value = notNull(value).resolveOverloading(declaredType); ! typecheck(notNull(value)); try { *************** *** 148,152 **** final class OverridenField extends NiceField { - isFinal() = true; --- 153,156 ---- Index: defaultconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/defaultconstructor.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** defaultconstructor.nice 5 Nov 2004 14:57:57 -0000 1.1 --- defaultconstructor.nice 5 Nov 2004 22:46:55 -0000 1.2 *************** *** 56,59 **** --- 56,62 ---- computeCode() { + if (classe.getDefinition().inInterfaceFile()) + throw new Error("Constructors are loaded from the compiled package"); + this.createBytecode(true); this.createBytecode(false); *************** *** 92,100 **** return; ! gnu.bytecode.Type[] argTypesArray = argTypes.toArray(); ! MonoSymbol[] argsArray = args.toArray(); ! ! if (classe.getDefinition().inInterfaceFile()) ! throw new Error("Constructors are loaded from the compiled package"); let lambda = nice.tools.code.Gen.createConstructor --- 95,100 ---- return; ! let argTypesArray = argTypes.toArray(); ! let argsArray = args.toArray(); let lambda = nice.tools.code.Gen.createConstructor *************** *** 105,126 **** classe.getClassExp().addMethod(lambda); - // Add attributes useful for the nice compiler. These are not needed - // for the version omitting defaults, since that one is only there for - // Java users' sake. if (! omitDefaults) { lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); lambda.addBytecodeAttribute(new gnu.bytecode.MiscAttr("default")); } - - if (omitDefaults) - { - initializeOmitDefaults = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda)); - } else { ! initialize = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda)); ! initializeFromConstructor = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda, true)); ! instantiate = new gnu.expr.QuoteExp(new gnu.expr.InstantiateProc(lambda)); } } --- 105,123 ---- classe.getClassExp().addMethod(lambda); if (! omitDefaults) { + initialize = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda)); + initializeFromConstructor = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda, true)); + instantiate = new gnu.expr.QuoteExp(new gnu.expr.InstantiateProc(lambda)); + + // Add attributes useful for the nice compiler. These are not needed + // for the version omitting defaults, since that one is only there for + // Java users' sake. lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); lambda.addBytecodeAttribute(new gnu.bytecode.MiscAttr("default")); } else { ! initializeOmitDefaults = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda)); } } |