[Nice-commit] Nice/src/bossa/syntax EnumDefinition.java,1.14,1.15 LocatedString.java,1.18,1.19 analy
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-10-13 23:22:35
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7665/F:/nice/src/bossa/syntax Modified Files: EnumDefinition.java LocatedString.java analyse.nice assign.nice call.nice constant.nice increment.nice locals.nice new.nice overloadedsymbol.nice pattern.nice super.nice tools.nice typecheck.nice Log Message: Cleanup of nullness issues. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** analyse.nice 7 Oct 2004 22:03:44 -0000 1.112 --- analyse.nice 13 Oct 2004 23:22:22 -0000 1.113 *************** *** 534,538 **** { CallExp res = new CallExp(function: createOverloadedSymbolExp(symbols, notNull(e.ident)), ! arguments: new Arguments([new Arguments.Argument(Node.thisExp)])); res.setLocation(e.location()); return res; --- 534,538 ---- { CallExp res = new CallExp(function: createOverloadedSymbolExp(symbols, notNull(e.ident)), ! arguments: Arguments.singleArgument(Node.thisExp)); res.setLocation(e.location()); return res; Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pattern.nice 9 Oct 2004 09:28:41 -0000 1.6 --- pattern.nice 13 Oct 2004 23:22:22 -0000 1.7 *************** *** 603,612 **** if (name[0] == '-') ! return createPattern(ConstantExp.makeNumber(new LocatedString(name, ! loc))); if (name[0] == '+') ! return createPattern(ConstantExp.makeNumber(new LocatedString( ! name.substring(1), loc))); if (name[0] == '\"') --- 603,610 ---- if (name[0] == '-') ! return createPattern(ConstantExp.makeNumber(new LocatedString(name))); if (name[0] == '+') ! return createPattern(ConstantExp.makeNumber(new LocatedString(name.substring(1)))); if (name[0] == '\"') *************** *** 618,630 **** let prefix = name.substring(0, (name[1] == '=') ? 2 : 1); return createPattern(prefix, null, ConstantExp.makeNumber( ! new LocatedString(name.substring(prefix.length()), loc)), null, loc); } if (name[0] == '=') ! return resolveGlobalConstants(new VariablePattern(new LocatedString(name.substring(1), loc), loc)); } if (name.equals("_")) ! return createPattern(new LocatedString("_", loc)); if (name.equals("NONNULL")) --- 616,628 ---- let prefix = name.substring(0, (name[1] == '=') ? 2 : 1); return createPattern(prefix, null, ConstantExp.makeNumber( ! new LocatedString(name.substring(prefix.length()))), null, loc); } if (name[0] == '=') ! return resolveGlobalConstants(new VariablePattern(new LocatedString(name.substring(1)), loc)); } if (name.equals("_")) ! return createPattern(new LocatedString("_")); if (name.equals("NONNULL")) Index: LocatedString.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/LocatedString.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** LocatedString.java 29 May 2003 14:17:18 -0000 1.18 --- LocatedString.java 13 Oct 2004 23:22:22 -0000 1.19 *************** *** 29,32 **** --- 29,37 ---- } + public LocatedString(String content) + { + this(content, Location.nowhere(), false); + } + /** * @param content the underlying raw string Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** typecheck.nice 7 Oct 2004 22:03:44 -0000 1.116 --- typecheck.nice 13 Oct 2004 23:22:22 -0000 1.117 *************** *** 1058,1062 **** try { Typing.enter(); ! type.getConstraint().enter(); Typing.leq(type.getMonotype(), PrimitiveType.sureTC); Typing.implies(); --- 1058,1062 ---- try { Typing.enter(); ! notNull(type.getConstraint()).enter(); Typing.leq(type.getMonotype(), PrimitiveType.sureTC); Typing.implies(); Index: constant.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constant.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** constant.nice 2 Sep 2004 15:46:32 -0000 1.1 --- constant.nice 13 Oct 2004 23:22:22 -0000 1.2 *************** *** 59,63 **** } ! let LocatedString voidName = new LocatedString("void", bossa.util.Location.nowhere()); /** --- 59,63 ---- } ! let LocatedString voidName = new LocatedString("void"); /** *************** *** 88,92 **** } ! let LocatedString stringClassName = new LocatedString("java.lang.String", Location.nowhere()); // cf. JLS 3.10.6 --- 88,92 ---- } ! let LocatedString stringClassName = new LocatedString("java.lang.String"); // cf. JLS 3.10.6 *************** *** 198,204 **** } ! TypeConstructor getTC() { ! return nice.tools.typing.Types.rawType(representedType).head(); } --- 198,204 ---- } ! ?TypeConstructor getTC() { ! return notNull(nice.tools.typing.Types.rawType(representedType)).head(); } Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** tools.nice 7 Oct 2004 22:03:44 -0000 1.52 --- tools.nice 13 Oct 2004 23:22:22 -0000 1.53 *************** *** 76,80 **** MethodDeclaration.enterLocalContext(); ! type.getConstraint.enter(true); } --- 76,80 ---- MethodDeclaration.enterLocalContext(); ! notNull(type.getConstraint).enter(true); } *************** *** 192,195 **** --- 192,197 ---- LocatedString name(VarSymbol) = native VarSymbol.name; Arguments.Argument[] arguments(Arguments) = native Arguments.arguments; + Arguments Argument(List<Arguments.Argument>) = native new Arguments(List); + Arguments Argument(Arguments.Argument[]) = native new Arguments(Arguments.Argument[]); mlsub.typing.Polytype getType(Expression) = native mlsub.typing.Polytype Expression.getType(); *************** *** 212,217 **** ?mlsub.typing.TypeConstructor getRuntimeTC(Pattern) = native mlsub.typing.TypeConstructor Pattern.getRuntimeTC(); boolean matchesValue(Pattern, ConstantExp) = native boolean Pattern.matchesValue(ConstantExp); ! public ?LocatedString getName(Pattern) = native LocatedString Pattern.getName(); ! // Retypings needed since java types are not strict. --- 214,230 ---- ?mlsub.typing.TypeConstructor getRuntimeTC(Pattern) = native mlsub.typing.TypeConstructor Pattern.getRuntimeTC(); boolean matchesValue(Pattern, ConstantExp) = native boolean Pattern.matchesValue(ConstantExp); ! ?LocatedString getName(Pattern) = native LocatedString Pattern.getName(); ! ?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(); ! ?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); ! mlsub.typing.Monotype[?] Types_parameters(mlsub.typing.Polytype) = native mlsub.typing.Monotype[] nice.tools.typing.Types.parameters(mlsub.typing.Polytype); ! ?mlsub.typing.TypeConstructor head(mlsub.typing.Monotype) = native mlsub.typing.TypeConstructor mlsub.typing.Monotype.head(); ! ?ClassDefinition ClassDefinition_get(mlsub.typing.TypeConstructor) = native ClassDefinition ClassDefinition.get(mlsub.typing.TypeConstructor); ! ?gnu.bytecode.ClassType getSuperclass(gnu.bytecode.ClassType) = native gnu.bytecode.ClassType gnu.bytecode.ClassType.getSuperclass(); ! int[?] getUsedArguments(Arguments, VarSymbol) = native int[] Arguments.getUsedArguments(VarSymbol); ! ?mlsub.typing.Constraint getConstraint(mlsub.typing.Polytype) = native mlsub.typing.Constraint mlsub.typing.Polytype.getConstraint(); // Retypings needed since java types are not strict. Index: locals.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/locals.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** locals.nice 8 Aug 2004 21:51:54 -0000 1.1 --- locals.nice 13 Oct 2004 23:22:22 -0000 1.2 *************** *** 126,136 **** } ! display() ! { ! if (left.constant) ! return "let "+ super; ! else ! return "var " + super; ! } } --- 126,130 ---- } ! display() = (left.constant ? "let " : "var ") + super; } Index: new.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/new.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** new.nice 13 Aug 2004 21:04:41 -0000 1.3 --- new.nice 13 Oct 2004 23:22:22 -0000 1.4 *************** *** 56,64 **** // Make sure that the constructors have been created. ! ClassDefinition definition = ClassDefinition.get(tc); if (definition != null) definition.resolve(); ! LinkedList<VarSymbol> constructors = TypeConstructors.getConstructors(tc); if (constructors == null) { --- 56,64 ---- // Make sure that the constructors have been created. ! let definition = ClassDefinition.get(tc); if (definition != null) definition.resolve(); ! ?LinkedList<VarSymbol> constructors = TypeConstructors.getConstructors(tc); if (constructors == null) { *************** *** 75,79 **** constructors = constructors.clone(); ! function = createOverloadedSymbolExp(constructors, new LocatedString("new " + tc, this.location())); } --- 75,79 ---- constructors = constructors.clone(); ! function = createOverloadedSymbolExp(notNull(constructors), new LocatedString("new " + tc, this.location())); } *************** *** 85,89 **** } ! toString() = "new " + ti.toString() + arguments; } --- 85,89 ---- } ! toString() = "new " + ti + arguments; } Index: EnumDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/EnumDefinition.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** EnumDefinition.java 2 Sep 2004 15:46:32 -0000 1.14 --- EnumDefinition.java 13 Oct 2004 23:22:22 -0000 1.15 *************** *** 60,64 **** Statement body = bossa.syntax.dispatch.createReturnStmt(bossa.syntax.dispatch.createLiteralArrayExp(exps), true); ! LocatedString mName = new LocatedString("family", bossa.util.Location.nowhere()); Definition mBodyDef = new MethodBodyDefinition(impl, mName, null, new LinkedList(), body); --- 60,64 ---- Statement body = bossa.syntax.dispatch.createReturnStmt(bossa.syntax.dispatch.createLiteralArrayExp(exps), true); ! LocatedString mName = new LocatedString("family"); Definition mBodyDef = new MethodBodyDefinition(impl, mName, null, new LinkedList(), body); Index: assign.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/assign.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** assign.nice 2 Sep 2004 19:12:09 -0000 1.3 --- assign.nice 13 Oct 2004 23:22:22 -0000 1.4 *************** *** 39,43 **** { // Rewrite "get(e, i, ...) = v" into "set(e, i, ... , v)" ! if (to instanceof CallExp && "get".equals(notNull(to.function).toString())) { List<Arguments.Argument> args = new ArrayList(to.arguments.arguments); --- 39,43 ---- { // Rewrite "get(e, i, ...) = v" into "set(e, i, ... , v)" ! if (to instanceof CallExp && "get".equals(to.function.toString())) { List<Arguments.Argument> args = new ArrayList(to.arguments.arguments); *************** *** 45,50 **** return createCallExp( ! new IdentExp(new LocatedString("set", notNull(to.function).location())), ! new Arguments(args.toArray())); } --- 45,50 ---- return createCallExp( ! new IdentExp(new LocatedString("set", to.function.location())), ! new Arguments(args)); } Index: super.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/super.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** super.nice 7 Aug 2004 14:20:29 -0000 1.2 --- super.nice 13 Oct 2004 23:22:22 -0000 1.3 *************** *** 122,126 **** mlsub.typing.Monotype[] m = monotype.domain(); List<mlsub.typing.AtomicConstraint> newAtoms = new ArrayList(); ! mlsub.typing.AtomicConstraint[?] oldAtoms = type.getConstraint().atoms(); if (oldAtoms != null) --- 122,126 ---- mlsub.typing.Monotype[] m = monotype.domain(); List<mlsub.typing.AtomicConstraint> newAtoms = new ArrayList(); ! mlsub.typing.AtomicConstraint[?] oldAtoms = notNull(type.getConstraint()).atoms(); if (oldAtoms != null) *************** *** 149,153 **** } ! constraint = new mlsub.typing.Constraint(type.getConstraint().binders(), new mlsub.typing.AtomicConstraint[newAtoms.size()].fillWith(newAtoms)); --- 149,153 ---- } ! constraint = new mlsub.typing.Constraint(notNull(type.getConstraint()).binders(), new mlsub.typing.AtomicConstraint[newAtoms.size()].fillWith(newAtoms)); *************** *** 170,174 **** // the base method), a call to super is emited. { ! let NiceClass nc = cast(ClassDefinition.get(notNull(currentMethod).firstArgument()).implementation); code = nc.callSuperMethod(notNull(superMethod)); } --- 170,174 ---- // the base method), a call to super is emited. { ! let NiceClass nc = cast(notNull(ClassDefinition.get(notNull(currentMethod).firstArgument())).implementation); code = nc.callSuperMethod(notNull(superMethod)); } Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** overloadedsymbol.nice 13 Aug 2004 21:04:41 -0000 1.4 --- overloadedsymbol.nice 13 Oct 2004 23:22:22 -0000 1.5 *************** *** 574,578 **** } ! private Domain domain(mlsub.typing.Polytype t, int[] usedArguments) { // remove nullness marker --- 574,578 ---- } ! private Domain domain(mlsub.typing.Polytype t, int[?] usedArguments) { // remove nullness marker Index: increment.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/increment.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** increment.nice 13 Aug 2004 21:04:41 -0000 1.2 --- increment.nice 13 Oct 2004 23:22:22 -0000 1.3 *************** *** 42,63 **** // variable is not a local variable, so it must be a field ! ?CallExp call = null; ! if (variable instanceof CallExp) ! call = cast(variable); ! ! if (call == null) Internal.error(this, "\"var\" is assignable and not a local, " + "so it should be a call to a FieldAccessMethod"); ! let access = notNull(call).function.getFieldAccessMethod(); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + "so it should be a call to a FieldAccessMethod"); ! if (access.isFinal()) User.error(this, "Field " + access + " is final"); ! return NiceUtils.doInline(new nice.tools.code.IncrementProc(access.fieldDecl, returnOld, increment), ! notNull(call).arguments.getExp(0).generateCode()); } --- 42,61 ---- // variable is not a local variable, so it must be a field ! if (! (variable instanceof CallExp)) Internal.error(this, "\"var\" is assignable and not a local, " + "so it should be a call to a FieldAccessMethod"); ! CallExp call = cast(variable); ! ! let access = call.function.getFieldAccessMethod(); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + "so it should be a call to a FieldAccessMethod"); ! if (notNull(access).isFinal()) User.error(this, "Field " + access + " is final"); ! return NiceUtils.doInline(new nice.tools.code.IncrementProc(notNull(access).fieldDecl, returnOld, increment), ! call.arguments.getExp(0).generateCode()); } Index: call.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/call.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** call.nice 11 Aug 2004 12:34:30 -0000 1.3 --- call.nice 13 Oct 2004 23:22:22 -0000 1.4 *************** *** 156,160 **** gnu.expr.Expression res; if (function.isFieldAccess()) ! res = 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 = notNull(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 = function.getFieldAccessMethod(); if (access.isFinal()) --- 198,202 ---- Internal.error(this, "Assignment to a call that is not a field access"); ! FieldAccess access = notNull(function.getFieldAccessMethod()); if (access.isFinal()) |