summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2003-05-15 09:01:25 +0000
committerschinz <schinz@epfl.ch>2003-05-15 09:01:25 +0000
commit9b2e927cd8365b232a2f694bc4e39afa4b59bdb0 (patch)
treef321804b444c98bf5a46e66fd961b5316755bc1d /sources
parentc7b62d7913481024cad13cbe5113a0a47473e659 (diff)
downloadscala-9b2e927cd8365b232a2f694bc4e39afa4b59bdb0.tar.gz
scala-9b2e927cd8365b232a2f694bc4e39afa4b59bdb0.tar.bz2
scala-9b2e927cd8365b232a2f694bc4e39afa4b59bdb0.zip
- added generation of line-number information
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/backend/jvm/GenJVM.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/sources/scalac/backend/jvm/GenJVM.java b/sources/scalac/backend/jvm/GenJVM.java
index 2c14a1ca42..072f9564ae 100644
--- a/sources/scalac/backend/jvm/GenJVM.java
+++ b/sources/scalac/backend/jvm/GenJVM.java
@@ -100,6 +100,9 @@ class GenJVM {
public case If(InstructionHandle target, boolean when);
}
+ // Line numbers attribution
+ protected HashMap/*<InstructionHandle,Integer>*/ lineAttributedInstrs;
+
protected void gen(Tree tree) {
gen(tree, cst.T_VOID, InstrContext.Empty);
}
@@ -136,6 +139,14 @@ class GenJVM {
Symbol sym = tree.symbol();
byte generatedType = cst.T_VOID;
+ // Remember first instruction associated to this tree, to
+ // generate line numbers.
+ InstructionHandle startHandle;
+ if (currIL != null)
+ startHandle = currIL.getEnd();
+ else
+ startHandle = null;
+
switch (tree) {
case PackageDef(_, Tree.Template impl):
gen(impl);
@@ -499,6 +510,26 @@ class GenJVM {
|| (generatedType == cst.T_ARRAY
&& expectedType == cst.T_OBJECT)))
genWidenConversion(generatedType, expectedType);
+
+ // Associate line numbers to instructions we just generated.
+ if (currIL != null) {
+ InstructionHandle ih =
+ (startHandle == null ? currIL.getStart() : startHandle);
+ int prevLine = -1;
+ while (ih != null) {
+ if (lineAttributedInstrs.containsKey(ih))
+ prevLine = ((Integer)lineAttributedInstrs.get(ih)).intValue();
+ else {
+ int line = Position.line(tree.pos);
+ lineAttributedInstrs.put(ih, new Integer(line));
+ if (line != prevLine) {
+ currMethod.addLineNumber(ih, line);
+ prevLine = line;
+ }
+ }
+ ih = ih.getNext();
+ }
+ }
}
protected Tree unbox(Tree tree) {
@@ -1274,6 +1305,8 @@ class GenJVM {
currMethod = mGen;
currLocals = locals;
currIL = currMethod.getInstructionList();
+
+ lineAttributedInstrs = new HashMap();
}
protected void leaveMethod() {
@@ -1286,6 +1319,8 @@ class GenJVM {
currMethod = null;
currLocals = null;
currIL = null;
+
+ lineAttributedInstrs = null;
}
protected int modifiersStoJ(int flags) {