Compile snippets into bytecode in assembler
See original GitHub issueCompile snippets into bytecode in assembler
The idea is to allow users to open a method assembler, then open a prompt allowing them to type in something like System.out.println("test")
. This line would then be compiled against the current source and inserted into the assembler as lines of method bytecode.
It would be nice to support arbitrary variable support too, such as: if ($0 != 0){}
--> *LOAD 0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12 (8 by maintainers)
Top Results From Across the Web
How to translate assembly code snippet into binary machine ...
I did a workaround to my problem. It works on Windows platforms and uses ML64 assembler that goes with Visual Studio.
Read more >Know Your Stack — Scala to Java to Bytecode to Assembly
A JVM takes bytecode and JITs it to machine code at runtime. It will even compile hot code that is being JITd frequently....
Read more >RAVM: compile once and run anywhere - zsmith.co
a simple assembler (RASM) that produces bytecode, which is to say the virtual machine language that RAVM runs. What is the justification for...
Read more >Delphi bytecode compiler - Jon L. Aasenden - WordPress.com
I decided to do something a bit novel. Rather than just creating some classes to help you generate bytecode, I decided to create...
Read more >Building Compilers and Interpreters - Open Book Project
and an "assembler" program would translate this into machine code (just ... Python first compiles source code in a .py file into "byte...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Could be improved, but variable support is in!
Need to get some proper unit tests made too…
No it can’t - at least, not in its current state. After some digging however, I believe its possible to make it work without major modifications.
Javassist has a complete lexer/parser/bytecode-generator system just built for this, like a lightweight version of JavaParser. It will first parse the statement using a pre-populated symbol table and generate an AST tree representation. Then the corresponding bytecode will be emitted at the various
at***
methods inCodeGen
,MemberCodeGen
andJvstCodeGen
. One of these methods,atVariable
, goes like this:As you can see, this kind of structuring makes it easy to implement our own bytecode emitter that works on the stack. We won’t even need to change the pesky parser part (except here), just feed it some type info about things-on-stack through the symbol table and write some custom
at***
generators and it magically works. At least, it should. Never done this before but don’t see why it shouldn’t - a value is a value, no matter whether it comes from a variable or the stack. It won’t be ‘piece of cake’ level of easy, but it should work.