Skip to content

Commit

Permalink
Perlito5 - misc/Java-Asm-Interpreter/MethodExecutorAsm refactor gener…
Browse files Browse the repository at this point in the history
…ateClassName()
  • Loading branch information
fglock committed Aug 1, 2024
1 parent c635ec9 commit 6cbd666
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ public static Class<?> createClassWithMethod(EmitterContext ctx, String[] env, N
// Create a ClassWriter with COMPUTE_FRAMES and COMPUTE_MAXS options for automatic frame and max stack size calculation
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);

if (ctx.javaClassName == null) {
// Generate a unique class name
ctx.javaClassName = generateClassName();
}
// Create a "Java" class name with dots instead of slash
String javaClassNameDot = ctx.javaClassName.replace('/', '.');

// Set the source file name for runtime error messages
Expand All @@ -53,10 +50,6 @@ public static Class<?> createClassWithMethod(EmitterContext ctx, String[] env, N
cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, fieldName, "LRuntime;", null, null).visitEnd();
}

// Set the context type and other context properties
ctx.contextType = ContextType.RUNTIME;
ctx.isBoxed = true;

// Create the class initializer method
ctx.mv = cw.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null);
ctx.mv.visitCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private void handleEvalOperator(UnaryOperatorNode node) throws Exception {
null, // return label
null, // method visitor
ctx.contextType, // call context
false, // is boxed
true, // is boxed
ctx.errorUtil, // error message utility
ctx.debugEnabled
);
Expand Down Expand Up @@ -335,8 +335,8 @@ public void visit(AnonSubNode node) throws Exception {
ctx.symbolTable, // closure symbolTable
null, // return label
null, // method visitor
null, // call context
false, // is boxed
ContextType.RUNTIME, // call context
true, // is boxed
ctx.errorUtil, // error message utility
ctx.debugEnabled
);
Expand Down
4 changes: 2 additions & 2 deletions misc/Java-Asm-Interpreter/MethodExecutorAsm/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public static void main(String[] args) {
new ScopedSymbolTable(), // Top-level symbol table
null, // Return label
null, // Method visitor
null, // Call context
false, // Is boxed
ContextType.SCALAR, // Call context
true, // Is boxed
null, // errorUtil
debugEnabled // debugEnabled flag
);
Expand Down

0 comments on commit 6cbd666

Please sign in to comment.