-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make captured scopes available in debug output
- Loading branch information
1 parent
6fd3c81
commit 0ad140c
Showing
4 changed files
with
135 additions
and
3 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
8 changes: 8 additions & 0 deletions
8
luceedebug/src/main/java/luceedebug/coreinject/ClosureScopeLocalScopeAccessorShim.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,8 @@ | ||
package luceedebug.coreinject; | ||
|
||
/** | ||
* Intended to be an extension on lucee.runtime.type.scope.ClosureScope, applied during classfile rewrites during agent startup. | ||
*/ | ||
public interface ClosureScopeLocalScopeAccessorShim { | ||
lucee.runtime.type.scope.Scope getLocalScope(); | ||
} |
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
44 changes: 44 additions & 0 deletions
44
luceedebug/src/main/java/luceedebug/instrumenter/ClosureScope.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,44 @@ | ||
package luceedebug.instrumenter; | ||
|
||
import org.objectweb.asm.*; | ||
import org.objectweb.asm.commons.GeneratorAdapter; | ||
|
||
/** | ||
* extend lucee.runtime.type.scope.ClosureScope to implement ClosureScopeLocalScopeAccessorShim | ||
*/ | ||
|
||
public class ClosureScope extends ClassVisitor { | ||
public ClosureScope(int api, ClassWriter cw) { | ||
super(api, cw); | ||
} | ||
|
||
@Override | ||
public void visit( | ||
int version, | ||
int access, | ||
String name, | ||
String signature, | ||
String superName, | ||
String[] interfaces | ||
) { | ||
final var augmentedInterfaces = new String[interfaces.length + 1]; | ||
for (int i = 0; i < interfaces.length; i++) { | ||
augmentedInterfaces[i] = interfaces[i]; | ||
} | ||
augmentedInterfaces[interfaces.length] = "luceedebug/coreinject/ClosureScopeLocalScopeAccessorShim"; | ||
|
||
super.visit(version, access, name, signature, superName, augmentedInterfaces); | ||
} | ||
|
||
@Override | ||
public void visitEnd() { | ||
final var name = "getLocalScope"; | ||
final var descriptor = "()Llucee/runtime/type/scope/Scope;"; | ||
final var mv = visitMethod(org.objectweb.asm.Opcodes.ACC_PUBLIC, name, descriptor, null, null); | ||
final var ga = new GeneratorAdapter(mv, org.objectweb.asm.Opcodes.ACC_PUBLIC, name, descriptor); | ||
ga.loadThis(); | ||
ga.getField(org.objectweb.asm.Type.getType("Llucee/runtime/type/scope/ClosureScope;"), "local", org.objectweb.asm.Type.getType("Llucee/runtime/type/scope/Local;")); | ||
ga.returnValue(); | ||
ga.endMethod(); | ||
} | ||
} |