Skip to content

Commit

Permalink
Merge branch 'PackfileView' into target-pbc
Browse files Browse the repository at this point in the history
Conflicts:
	src/HLL/Compiler.pm
	src/NQP/World.pm
	src/QRegex/Cursor.nqp
	src/Regex/Cursor.pir
  • Loading branch information
gerdr committed Feb 16, 2013
2 parents d579a30 + d3a9cc2 commit ca1ba8c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
17 changes: 15 additions & 2 deletions src/HLL/Compiler.pm
Expand Up @@ -149,7 +149,17 @@ class HLL::Compiler {
pir::set_runcore__0s("subprof_hll");
}
pir::trace__vI(%adverbs<trace>);
$output := $output(|@args);

# Execute :init subs
if !$output.is_initialized('init') {
for $output.subs_by_tag('init') -> $sub { $sub(); }
$output.mark_initialized('init');
}

# Now execute the :main sub
my $main_sub := $output.main_sub();
$output := $main_sub(|@args);

pir::trace__0i(0);
}
pir::set_runcore__vs($old_runcore);
Expand Down Expand Up @@ -427,7 +437,10 @@ class HLL::Compiler {

method evalpmc($source, *%adverbs) {
my $compiler := pir::compreg__Ps('PIR');
$compiler($source)
my $packfile := $compiler.compile($source);
for $packfile.subs_by_tag('init') -> $sub { $sub(); }
$packfile.mark_initialized('init');
$packfile
}

method dumper($obj, $name, *%options) {
Expand Down
16 changes: 9 additions & 7 deletions src/NQP/World.pm
Expand Up @@ -243,23 +243,24 @@ class NQP::World is HLL::World {
my $compiled := $nqpcomp.evalpmc($pir);

# Fix up any code objects holding stubs with the real compiled thing.
my $c := nqp::elems($compiled);
my @all_subs := $compiled.all_subs();
my $c := nqp::elems(@all_subs);
my $i := 0;
while $i < $c {
my $subid := $compiled[$i].get_subid();
my $subid := @all_subs[$i].get_subid();
if nqp::existskey(%!code_objects_to_fix_up, $subid) {
# First, go over the code objects. Update the $!do, and the
# entry in the SC. Make sure the newly compiled code is marked
# as a static code ref.
my $static := %!code_objects_to_fix_up{$subid}.shift();
nqp::bindattr($static, %!code_object_types{$subid}, '$!do', $compiled[$i]);
nqp::bindattr($static, %!code_object_types{$subid}, '$!do', @all_subs[$i]);
nqp::bindattr($static, %!code_object_types{$subid}, '$!clone_callback', nqp::null());
for %!code_objects_to_fix_up{$subid} {
nqp::bindattr($_, %!code_object_types{$subid}, '$!do', nqp::clone($compiled[$i]));
nqp::bindattr($_, %!code_object_types{$subid}, '$!do', nqp::clone(@all_subs[$i]));
nqp::bindattr($_, %!code_object_types{$subid}, '$!clone_callback', nqp::null());
}
pir::setprop__vPsP($compiled[$i], 'STATIC_CODE_REF', $compiled[$i]);
self.update_root_code_ref(%!code_stub_sc_idx{$subid}, $compiled[$i]);
pir::setprop__vPsP(@all_subs[$i], 'STATIC_CODE_REF', @all_subs[$i]);
self.update_root_code_ref(%!code_stub_sc_idx{$subid}, @all_subs[$i]);

# Clear up the fixup statements.
my $fixup_stmts := %!code_object_fixup_list{$subid};
Expand All @@ -268,7 +269,8 @@ class NQP::World is HLL::World {
$i := $i + 1;
}

$compiled(|@args, |%named);
my $main_sub := $compiled.main_sub();
$main_sub(|@args, |%named);
};

# Create code object, if we'll need one.
Expand Down
2 changes: 1 addition & 1 deletion src/QRegex/Cursor.nqp
Expand Up @@ -733,7 +733,7 @@ class NQPCursor does NQPCursorRole {
$var := $res;
}
else {
$var := $rxcompiler.compile($var);
$var := $rxcompiler.compile($var).main_sub();
}
}
return self.'!INTERPOLATE'($var);
Expand Down
2 changes: 1 addition & 1 deletion t/qregex/01-qregex.t
Expand Up @@ -45,7 +45,7 @@ sub test_line($line) {

my $rxcomp := pir::compreg__Ps('QRegex::P6Regex');
try {
my $rxsub := $rxcomp.compile($regex);
my $rxsub := $rxcomp.compile($regex).main_sub();
my $cursor := NQPCursor."!cursor_init"($target, :c(0));
my $match := $rxsub($cursor).MATCH;
if $expect_substr {
Expand Down

0 comments on commit ca1ba8c

Please sign in to comment.