[Nice-commit] Nice/src/bossa/syntax analyse.nice,1.109,1.110 block.nice,1.1,1.2 break.nice,1.2,1.3 i
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-08-13 21:04:52
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11917/F:/nice/src/bossa/syntax Modified Files: analyse.nice block.nice break.nice increment.nice loop.nice new.nice overloadedsymbol.nice return.nice statementexp.nice tools.nice typecheck.nice Log Message: Cleanup of nullness things in converted code. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** analyse.nice 8 Aug 2004 21:51:54 -0000 1.109 --- analyse.nice 13 Aug 2004 21:04:41 -0000 1.110 *************** *** 273,277 **** } ! void analyseExps(?Expression[] exps, Info info) { for (int i = 0; i < exps.length; i++) --- 273,277 ---- } ! void analyseExps(Expression[] exps, Info info) { for (int i = 0; i < exps.length; i++) *************** *** 303,307 **** { e.initValue = analyse(e.initValue, info); ! setInitialized(notNull(notNull(e.variable).left), info, e.location()); return e; } --- 303,307 ---- { e.initValue = analyse(e.initValue, info); ! setInitialized(e.variable.left, info, e.location()); return e; } *************** *** 358,362 **** e.isCallTo("assert") && args.size() > 0 && args.getExp(0).isFalse(); ! markAsCallFun(notNull(e.function), e.infix); e.function = analyse(e.function, info); --- 358,362 ---- e.isCallTo("assert") && args.size() > 0 && args.getExp(0).isFalse(); ! markAsCallFun(e.function, e.infix); e.function = analyse(e.function, info); *************** *** 569,573 **** analyse(LiteralArrayExp e, info) { ! analyseExps(cast(e.elements), info); return e; } --- 569,573 ---- analyse(LiteralArrayExp e, info) { ! analyseExps(e.elements, info); return e; } *************** *** 576,580 **** { e.resolveTC(info.typeMap); ! analyseExps(cast(notNull(e.knownDimensions)), info); return e; } --- 576,580 ---- { e.resolveTC(info.typeMap); ! analyseExps(e.knownDimensions, info); return e; } *************** *** 667,671 **** analyse(TupleExp e, info) { ! analyseExps(cast(notNull(e.expressions)), info); return e; } --- 667,671 ---- analyse(TupleExp e, info) { ! analyseExps(e.expressions, info); return e; } *************** *** 691,698 **** decl.setIndex(++info.varIndex); ! info.addVar(notNull(decl.left)); ! if (info.localsOfCurrentLoop != null && notNull(decl.left).constant) ! notNull(info.localsOfCurrentLoop).add(notNull(decl.left)); } --- 691,698 ---- decl.setIndex(++info.varIndex); ! info.addVar(decl.left); ! if (info.localsOfCurrentLoop != null && decl.left.constant) ! notNull(info.localsOfCurrentLoop).add(decl.left); } *************** *** 700,711 **** { decl.value = analyse(decl.value, info); ! info.addVar(notNull(decl.left)); } analyse(LocalFunction decl, info) { ! notNull(decl.parameters).resolveCalledFromAnalyse(cast(info)); ! info.addVar(notNull(decl.left)); decl.value = analyse(decl.value, info); } --- 700,711 ---- { decl.value = analyse(decl.value, info); ! info.addVar(decl.left); } analyse(LocalFunction decl, info) { ! decl.parameters.resolveCalledFromAnalyse(cast(info)); ! info.addVar(decl.left); decl.value = analyse(decl.value, info); } *************** *** 797,801 **** analyse(LabeledStmt s, info) { ! mustNotFindLabel(notNull(s.getLabel()), info); info.labels.push(s); analyse(s.getStatement(), info); --- 797,801 ---- analyse(LabeledStmt s, info) { ! mustNotFindLabel(s.getLabel(), info); info.labels.push(s); analyse(s.getStatement(), info); *************** *** 830,834 **** analyse(BreakLabelStmt b, info) { ! LabeledStmt target = b.statement = mustFindLabel(notNull(b.label), info); ?LoopStmt loop = target.getLoop(); --- 830,834 ---- analyse(BreakLabelStmt b, info) { ! LabeledStmt target = b.statement = mustFindLabel(b.label, info); ?LoopStmt loop = target.getLoop(); *************** *** 884,888 **** info.otherCase(); info.begin(); ! info.addVar(notNull(c.exnVar)); c.t = notNull(c.tc).resolveToTC(info.typeMap); c.tc = null; --- 884,888 ---- info.otherCase(); info.begin(); ! info.addVar(c.exnVar); c.t = notNull(c.tc).resolveToTC(info.typeMap); c.tc = null; Index: break.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/break.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** break.nice 11 Aug 2004 13:36:09 -0000 1.2 --- break.nice 13 Aug 2004 21:04:41 -0000 1.3 *************** *** 86,92 **** generateCode() { - // if (statement == null) - // return notNull(gnu.expr.QuoteExp.voidExp); - let res = block = new gnu.expr.BlockExp(); notNull(block).setBody(statement.generateCode()); --- 86,89 ---- Index: return.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/return.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** return.nice 28 Jul 2004 20:48:28 -0000 1.2 --- return.nice 13 Aug 2004 21:04:41 -0000 1.3 *************** *** 45,49 **** mlsub.typing.Polytype returnType() { ! return notNull(PrimitiveType.voidPolytype); } --- 45,49 ---- mlsub.typing.Polytype returnType() { ! return PrimitiveType.voidPolytype; } Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** typecheck.nice 8 Aug 2004 21:51:54 -0000 1.112 --- typecheck.nice 13 Aug 2004 21:04:41 -0000 1.113 *************** *** 40,44 **** typecheck(AssignExp e) { ! Expression to = notNull(notNull(e.to).noOverloading()); e.to = to; typecheck(to); --- 40,44 ---- typecheck(AssignExp e) { ! Expression to = e.to.noOverloading(); e.to = to; typecheck(to); *************** *** 52,57 **** try{ ! e.value = notNull(e.value).resolveOverloading(to.getType()); ! checkAssignment(to.getType(), notNull(e.value)); } catch(TypingEx t){ --- 52,57 ---- try{ ! e.value = e.value.resolveOverloading(to.getType()); ! checkAssignment(to.getType(), e.value); } catch(TypingEx t){ *************** *** 61,65 **** try { ! checkAssignment(originalType, notNull(e.value)); // It is OK to assign the variable, considering it has the original --- 61,65 ---- try { ! checkAssignment(originalType, e.value); // It is OK to assign the variable, considering it has the original *************** *** 80,89 **** toName = field.getName().toString(); ! reportNullAssignmentError(e, t, value: notNull(e.value), toName, to.getType().getMonotype(), field != null); throw assignmentError(e, to.toString(), ! to.getType().toString(), notNull(e.value)); } --- 80,89 ---- toName = field.getName().toString(); ! reportNullAssignmentError(e, t, value: e.value, toName, to.getType().getMonotype(), field != null); throw assignmentError(e, to.toString(), ! to.getType().toString(), e.value); } *************** *** 93,100 **** if (originalType != null) try { ! checkAssignment(originalType, notNull(e.value)); } catch (TypingEx t) { throw assignmentError(e, to.toString(), ! to.getType().toString(), notNull(e.value)); } } --- 93,100 ---- if (originalType != null) try { ! checkAssignment(originalType, e.value); } catch (TypingEx t) { throw assignmentError(e, to.toString(), ! to.getType().toString(), e.value); } } *************** *** 102,106 **** } ! void typecheckExps(?Expression[] exps) { for (int i = 0; i < exps.length; i++) --- 102,106 ---- } ! void typecheckExps(Expression[] exps) { for (int i = 0; i < exps.length; i++) *************** *** 508,514 **** typecheck(IfExp e) { ! Expression condition = notNull(e.condition); ! Expression thenExp = notNull(e.thenExp); ! Expression elseExp = notNull(e.elseExp); condition = condition.resolveOverloading(PrimitiveType.boolPolytype); --- 508,514 ---- typecheck(IfExp e) { ! Expression condition = e.condition; ! Expression thenExp = e.thenExp; ! Expression elseExp = e.elseExp; condition = condition.resolveOverloading(PrimitiveType.boolPolytype); *************** *** 539,543 **** setVarType(variable, now: type, otherBranch: variable.type)); ! e.thenExp = thenExp = notNull(thenExp.noOverloading()); typecheck(thenExp); // since the type of the variable is destructively changed, --- 539,543 ---- setVarType(variable, now: type, otherBranch: variable.type)); ! e.thenExp = thenExp = thenExp.noOverloading(); typecheck(thenExp); // since the type of the variable is destructively changed, *************** *** 561,565 **** setVarType(variable, now: type, out: variable.type)); ! e.elseExp = elseExp = notNull(elseExp.noOverloading()); typecheck(elseExp); // since the type of the variable is destructively changed, --- 561,565 ---- setVarType(variable, now: type, out: variable.type)); ! e.elseExp = elseExp = elseExp.noOverloading(); typecheck(elseExp); // since the type of the variable is destructively changed, *************** *** 610,615 **** { try{ ! e.variable = notNull(e.variable).resolveOverloading(PrimitiveType.longPolytype); ! checkAssignment(PrimitiveType.longType, notNull(e.variable)); } catch(TypingEx t){ --- 610,615 ---- { try{ ! e.variable = e.variable.resolveOverloading(PrimitiveType.longPolytype); ! checkAssignment(PrimitiveType.longType, e.variable); } catch(TypingEx t){ *************** *** 617,622 **** throw new bossa.util.UserError (e, ! notNull(e.description()) + " is only valid on integers.\n" + ! e.variable + " has type " + notNull(e.variable).getType()); } } --- 617,622 ---- throw new bossa.util.UserError (e, ! e.description() + " is only valid on integers.\n" + ! e.variable + " has type " + e.variable.getType()); } } *************** *** 624,633 **** typecheck(LiteralArrayExp e) { ! typecheckExps(cast(e.elements)); } typecheck(NewArrayExp e) { ! Expression[] knownDimensions = notNull(e.knownDimensions); for (int i=0; i<knownDimensions.length; i++) --- 624,633 ---- typecheck(LiteralArrayExp e) { ! typecheckExps(e.elements); } typecheck(NewArrayExp e) { ! Expression[] knownDimensions = e.knownDimensions; for (int i=0; i<knownDimensions.length; i++) *************** *** 662,666 **** typecheck(TupleExp e) { ! typecheckExps(cast(notNull(e.expressions))); } --- 662,666 ---- typecheck(TupleExp e) { ! typecheckExps(e.expressions); } *************** *** 678,682 **** { let decl = e.variable; ! MonoSymbol target = notNull(decl.left); if (! target.used) --- 678,682 ---- { let decl = e.variable; ! MonoSymbol target = decl.left; if (! target.used) *************** *** 684,688 **** ?mlsub.typing.Monotype type = target.getMonotype(); ! Expression value = notNull(e.initValue); if (type == null) --- 684,688 ---- ?mlsub.typing.Monotype type = target.getMonotype(); ! Expression value = e.initValue; if (type == null) *************** *** 733,742 **** b.statements = rewrite(b.statements); ! b.locals.foreach(?LocalDeclaration d => typecheck(d)); b.statements.foreach ! (?Statement s => { try { typecheck(s); } catch (bossa.util.UserError ex) ! { throw ensureLocated(ex, notNull(s)); } }); } --- 733,742 ---- b.statements = rewrite(b.statements); ! b.locals.foreach(LocalDeclaration d => typecheck(d)); b.statements.foreach ! (Statement s => { try { typecheck(s); } catch (bossa.util.UserError ex) ! { throw ensureLocated(ex, s); } }); } *************** *** 748,752 **** typecheck(LocalVariable decl) { ! MonoSymbol target = notNull(decl.left()); if (! target.used) --- 748,752 ---- typecheck(LocalVariable decl) { ! MonoSymbol target = decl.left; if (! target.used) *************** *** 765,769 **** if (target.type == PrimitiveType.byteType || target.type == PrimitiveType.shortType) ! target.type = notNull(PrimitiveType.intType); if (nice.tools.typing.Types.isVoid(target.type)) --- 765,769 ---- if (target.type == PrimitiveType.byteType || target.type == PrimitiveType.shortType) ! target.type = PrimitiveType.intType; if (nice.tools.typing.Types.isVoid(target.type)) *************** *** 791,796 **** typecheck(LocalConstant decl) { ! if (! notNull(decl.left).used) ! bossa.util.User.warning(decl, "Unused local variable " + notNull(decl.left).name); typecheck(decl.value); --- 791,796 ---- typecheck(LocalConstant decl) { ! if (! decl.left.used) ! bossa.util.User.warning(decl, "Unused local variable " + decl.left.name); typecheck(decl.value); *************** *** 798,804 **** mlsub.typing.Polytype type = notNull(decl.value).getType(); ! notNull(decl.left).type = ensureMonomorphic(type, decl); ! if (nice.tools.typing.Types.isVoid(notNull(decl.left).type)) throw error(decl, "A variable cannot have a void type"); --- 798,804 ---- mlsub.typing.Polytype type = notNull(decl.value).getType(); ! decl.left.type = ensureMonomorphic(type, decl); ! if (nice.tools.typing.Types.isVoid(decl.left.type)) throw error(decl, "A variable cannot have a void type"); *************** *** 883,887 **** ?mlsub.typing.Monotype expectedType = function.getExpectedType(); if (expectedType == null) ! r.value = notNull(r.value).noOverloading(); else { --- 883,887 ---- ?mlsub.typing.Monotype expectedType = function.getExpectedType(); if (expectedType == null) ! r.value = r.value.noOverloading(); else { *************** *** 889,894 **** throw bossa.util.User.error(r, "Cannot return a value here"); ! r.value = notNull(r.value).resolveOverloading ! (new mlsub.typing.Polytype(expectedType)); } --- 889,893 ---- throw bossa.util.User.error(r, "Cannot return a value here"); ! r.value = r.value.resolveOverloading(new mlsub.typing.Polytype(expectedType)); } *************** *** 902,906 **** catch(Function.WrongReturnType e){ if (notNullError(notNull(e.typingException), r, String.valueOf(r.value))) ! wrongReturnType(r, notNull(r.returnType()).toString(), valueOf(e.expectedReturnType), notNull(e.typingException)); } --- 901,905 ---- catch(Function.WrongReturnType e){ if (notNullError(notNull(e.typingException), r, String.valueOf(r.value))) ! wrongReturnType(r, r.returnType().toString(), valueOf(e.expectedReturnType), notNull(e.typingException)); } *************** *** 923,927 **** } catch(Function.WrongReturnType e){ ! wrongReturnType(r, notNull(r.returnType()).toString(), valueOf(e.expectedReturnType), notNull(e.typingException)); } --- 922,926 ---- } catch(Function.WrongReturnType e){ ! wrongReturnType(r, r.returnType().toString(), valueOf(e.expectedReturnType), notNull(e.typingException)); } *************** *** 941,946 **** typecheck(SynchronizedStmt s) { ! s.object = notNull(s.object).noOverloading(); ! mlsub.typing.Polytype type = notNull(s.object).getType(); if (nice.tools.typing.Types.isPrimitive(type)) throw bossa.util.User.error(s.object, --- 940,945 ---- typecheck(SynchronizedStmt s) { ! s.object = s.object.noOverloading(); ! mlsub.typing.Polytype type = s.object.getType(); if (nice.tools.typing.Types.isPrimitive(type)) throw bossa.util.User.error(s.object, Index: statementexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/statementexp.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** statementexp.nice 28 Jul 2004 14:40:33 -0000 1.1 --- statementexp.nice 13 Aug 2004 21:04:41 -0000 1.2 *************** *** 27,33 **** compile() { - if (statement == null) - return notNull(gnu.expr.QuoteExp.voidExp); - return new gnu.expr.BeginExp(statement.generateCode(), gnu.expr.QuoteExp.voidExp); } --- 27,30 ---- Index: loop.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/loop.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** loop.nice 8 Aug 2004 21:51:54 -0000 1.3 --- loop.nice 13 Aug 2004 21:04:41 -0000 1.4 *************** *** 60,69 **** if (whileExp == null) ! test = notNull(gnu.expr.QuoteExp.trueExp); else test = notNull(whileExp).generateCode(); if (iterationStatements == null) ! iteration = notNull(gnu.expr.QuoteExp.voidExp); else iteration = notNull(iterationStatements).generateCode(); --- 60,69 ---- if (whileExp == null) ! test = gnu.expr.QuoteExp.trueExp; else test = notNull(whileExp).generateCode(); if (iterationStatements == null) ! iteration = gnu.expr.QuoteExp.voidExp; else iteration = notNull(iterationStatements).generateCode(); *************** *** 77,81 **** res = notNull(code); ! notNull(code).setBody(loopBody != null ? notNull(loopBody).generateCode() : null); code = null; --- 77,81 ---- res = notNull(code); ! notNull(code).setBody(loopBody.generateCode()); code = null; *************** *** 91,100 **** { if (!testFirst) ! return "do {\n" + (loopBody == null ? " " : loopBody.toString()) + ! "}\n while (" + whileExp + ");"; if (iterationStatements == null) ! return "while (" + whileExp + ")" + ! (loopBody == null ? ";" : loopBody.toString()); Block itbl = cast(iterationStatements); --- 91,98 ---- { if (!testFirst) ! return "do {\n" + loopBody + "}\n while (" + whileExp + ");"; if (iterationStatements == null) ! return "while (" + whileExp + ")" + loopBody; Block itbl = cast(iterationStatements); *************** *** 108,113 **** } ! return "for(; " + whileExp + " ;" + itStats + ")\n " + ! (loopBody == null ? "" : loopBody.toString()); } } --- 106,110 ---- } ! return "for(; " + whileExp + " ;" + itStats + ")\n " + loopBody; } } Index: new.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/new.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** new.nice 5 Aug 2004 10:45:30 -0000 1.2 --- new.nice 13 Aug 2004 21:04:41 -0000 1.3 *************** *** 14,18 **** import bossa.util.*; - import java.util.*; /** --- 14,17 ---- Index: block.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/block.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** block.nice 8 Aug 2004 21:51:54 -0000 1.1 --- block.nice 13 Aug 2004 21:04:41 -0000 1.2 *************** *** 149,153 **** let stmts = res.cutInBlocks(statements); res.statements = stmts; ! if (stmts != null && stmts.length > 0 && stmts[0] != null) res.setLocation(stmts[0].location()); return res; --- 149,153 ---- let stmts = res.cutInBlocks(statements); res.statements = stmts; ! if (stmts.length > 0) res.setLocation(stmts[0].location()); return res; Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** tools.nice 8 Aug 2004 21:51:54 -0000 1.47 --- tools.nice 13 Aug 2004 21:04:41 -0000 1.48 *************** *** 211,217 **** --- 211,220 ---- mlsub.typing.Polytype boolPolytype() = native PrimitiveType.boolPolytype; mlsub.typing.Polytype longPolytype() = native PrimitiveType.longPolytype; + mlsub.typing.Polytype voidPolytype() = native PrimitiveType.voidPolytype; mlsub.typing.Monotype boolType() = native PrimitiveType.boolType; mlsub.typing.Monotype intType() = native PrimitiveType.intType; mlsub.typing.Monotype longType() = native PrimitiveType.longType; + gnu.expr.QuoteExp trueExp() = native gnu.expr.QuoteExp.trueExp; + gnu.expr.QuoteExp voidExp() = native gnu.expr.QuoteExp.voidExp; // Local Variables: Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** overloadedsymbol.nice 5 Aug 2004 10:45:30 -0000 1.3 --- overloadedsymbol.nice 13 Aug 2004 21:04:41 -0000 1.4 *************** *** 420,426 **** Expression createOverloadedSymbolExp(List<VarSymbol> symbols, LocatedString ident) { - if(symbols == null) - Internal.error("No symbols"); - let res = new OverloadedSymbolExp(symbols: symbols, ident: ident); res.setLocation(ident.location()); --- 420,423 ---- *************** *** 431,437 **** boolean noImplicitThis) { - if(symbols == null) - Internal.error("No symbols"); - let res = new OverloadedSymbolExp(symbols: symbols, ident: ident, noImplicitThis: noImplicitThis); res.setLocation(ident.location()); --- 428,431 ---- Index: increment.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/increment.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** increment.nice 28 Jul 2004 14:40:33 -0000 1.1 --- increment.nice 13 Aug 2004 21:04:41 -0000 1.2 *************** *** 50,54 **** "so it should be a call to a FieldAccessMethod"); ! let access = notNull(notNull(call).function).getFieldAccessMethod(); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + --- 50,54 ---- "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, " + |