aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/compiler/Javac.java
diff options
context:
space:
mode:
authorakuznetsov <akuznetsov@tradingview.com>2023-09-26 15:57:53 +0400
committerakuznetsov <akuznetsov@tradingview.com>2023-10-04 14:06:05 +0400
commitd5a7881381080fa4953b24c069675ca435598b95 (patch)
tree7a94b14981dde07f72068b1bb0704e7b4c2f3fc8 /src/main/javassist/compiler/Javac.java
parent700be6f6f9546e8af049b1a763ce27f1fde5955d (diff)
downloadjavassist-d5a7881381080fa4953b24c069675ca435598b95.tar.gz
javassist-d5a7881381080fa4953b24c069675ca435598b95.zip
add line numbers and test
Diffstat (limited to 'src/main/javassist/compiler/Javac.java')
-rw-r--r--src/main/javassist/compiler/Javac.java38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/main/javassist/compiler/Javac.java b/src/main/javassist/compiler/Javac.java
index 084487b4..6e67ab66 100644
--- a/src/main/javassist/compiler/Javac.java
+++ b/src/main/javassist/compiler/Javac.java
@@ -43,7 +43,7 @@ import javassist.compiler.ast.Stmnt;
import javassist.compiler.ast.Symbol;
public class Javac {
- JvstCodeGen gen;
+ JvstCodeGenWitlLineNumber gen;
SymbolTable stable;
private Bytecode bytecode;
@@ -71,7 +71,7 @@ public class Javac {
* belongs to.
*/
public Javac(Bytecode b, CtClass thisClass) {
- gen = new JvstCodeGen(b, thisClass, thisClass.getClassPool());
+ gen = new JvstCodeGenWitlLineNumber(b, thisClass, thisClass.getClassPool());
stable = new SymbolTable();
bytecode = b;
}
@@ -160,8 +160,9 @@ public class Javac {
gen.getThisClass());
cons.setModifiers(mod);
md.accept(gen);
- cons.getMethodInfo().setCodeAttribute(
- bytecode.toCodeAttribute());
+ CodeAttribute cattr = bytecode.toCodeAttribute();
+ cattr.setAttribute(gen.toLineNumberAttribute());
+ cons.getMethodInfo().setCodeAttribute(cattr);
cons.setExceptionTypes(tlist);
return cons;
}
@@ -173,10 +174,11 @@ public class Javac {
method.setModifiers(mod);
gen.setThisMethod(method);
md.accept(gen);
- if (md.getBody() != null)
- method.getMethodInfo().setCodeAttribute(
- bytecode.toCodeAttribute());
- else
+ if (md.getBody() != null) {
+ CodeAttribute cattr = bytecode.toCodeAttribute();
+ cattr.setAttribute(gen.toLineNumberAttribute());
+ method.getMethodInfo().setCodeAttribute(cattr);
+ } else
method.setModifiers(mod | Modifier.ABSTRACT);
method.setExceptionTypes(tlist);
@@ -446,11 +448,11 @@ public class Javac {
public void doit(JvstCodeGen gen, Bytecode b, ASTList args)
throws CompileError
{
- ASTree expr = new Member(m);
+ ASTree expr = new Member(m, texpr.getLineNumber());
if (texpr != null)
- expr = Expr.make('.', texpr, expr);
+ expr = Expr.make('.', texpr, expr, texpr.getLineNumber());
- expr = CallExpr.makeCall(expr, args);
+ expr = CallExpr.makeCall(expr, args, texpr.getLineNumber());
gen.compileExpr(expr);
gen.addNullIfVoid();
}
@@ -459,11 +461,11 @@ public class Javac {
public void setReturnType(JvstTypeChecker check, ASTList args)
throws CompileError
{
- ASTree expr = new Member(m);
+ ASTree expr = new Member(m, texpr.getLineNumber());
if (texpr != null)
- expr = Expr.make('.', texpr, expr);
+ expr = Expr.make('.', texpr, expr, texpr.getLineNumber());
- expr = CallExpr.makeCall(expr, args);
+ expr = CallExpr.makeCall(expr, args, texpr.getLineNumber());
expr.accept(check);
check.addNullIfVoid();
}
@@ -493,8 +495,8 @@ public class Javac {
throws CompileError
{
Expr expr = Expr.make(TokenId.MEMBER,
- new Symbol(c), new Member(m));
- expr = CallExpr.makeCall(expr, args);
+ new Symbol(c, args.getLineNumber()), new Member(m, args.getLineNumber()), args.getLineNumber());
+ expr = CallExpr.makeCall(expr, args, args.getLineNumber());
gen.compileExpr(expr);
gen.addNullIfVoid();
}
@@ -504,8 +506,8 @@ public class Javac {
throws CompileError
{
Expr expr = Expr.make(TokenId.MEMBER,
- new Symbol(c), new Member(m));
- expr = CallExpr.makeCall(expr, args);
+ new Symbol(c, args.getLineNumber()), new Member(m, args.getLineNumber()), args.getLineNumber());
+ expr = CallExpr.makeCall(expr, args, args.getLineNumber());
expr.accept(check);
check.addNullIfVoid();
}