diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/icode/GenICode.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 6aee52a354..b9675b8270 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -94,7 +94,7 @@ abstract class GenICode extends SubComponent { // !! modules should be eliminated by refcheck... or not? case ModuleDef(mods, name, impl) => - abort("Modules should not reach backend!") + abort("Modules should not reach backend! " + tree) case ValDef(mods, name, tpt, rhs) => ctx // we use the symbol to add fields @@ -393,15 +393,15 @@ abstract class GenICode extends SubComponent { for (CaseDef(pat, _, body) <- catches.reverse) yield { def genWildcardHandler(sym: Symbol): (Symbol, TypeKind, Context => Context) = (sym, kind, ctx => { - ctx.bb.emit(DROP(REFERENCE(sym))) + ctx.bb.emit(DROP(REFERENCE(sym))) // drop the loaded exception genLoad(body, ctx, kind) }) pat match { case Typed(Ident(nme.WILDCARD), tpt) => genWildcardHandler(tpt.tpe.typeSymbol) case Ident(nme.WILDCARD) => genWildcardHandler(ThrowableClass) - case Bind(name, _) => - val exception = ctx.method addLocal new Local(pat.symbol, toTypeKind(pat.symbol.tpe), false) + case Bind(_, _) => + val exception = ctx.method addLocal new Local(pat.symbol, toTypeKind(pat.symbol.tpe), false) // the exception will be loaded and stored into this local (pat.symbol.tpe.typeSymbol, kind, { ctx: Context => @@ -704,7 +704,8 @@ abstract class GenICode extends SubComponent { ctx1 case New(tpt) => - abort("Unexpected New") + abort("Unexpected New(" + tpt.summaryString + "/" + tpt + ") received in icode.\n" + + " Call was genLoad" + ((tree, ctx, expectedType))) case Apply(TypeApply(fun, targs), _) => val sym = fun.symbol @@ -875,7 +876,23 @@ abstract class GenICode extends SubComponent { val (newCtx, resKind) = genPrimitiveOp(app, ctx, expectedType) generatedType = resKind newCtx - } else { // normal method call + } else if (sym.elisionLevel.exists (_ < settings.elidebelow.value || settings.noassertions.value)) { + // XXX settings.noassertions.value temporarily retained to avoid + // breakage until a reasonable interface is settled upon. + debuglog("Eliding call from " + tree.symbol.owner + " to " + sym + + " based on its elision threshold of " + sym.elisionLevel.get) + if (expectedType.isValueType) { + ctx.bb.emit(CONSTANT(global.gen.mkConstantZero(expectedType.toType)), tree.pos) + generatedType = expectedType + } + else if (expectedType.isNothingType) unit.error(tree.pos, "Cannot elide where Nothing is required.") + else { + ctx.bb.emit(CONSTANT(Constant(null)), tree.pos) + generatedType = NullReference + } + ctx + } + else { // normal method call debuglog("Gen CALL_METHOD with sym: " + sym + " isStaticSymbol: " + sym.isStaticMember); val invokeStyle = if (sym.isStaticMember) @@ -1054,7 +1071,7 @@ abstract class GenICode extends SubComponent { case Match(selector, cases) => debuglog("Generating SWITCH statement."); - var ctx1 = genLoad(selector, ctx, INT) + var ctx1 = genLoad(selector, ctx, INT) // TODO: Java 7 allows strings in switches (so, don't assume INT and don't convert the literals using intValue) val afterCtx = ctx1.newBlock var caseCtx: Context = null generatedType = toTypeKind(tree.tpe) @@ -2086,12 +2103,12 @@ abstract class GenICode extends SubComponent { exh }) else None - val exhs = handlers.map { handler => - val exh = this.newExceptionHandler(handler._1, handler._2, tree.pos) + val exhs = handlers.map { case (sym, kind, handler) => // def genWildcardHandler(sym: Symbol): (Symbol, TypeKind, Context => Context) = + val exh = this.newExceptionHandler(sym, kind, tree.pos) var ctx1 = outerCtx.enterExceptionHandler(exh) ctx1.addFinalizer(finalizer, finalizerCtx) loadException(ctx1, exh, tree.pos) - ctx1 = handler._3(ctx1) + ctx1 = handler(ctx1) // emit finalizer val ctx2 = emitFinalizer(ctx1) ctx2.bb.closeWith(JUMP(afterCtx.bb)) |