Skip to content

Commit 16319cd

Browse files
committed
Start sketching out QAST::Var; not enough to do anything useful yet.
1 parent c0b439f commit 16319cd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/QAST/Compiler.nqp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,37 @@ class QAST::Compiler is HLL::Compiler {
147147
QAST::Operations.compile_op(self, '', $node)
148148
}
149149

150+
multi method as_post(QAST::Var $node) {
151+
my $scope := $node.scope;
152+
my $decl := $node.decl;
153+
154+
# Handle any declarations; after this, we call through to the
155+
# lookup code.
156+
if $decl {
157+
# If it's a parameter, add it to the things we should bind
158+
# at block entry.
159+
if $node.decl eq 'param' {
160+
$*BLOCK.add_param($node);
161+
}
162+
elsif $decl ne 'var' {
163+
pir::die("Don't understand declaration type '$decl'");
164+
}
165+
166+
# Register storage.
167+
if $scope eq 'local' {
168+
$*BLOCK.add_local($node);
169+
}
170+
elsif $scope eq 'lexical' {
171+
$*BLOCK.add_lexical($node);
172+
}
173+
else {
174+
pir::die("Cannot declare $decl of scope '$scope'; use 'local' or 'lexical'");
175+
}
176+
}
177+
178+
pir::die("QAST::Var NYI");
179+
}
180+
150181
multi method as_post(QAST::IVal $node) {
151182
self.post_new('Ops', :result(~$node.value))
152183
}

0 commit comments

Comments
 (0)