-
-
Save niner/938c307ba8313788cdf9d383dedb4ce3 to your computer and use it in GitHub Desktop.
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
method to_mast($qast, %mast_frames = nqp::hash()) { | |
# Set up compilation state. | |
my $profile := nqp::existskey(nqp::getenvhash(), 'PROFILEMBC') && nqp::istype($qast, QAST::CompUnit) && $qast.compilation_mode && !$qast.is_nested; | |
nqp::mvmstartprofile(nqp::hash('kind', 'instrumented')) if $profile; | |
$!hll := ''; | |
my $string-heap := MoarVM::StringHeap.new(); | |
my $callsites := MoarVM::Callsites.new(:$string-heap); | |
my $annotations := $buf.new; | |
$!writer := MoarVM::BytecodeWriter.new(:$string-heap, :$callsites, :$annotations); | |
$!mast_compunit := MAST::CompUnit.new(:$!writer); | |
$!writer.set-compunit($!mast_compunit); | |
%!mast_frames := %mast_frames; | |
$!file := nqp::ifnull(nqp::getlexdyn('$?FILES'), "<unknown file>"); | |
$!sc := NQPMu; | |
# Compile, and evaluate to compilation unit. | |
self.as_mast($qast); | |
HLL::Backend::MoarVM.dump_instrumented_profile_data(nqp::mvmendprofile, nqp::null) if $profile; | |
#CATCH { | |
# my $err := $!; | |
# my $source := self.source_for_node($!last_op); | |
# nqp::die("QAST -> MAST failed while compiling op " ~ $!last_op.op ~ "$source: $err"); | |
#} | |
$!mast_compunit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment