summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2007-03-26 12:45:33 +0000
committerIulian Dragos <jaguarul@gmail.com>2007-03-26 12:45:33 +0000
commite2ec34436ea22b62d091be0bb56a577f0e0c4c07 (patch)
treeda9f2b88fadb2861cde9c7e14b5c688e61e81886 /src
parente0e03261824f9d42a6dbb290b0936eaf0e22143d (diff)
downloadscala-e2ec34436ea22b62d091be0bb56a577f0e0c4c07.tar.gz
scala-e2ec34436ea22b62d091be0bb56a577f0e0c4c07.tar.bz2
scala-e2ec34436ea22b62d091be0bb56a577f0e0c4c07.zip
Fixed bug #1020 (crash on finally with try-catch).
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala24
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala6
2 files changed, 12 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index bfb09d1091..1cb38f79e1 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -398,8 +398,7 @@ abstract class GenICode extends SubComponent {
case ValDef(_, _, _, rhs) =>
val sym = tree.symbol
- var local = new Local(sym, toTypeKind(sym.info), false)
- local = ctx.method.addLocal(local)
+ val local = ctx.method.addLocal(new Local(sym, toTypeKind(sym.info), false))
ctx.scope.add(local)
ctx.bb.emit(SCOPE_ENTER(local))
@@ -495,8 +494,7 @@ abstract class GenICode extends SubComponent {
})
case Bind(name, _) =>
- val exception = new Local(pat.symbol, toTypeKind(pat.symbol.tpe), false)
- ctx.method.addLocal(exception);
+ val exception = ctx.method.addLocal(new Local(pat.symbol, toTypeKind(pat.symbol.tpe), false))
(pat.symbol.tpe.symbol, kind, {
ctx: Context =>
@@ -511,12 +509,11 @@ abstract class GenICode extends SubComponent {
if (finalizer != EmptyTree)
handlers = (NoSymbol, kind, {
ctx: Context =>
- val exception = new Local(ctx.method.symbol
+ val exception = ctx.method.addLocal(new Local(ctx.method.symbol
.newVariable(finalizer.pos, unit.fresh.newName("exc"))
.setFlag(Flags.SYNTHETIC)
.setInfo(definitions.ThrowableClass.tpe),
- REFERENCE(definitions.ThrowableClass), false);
- ctx.method.addLocal(exception);
+ REFERENCE(definitions.ThrowableClass), false));
if (settings.Xdce.value)
ctx.bb.emit(LOAD_EXCEPTION())
ctx.bb.emit(STORE_LOCAL(exception));
@@ -535,9 +532,9 @@ abstract class GenICode extends SubComponent {
generatedType = kind; //toTypeKind(block.tpe);
val ctx1 = genLoad(block, bodyCtx, generatedType);
if (kind != UNIT && mayCleanStack(finalizer)) {
- val tmp = new Local(ctx.method.symbol.newVariable(tree.pos, unit.fresh.newName("tmp")).setInfo(tree.tpe).setFlag(Flags.SYNTHETIC),
- kind, false);
- ctx1.method.addLocal(tmp)
+ val tmp = ctx1.method.addLocal(
+ new Local(ctx.method.symbol.newVariable(tree.pos, unit.fresh.newName("tmp")).setInfo(tree.tpe).setFlag(Flags.SYNTHETIC),
+ kind, false))
if (settings.Xdce.value)
ctx.bb.emit(LOAD_EXCEPTION())
ctx1.bb.emit(STORE_LOCAL(tmp))
@@ -729,13 +726,13 @@ abstract class GenICode extends SubComponent {
generatedType = BOOL
ctx1 = afterCtx
} else if (code == scalaPrimitives.SYNCHRONIZED) {
- val monitor = new Local(ctx.method.symbol.newVariable(
+ var monitor = new Local(ctx.method.symbol.newVariable(
tree.pos,
unit.fresh.newName("monitor"))
.setInfo(definitions.ObjectClass.tpe)
.setFlag(Flags.SYNTHETIC),
ANY_REF_CLASS, false)
- ctx.method.addLocal(monitor)
+ monitor = ctx.method.addLocal(monitor)
ctx1 = genLoadQualifier(fun, ctx1)
ctx1.bb.emit(DUP(ANY_REF_CLASS))
@@ -1403,8 +1400,7 @@ abstract class GenICode extends SubComponent {
val eqEqTempVar =
ctx.method.symbol.newVariable(l.pos, eqEqTempName).setFlag(Flags.SYNTHETIC)
eqEqTempVar.setInfo(definitions.AnyRefClass.typeConstructor)
- val local = new Local(eqEqTempVar, REFERENCE(definitions.AnyRefClass), false)
- ctx.method.addLocal(local)
+ val local = ctx.method.addLocal(new Local(eqEqTempVar, REFERENCE(definitions.AnyRefClass), false))
local.start = unit.position(l.pos).line
local.end = unit.position(r.pos).line
local
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index 97a101a1a9..e256b0c87b 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -1257,14 +1257,12 @@ abstract class GenJVM extends SubComponent {
def indexOf(m: IMethod, sym: Symbol): Int = {
val Some(local) = m.lookupLocal(sym)
- assert(local.index >= 0,
- "Invalid index for: " + local + "{" + local.hashCode + "}")
- local.index
+ indexOf(local)
}
def indexOf(local: Local): Int = {
assert(local.index >= 0,
- "Invalid index for: " + local + "{" + local.hashCode + "}")
+ "Invalid index for: " + local + "{" + local.hashCode + "}: ")
local.index
}