Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add JVM version of HLL::Backend.
  • Loading branch information
jnthn committed Apr 14, 2013
1 parent 95903d5 commit cee4c7e
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions src/vm/jvm/HLL/Backend.nqp
@@ -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 }
}

0 comments on commit cee4c7e

Please sign in to comment.