Skip to content

Commit c0b439f

Browse files
committed
Sketch in a BlockInfo to track per-block compilation state; tracker outer chain.
1 parent 115c75c commit c0b439f

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

src/QAST/Compiler.nqp

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,34 @@ class QAST::Compiler is HLL::Compiler {
4545
method cur_n() { $!cur_n }
4646
}
4747

48+
# Holds information about the QAST::Block we're currently compiling.
49+
my class BlockInfo {
50+
has $!outer;
51+
52+
method new($outer?) {
53+
my $obj := nqp::create(self);
54+
$obj.BUILD($outer);
55+
$obj
56+
}
57+
58+
method BUILD($outer) {
59+
$!outer := $outer;
60+
}
61+
62+
method outer() {
63+
$!outer
64+
}
65+
66+
method add_param($var) {
67+
}
68+
69+
method add_lexical($var) {
70+
}
71+
72+
method add_local($var) {
73+
}
74+
}
75+
4876
our $serno;
4977
INIT {
5078
$serno := 10;
@@ -66,11 +94,17 @@ class QAST::Compiler is HLL::Compiler {
6694
proto method as_post(*@args, *%_) { * }
6795

6896
multi method as_post(QAST::Block $node) {
69-
# Block gets completely fresh registers.
97+
# Block gets completely fresh registers, and fresh BlockInfo.
7098
my $*REGALLOC := RegAlloc.new();
99+
my $outer := try $*BLOCK;
100+
my $block := BlockInfo.new($outer);
71101

72102
# First need to compile all of the statements.
73-
my $stmts := self.compile_all_the_stmts($node.list);
103+
my $stmts;
104+
{
105+
my $*BLOCK := $block;
106+
$stmts := self.compile_all_the_stmts($node.list);
107+
}
74108

75109
# XXX Generate parameter handling code.
76110
my $params := self.post_new('Ops');

0 commit comments

Comments
 (0)