diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2005-11-09 09:54:58 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2005-11-09 09:54:58 +0000 |
commit | 8800f2781ebcd3467f670da9e77af834b846ee83 (patch) | |
tree | 5301d64f2fb1355c79f52f8d2f8c36efddd4e6a7 | |
parent | 58dc9b6ad4ea2558f4dfc517efa0707cbb162a95 (diff) | |
download | scala-8800f2781ebcd3467f670da9e77af834b846ee83.tar.gz scala-8800f2781ebcd3467f670da9e77af834b846ee83.tar.bz2 scala-8800f2781ebcd3467f670da9e77af834b846ee83.zip |
Fixed some code generation issues.
-rw-r--r-- | sources/scala/tools/nsc/backend/icode/GenICode.scala | 16 | ||||
-rw-r--r-- | sources/scala/tools/nsc/backend/jvm/GenJVM.scala | 17 |
2 files changed, 16 insertions, 17 deletions
diff --git a/sources/scala/tools/nsc/backend/icode/GenICode.scala b/sources/scala/tools/nsc/backend/icode/GenICode.scala index a21fa72aa1..8b8c0e72b4 100644 --- a/sources/scala/tools/nsc/backend/icode/GenICode.scala +++ b/sources/scala/tools/nsc/backend/icode/GenICode.scala @@ -13,9 +13,6 @@ import scala.tools.nsc.symtab._; /** * TODO: - * - exception handling - * - synchronized blocks should add exception handlers that guarantee - * monitor releases in case of exceptions (like Java)? * - switches with alternatives */ abstract class GenICode extends SubComponent { @@ -427,10 +424,10 @@ abstract class GenICode extends SubComponent { val handlers = for (val CaseDef(pat, _, body) <- catches) yield pat match { case Typed(Ident(nme.WILDCARD), tpt) => - genHandler(body, tpt.tpe.symbol); + genHandler(body, tpt.tpe.symbol, expectedType); case Ident(nme.WILDCARD) => - genHandler(body, definitions.ThrowableClass); + genHandler(body, definitions.ThrowableClass, expectedType); case Bind(name, _) => val exception = new Local(pat.symbol, toTypeKind(pat.symbol.tpe)); @@ -440,7 +437,7 @@ abstract class GenICode extends SubComponent { val exhCtx = outerCtx.enterHandler(exh); exhCtx.bb.emit(STORE_LOCAL(exception, false), pat.pos); - val ctx1 = genLoad(body, exhCtx, toTypeKind(body.tpe)); + val ctx1 = genLoad(body, exhCtx, expectedType); // toTypeKind(body.tpe)); if (finalHandler != NoFinalizer) ctx1.bb.emit(CALL_FINALIZER(finalHandler)); ctx1.bb.emit(JUMP(afterCtx.bb)); @@ -528,8 +525,8 @@ abstract class GenICode extends SubComponent { // on the stack (contrary to what the type in the AST says). case Apply(fun @ Select(Super(_, mixin), _), args) => log("Call to super: " + tree); - val invokeStyle = - if (fun.symbol.isConstructor) Static(true) else SuperCall(mixin); + val invokeStyle = SuperCall(mixin); +// if (fun.symbol.isConstructor) Static(true) else SuperCall(mixin); ctx.bb.emit(THIS(ctx.clazz.symbol), tree.pos); val ctx1 = genLoadArguments(args, fun.symbol.info.paramTypes, ctx); @@ -847,7 +844,8 @@ abstract class GenICode extends SubComponent { } } - private def genExceptionHandler(ctx: Context, outerCtx: Context, afterCtx: Context, finalHandler: Finalizer)(body: Tree, sym: Symbol): ExceptionHandler = { + private def genExceptionHandler(ctx: Context, outerCtx: Context, afterCtx: Context, finalHandler: Finalizer) + (body: Tree, sym: Symbol, pt: TypeKind): ExceptionHandler = { val exh = ctx.newHandler(sym); var ctx1 = outerCtx.enterHandler(exh); diff --git a/sources/scala/tools/nsc/backend/jvm/GenJVM.scala b/sources/scala/tools/nsc/backend/jvm/GenJVM.scala index 655193dc15..f84b77ae61 100644 --- a/sources/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/sources/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -439,7 +439,15 @@ abstract class GenJVM extends SubComponent { jcode.emitINVOKESPECIAL(owner, javaName(method), javaType(method).asInstanceOf[JMethodType]); + } else + jcode.emitINVOKESTATIC(owner, + javaName(method), + javaType(method).asInstanceOf[JMethodType]); + case SuperCall(_) => + jcode.emitINVOKESPECIAL(owner, + javaName(method), + javaType(method).asInstanceOf[JMethodType]); // we initialize the MODULE$ field immediately after the super ctor if (isTopLevelModule(clasz.symbol) && !isModuleInitialized && jmethod.getName() == JMethod.INSTANCE_CONSTRUCTOR_NAME && @@ -450,15 +458,8 @@ abstract class GenJVM extends SubComponent { MODULE_INSTANCE_NAME, jclass.getType()); } - } else - jcode.emitINVOKESTATIC(owner, - javaName(method), - javaType(method).asInstanceOf[JMethodType]); - case SuperCall(_) => - jcode.emitINVOKESPECIAL(owner, - javaName(method), - javaType(method).asInstanceOf[JMethodType]); + } case CALL_FINALIZER(finalizer) => |