Skip to content

Commit

Permalink
Prune optrees after saving units
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jan 17, 2011
1 parent 0fd012e commit b1c6b40
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/Metamodel.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ class StaticSub is RefTarget {
method add_child($z) { push $.zyg, $z }
method children() { @$.zyg }

method clear_optree() {
$.code = Any;
$.ltm = Any;
}

method create_static_pad() {
return Nil if $.spad_exists;
$.spad_exists = True;
Expand Down Expand Up @@ -647,6 +652,10 @@ class Unit {
}
}

method clear_optrees() {
self.visit_local_subs_postorder({ $_.clear_optree })
}

method visit_local_subs_postorder($cb) {
sub rec {
for $_.children { rec($_) }
Expand Down
3 changes: 2 additions & 1 deletion src/NieczaCompiler.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ method !compile($unitname, $filename, $modtime, $source, $main, $run, $end) {
:$filename, :$modtime, :$source); },
(map -> $st { $st.typename => { $ast = $st.invoke($ast) } }, @$.stages),
($.backend.typename ~ "-save") =>
{ $.backend.save_unit($unitname, $ast); $ast = Any },
{ $.backend.save_unit($unitname, $ast);
$ast.clear_optrees; $ast = Any },
($.backend.typename ~ "-post") =>
{ $.backend.post_save($unitname, :$main); },
($.backend.typename ~ "-run") =>
Expand Down

0 comments on commit b1c6b40

Please sign in to comment.