summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.xml6
-rw-r--r--config/build.default.properties5
-rw-r--r--sources/scala/tools/nsc/ant/NSC.scala14
-rw-r--r--sources/scala/tools/nsc/backend/jvm/GenJVM.scala34
4 files changed, 55 insertions, 4 deletions
diff --git a/build.xml b/build.xml
index 57980f0d03..dff7ed2455 100644
--- a/build.xml
+++ b/build.xml
@@ -216,7 +216,7 @@
unless="skip.nsc"
description="Builds the Scala library with the new Scala compiler.">
<nsc srcdir="${sources.dir}" destdir="${build.nslib.dir}"
- usepredefs="false"
+ usepredefs="false" debuginfo="${nsc.debuginfo}"
stop="${nsc.stop}" skip="${nsc.skip}" check="${nsc.check}" log="${nsc.log}"
logging="${nsc.logging}">
<classpath>
@@ -230,7 +230,7 @@
<include name="scala/runtime/ScalaRunTime.scala"/>
</nsc>
<nsc srcdir="${sources.dir}" destdir="${build.nslib.dir}"
- excludesfile="${nsc.nslib.excludes}"
+ excludesfile="${nsc.nslib.excludes}" debuginfo="${nsc.debuginfo}"
stop="${nsc.stop}" skip="${nsc.skip}" check="${nsc.check}" log="${nsc.log}"
logging="${nsc.logging}">
<classpath>
@@ -251,7 +251,7 @@
unless="skip.nsc"
description="Builds the Scala tools (NSC and Scalap) with the new Scala compiler.">
<nsc srcdir="${sources.dir}" destdir="${build.nstools.dir}"
- excludesfile="${nsc.nstools.excludes}"
+ excludesfile="${nsc.nstools.excludes}" debuginfo="${nsc.debuginfo}"
stop="${nsc.stop}" skip="${nsc.skip}" check="${nsc.check}" log="${nsc.log}"
logging="${nsc.logging}">
<classpath>
diff --git a/config/build.default.properties b/config/build.default.properties
index 61c222aa36..f803b45862 100644
--- a/config/build.default.properties
+++ b/config/build.default.properties
@@ -40,6 +40,11 @@ nsc.nstools.excludes=${config.dir}/excludes/nsc.nstools.excludes
# the new Scala tools. This file MUST EXIST.
nsc.osc-nstools.excludes=${config.dir}/excludes/nsc.osc-nstools.excludes
+# Boolean flag that controls whether the NSC compiler will generate
+# debug information in class files
+nsc.debuginfo=true
+
+
# LOCATION OF PRE-COMPILED LIBRARIES
##############################################################################
diff --git a/sources/scala/tools/nsc/ant/NSC.scala b/sources/scala/tools/nsc/ant/NSC.scala
index 1125bb500c..008958857c 100644
--- a/sources/scala/tools/nsc/ant/NSC.scala
+++ b/sources/scala/tools/nsc/ant/NSC.scala
@@ -52,8 +52,9 @@ package scala.tools.nsc.ant {
* <li>stop,</li>
* <li>skip,</li>
* <li>check,</li>
- * <li>showicode.</li>
+ * <li>showicode,</li>
* <li>log,</li>
+ * <li>debuginfo.</li>
* </ul>
* It also takes the following parameters as nested elements:<ul>
* <li>src (for srcdir),</li>
@@ -135,6 +136,10 @@ package scala.tools.nsc.ant {
/** Print ICode files along with class files (debug option). */
private var showICode: Boolean = false;
+ /** Instruct the compiler to generate debugging information (pass '-g') */
+ private var debugInfo: Boolean = false;
+
+
// ###################################################################
// ##### Properties setters #####
// ###################################################################
@@ -435,6 +440,12 @@ package scala.tools.nsc.ant {
def setShowicode(input: Boolean): Unit =
showICode = input;
+ /**
+ * Set the debug info attribute.
+ */
+ def setDebuginfo(input: Boolean): Unit =
+ debugInfo = input;
+
// ###################################################################
// ##### Compilation and support methods #####
// ###################################################################
@@ -588,6 +599,7 @@ package scala.tools.nsc.ant {
if (!skip.isEmpty) settings.skip.value = skip;
if (!check.isEmpty) settings.check.value = check;
settings.Xshowicode.value = showICode;
+ settings.debuginfo.value = debugInfo;
if (!logPhase.isEmpty) settings.log.value = logPhase;
// Sets path properties to prevent ClassPath from being corrupted.
diff --git a/sources/scala/tools/nsc/backend/jvm/GenJVM.scala b/sources/scala/tools/nsc/backend/jvm/GenJVM.scala
index f2ac6135bb..fc9bd73608 100644
--- a/sources/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/sources/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -161,6 +161,7 @@ abstract class GenJVM extends SubComponent {
jcode = jmethod.getCode().asInstanceOf[JExtendedCode];
genCode(m);
+ genLocalVariableTable;
}
}
@@ -898,6 +899,39 @@ abstract class GenJVM extends SubComponent {
settings.outdir.value + File.separatorChar + path + suffix
}
+
+ private def genLocalVariableTable: Unit = {
+ val vars: Array[JLocalVariable] = jmethod.getLocalVariables();
+
+ if (!settings.debuginfo.value || vars.length == 0)
+ return;
+
+ val pool = jclass.getConstantPool();
+ val pc = jcode.getPC();
+ var anonCounter = 0;
+
+ val lvTab = java.nio.ByteBuffer.allocate(2 + 10 * vars.length);
+ lvTab.putShort(vars.length.asInstanceOf[Short]);
+ for (val lv <- vars) {
+ val name = if (lv.getName() == null) {
+ anonCounter = anonCounter + 1;
+ "<anon" + anonCounter + ">"
+ } else lv.getName();
+
+ lvTab.putShort(0.asInstanceOf[Short]);
+ lvTab.putShort(pc.asInstanceOf[Short]);
+ lvTab.putShort(pool.addUtf8(name).asInstanceOf[Short]);
+ lvTab.putShort(pool.addUtf8(lv.getType().getSignature()).asInstanceOf[Short]);
+ lvTab.putShort(lv.getIndex().asInstanceOf[Short]);
+ }
+ val attr =
+ fjbgContext.JOtherAttribute(jclass,
+ jmethod,
+ "LocalVariableTable",
+ lvTab.array());
+ jcode.addAttribute(attr);
+ }
+
}
}