Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
whiteknight's PackfileView patch, with whitespace and stage0 changes …
…removed
  • Loading branch information
diakopter committed May 13, 2012
1 parent 9ddfc35 commit d3a9cc2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
17 changes: 15 additions & 2 deletions src/HLL/Compiler.pm
Expand Up @@ -217,7 +217,17 @@ class HLL::Compiler {
pir::set_runcore__vs("subprof_hll");
}
pir::trace(%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(0);
}
pir::set_runcore__vs($old_runcore);
Expand Down Expand Up @@ -479,7 +489,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 @@ -199,21 +199,22 @@ 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 pir::exists(%!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_type, '$!do', $compiled[$i]);
nqp::bindattr($static, $code_type, '$!do', @all_subs[$i]);
for %!code_objects_to_fix_up{$subid} {
nqp::bindattr($_, $code_type, '$!do', pir::clone($compiled[$i]));
nqp::bindattr($_, $code_type, '$!do', pir::clone(@all_subs[$i]));
}
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 @@ -222,7 +223,8 @@ class NQP::World is HLL::World {
$i := $i + 1;
}

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

# See if we already have our compile-time dummy. If not, create it.
Expand Down
4 changes: 2 additions & 2 deletions src/QRegex/Cursor.nqp
Expand Up @@ -485,12 +485,12 @@ class NQPCursor does NQPCursorRole {
for $var {
my $elem := $_;
$elem := $rxcompiler.compile($elem) unless pir::is_invokable__IP($elem);
nqp::push($res, $elem);
nqp::push($res, $elem.main_sub());
}
$var := $res;
}
else {
$var := $rxcompiler.compile($var);
$var := $rxcompiler.compile($var).main_sub();
}
}
return self.'!INTERPOLATE'($var);
Expand Down
2 changes: 2 additions & 0 deletions src/Regex/Cursor.pir
Expand Up @@ -1231,6 +1231,7 @@ are first compiled to regexes prior to being matched.
$I0 = does var, 'array'
if $I0 goto var_array
var = p6regex.'compile'(var)
var = var.'main_sub'()
goto done

var_array:
Expand All @@ -1243,6 +1244,7 @@ are first compiled to regexes prior to being matched.
$I0 = is_invokable elem
if $I0 goto var_next
elem = p6regex.'compile'(elem)
elem = elem.'main_sub'()
var_next:
push var, elem
goto var_loop
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 d3a9cc2

Please sign in to comment.