Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add JVM version of HLL::Backend.
- Loading branch information
Showing
1 changed file
with
91 additions
and
0 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # Backend class for the JVM. | ||
| class HLL::Backend::JVM { | ||
| method apply_transcodings($s, $transcode) { | ||
| $s | ||
| } | ||
|
|
||
| method config() { | ||
| nqp::hash() | ||
| } | ||
|
|
||
| method force_gc() { | ||
| nqp::die("Cannot force GC on JVM backend yet"); | ||
| } | ||
|
|
||
| method name() { | ||
| 'jvm' | ||
| } | ||
|
|
||
| method nqpevent($spec?) { | ||
| # Doesn't do anything just yet | ||
| } | ||
|
|
||
| method run_profiled($what) { | ||
| nqp::printfh(nqp::getstderr(), | ||
| "Attach a profiler (e.g. JVisualVM) and press enter"); | ||
| nqp::readlinefh(nqp::getstdin()); | ||
| $what(); | ||
| } | ||
|
|
||
| method run_traced($level, $what) { | ||
| nqp::die("No tracing support"); | ||
| } | ||
|
|
||
| method version_string() { | ||
| "JVM" | ||
| } | ||
|
|
||
| method stages() { | ||
| 'jast classfile jvm' | ||
| } | ||
|
|
||
| method is_precomp_stage($stage) { | ||
| $stage eq 'classfile' | ||
| } | ||
|
|
||
| method is_textual_stage($stage) { | ||
| 0 | ||
| } | ||
|
|
||
| method classname($source, *%adverbs) { | ||
| unless %*COMPILING<%?OPTIONS><javaclass> { | ||
| %*COMPILING<%?OPTIONS><javaclass> := nqp::sha1(nqp::sha1($source) ~ nqp::time_n()); | ||
| } | ||
| $source | ||
| } | ||
|
|
||
| method jast($qast, *%adverbs) { | ||
| nqp::getcomp('qast').jast($qast, :classname(nqp::sha1('eval-at-' ~ nqp::time_n()))); | ||
| } | ||
|
|
||
| method classfile($jast, *%adverbs) { | ||
| if %adverbs<target> eq 'classfile' && %adverbs<output> { | ||
| nqp::compilejasttofile($jast.dump(), %adverbs<output>); | ||
| nqp::null() | ||
| } | ||
| else { | ||
| nqp::compilejast($jast.dump()); | ||
| } | ||
| } | ||
|
|
||
| method jvm($cu, *%adverbs) { | ||
| nqp::loadcompunit($cu) | ||
| } | ||
|
|
||
| method is_compunit($cuish) { | ||
| nqp::iscompunit($cuish) | ||
| } | ||
|
|
||
| method compunit_mainline($cu) { | ||
| nqp::compunitmainline($cu) | ||
| } | ||
|
|
||
| method compunit_coderefs($cu) { | ||
| nqp::compunitcodes($cu) | ||
| } | ||
| } | ||
|
|
||
| # Role specifying the default backend for this build. | ||
| role HLL::Backend::Default { | ||
| method default_backend() { HLL::Backend::JVM } | ||
| } |