Tagged: compiler

Compiler generator using method inlining

It should be possible to write a language interpreter on top of Java or .NET and rely on method inlining to instantly get compiled code. Implement most of your interpreter opcodes as small static methods: Add, Subtract, LessThan, etc. Translate your language into Java/C# methods that call these opcodes. When the JIT sees all these small static methods, it should inline and optimize them. Presto! You’ve just written a compiler. It’s a bit like using¬†partial evaluation to generate a compiler from an interpreter. I think Peter Sestof did this the hard way¬†a long time ago.