-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lua4jvm: Add debug information generated classes
In other words, stack traces now show function names and line numbers!
- Loading branch information
Showing
17 changed files
with
267 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
lua4jvm/src/main/java/fi/benjami/code4jvm/lua/compiler/LuaContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
lua4jvm/src/main/java/fi/benjami/code4jvm/lua/ir/DebugInfoNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package fi.benjami.code4jvm.lua.ir; | ||
|
||
import fi.benjami.code4jvm.Value; | ||
import fi.benjami.code4jvm.block.Block; | ||
import fi.benjami.code4jvm.lua.compiler.LuaContext; | ||
import fi.benjami.code4jvm.statement.DebugInfo; | ||
|
||
/** | ||
* Emits debug information such as line numbers to generated bytecode. | ||
* Debug info nodes should not otherwise affect execution of code! | ||
* | ||
*/ | ||
public record DebugInfoNode( | ||
int lineNumber, | ||
IrNode node | ||
) implements IrNode { | ||
|
||
@Override | ||
public Value emit(LuaContext ctx, Block block) { | ||
block.add(DebugInfo.lineNumber(lineNumber)); | ||
return node.emit(ctx, block); | ||
} | ||
|
||
@Override | ||
public LuaType outputType(LuaContext ctx) { | ||
return node.outputType(ctx); | ||
} | ||
|
||
@Override | ||
public boolean hasReturn() { | ||
return node.hasReturn(); | ||
} | ||
|
||
@Override | ||
public IrNode concreteNode() { | ||
return node.concreteNode(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
lua4jvm/src/main/java/fi/benjami/code4jvm/lua/ir/LuaModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package fi.benjami.code4jvm.lua.ir; | ||
|
||
public record LuaModule( | ||
String name, | ||
LuaBlock root, | ||
LuaLocalVar env | ||
) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.