Skip to content

Commit 68f99e6

Browse files
committed
First crack at lexical lookup; needs a little more work on native handling, but hard to test until NQP's LexPad is updated to handle those.
1 parent 0147855 commit 68f99e6

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/QAST/Compiler.nqp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,25 @@ class QAST::Compiler is HLL::Compiler {
352352
$ops.result($reg);
353353
}
354354
else {
355-
pir::die("Lexical lookup/bind NYI");
355+
# Does the node have a native type marked on it?
356+
my $type := type_to_register_type($node.returns);
357+
if $type eq 'P' {
358+
# Consider the blocks for a declared native type.
359+
# XXX TODO
360+
}
361+
362+
# Emit the lookup or bind.
363+
if $*BINDVAL {
364+
my $valpost := self.coerce(self.as_post($*BINDVAL), nqp::lc($type));
365+
$ops.push($valpost);
366+
$ops.push_pirop('store_lex', self.escape($node.name), $valpost.result);
367+
$ops.result($valpost.result);
368+
}
369+
else {
370+
my $res_reg := $*REGALLOC."fresh_{nqp::lc($type)}"();
371+
$ops.push_pirop('find_lex', $res_reg, self.escape($node.name));
372+
$ops.result($res_reg);
373+
}
356374
}
357375
}
358376
else {

0 commit comments

Comments
 (0)