diff options
author | schinz <schinz@epfl.ch> | 2004-11-29 10:13:03 +0000 |
---|---|---|
committer | schinz <schinz@epfl.ch> | 2004-11-29 10:13:03 +0000 |
commit | 84094a0101e57a368ed1f681022c5fe5eeaa373c (patch) | |
tree | 3e52eccfafc4f400eb20ae98730703813c15e27b /sources | |
parent | 6862dacb9f3d0402030513a2f383cf68dce4b269 (diff) | |
download | scala-84094a0101e57a368ed1f681022c5fe5eeaa373c.tar.gz scala-84094a0101e57a368ed1f681022c5fe5eeaa373c.tar.bz2 scala-84094a0101e57a368ed1f681022c5fe5eeaa373c.zip |
- generate local variable table (patch submitte...
- generate local variable table (patch submitted by Ross Judson
<rjudson@managedobjects.com>) when the "-g" switch is specified
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scalac/backend/jvm/GenJVM.java | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/sources/scalac/backend/jvm/GenJVM.java b/sources/scalac/backend/jvm/GenJVM.java index da20f9a63b..2a7c4f5c52 100644 --- a/sources/scalac/backend/jvm/GenJVM.java +++ b/sources/scalac/backend/jvm/GenJVM.java @@ -158,6 +158,7 @@ class GenJVM { ctx1.withMethod(clinit, Collections.EMPTY_MAP, false); completeClassConstructor(ctx2, sym); ctx2.code.emitRETURN(); + genLocalVariableTable(ctx2); } leaveClass(ctx1, sym); @@ -1567,6 +1568,37 @@ class GenJVM { Position.line(tree.pos)); } + protected void genLocalVariableTable(Context ctx) { + JLocalVariable[] vars = ctx.method.getLocalVariables(); + + if (!global.debuginfo || vars.length == 0) + return; + + JConstantPool pool = ctx.clazz.getConstantPool(); + int pc = ctx.code.getPC(); + int anonCounter = 1; + + ByteBuffer lvTab = ByteBuffer.allocate(2 + 10 * vars.length); + lvTab.putShort((short)vars.length); + for (int i = 0; i < vars.length; i++) { + JLocalVariable lv = vars[i]; + String name = (lv.getName() == null) + ? "<anon" + (anonCounter++) + ">" : lv.getName(); + lvTab.putShort((short)0); + lvTab.putShort((short)pc); + lvTab.putShort((short)pool.addUtf8(name)); + lvTab.putShort((short)pool.addUtf8(lv.getType().getSignature())); + lvTab.putShort((short)lv.getIndex()); + } + JAttribute attr = + fjbgContext.JOtherAttribute(ctx.clazz, + ctx.method, + "LocalVariableTable", + lvTab.array()); + ctx.code.addAttribute(attr); + } + + /// Context ////////////////////////////////////////////////////////////////////// @@ -1668,8 +1700,8 @@ class GenJVM { JConstantPool cp = ctx.clazz.getConstantPool(); int reInx = cp.addClass(JAVA_RMI_REMOTEEXCEPTION); ByteBuffer contents = ByteBuffer.allocate(4); // u2 + u2[1] - contents.putShort((short) 1); - contents.putShort((short) reInx); + contents.putShort((short)1); + contents.putShort((short)reInx); global.log("adding 'Exceptions_attribute' " + contents.toString() + " for remote method " + mSym.name.toString()); method.addAttribute(fjbgContext.JOtherAttribute(ctx.clazz, @@ -1682,6 +1714,7 @@ class GenJVM { } protected void leaveMethod(Context ctx) { + genLocalVariableTable(ctx); global.log("leaving method"); } |