https://github.com/phase/jvmbg
JVM Bytecode Generator using ASM. Made for compilers.
https://github.com/phase/jvmbg
Last synced: 11 months ago
JSON representation
JVM Bytecode Generator using ASM. Made for compilers.
- Host: GitHub
- URL: https://github.com/phase/jvmbg
- Owner: phase
- Created: 2015-07-29T17:31:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-08T02:14:15.000Z (over 10 years ago)
- Last Synced: 2025-02-03T19:52:35.019Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 239 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#JVM Bytecode Generator
A JVM Bytecode Generator for compilers.
JVMBG offers an easy-to-use API that can work with lazy or normal compilers.
Here's a sample of this awesomeness (*Note: This is a major WIP and won't work as expected right now!*):
```java
//Example
JVMClass clazz = new JVMClass("xyz/jadonfowler/derp/Test"); // public class Test extends java.lang.Object
JVMConstructor constructor = new JVMConstructor(clazz, Modifiers.PUBLIC); // public Test()
// Creates a field called 'field' and sets it to 12
constructor.createField(new Variable(IdentifierType.INT, "field", 12));
clazz.addMethod(constructor); // Finsishes up the constructor bytecode
JVMMethod method = new JVMMethod("test", Modifiers.PUBLIC, Modifiers.STATIC); // public static void test()
method.createLocalVariable(new Variable(IdentifierType.INT, "variable", 7)); // int variable = 7
method.changeLocalVariable("variable", 12);
clazz.addMethod(method); // Finishes up the method bytecode
clazz.build(); // Output class files into local directory
```