Skip to content

Commit 07ab3c7

Browse files
committed
Sketch out 'bind' op; since it's sensitive to the variable type, the real work on this will be done by the QAST::Var processor.
1 parent 8ee175e commit 07ab3c7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/QAST/Compiler.nqp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class QAST::Compiler is HLL::Compiler {
143143
# Block gets completely fresh registers, and fresh BlockInfo.
144144
my $*REGALLOC := RegAlloc.new();
145145
my $*BLOCKRA := $*REGALLOC;
146+
my $*BINDVAL := 0;
146147
my $outer := try $*BLOCK;
147148
my $block := BlockInfo.new($outer);
148149

src/QAST/Operations.nqp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,23 @@ for <if unless> -> $op_name {
176176
});
177177
}
178178

179+
# Binding
180+
QAST::Operations.add_core_op('bind', -> $qastcomp, $op {
181+
# Sanity checks.
182+
my @children := $op.list;
183+
if +@children != 2 {
184+
pir::die("A 'bind' op must have exactly two children");
185+
}
186+
unless nqp::istype(@children[0], QAST::Var) {
187+
pir::die("First child of a 'bind' op must be a QAST::Var");
188+
}
189+
190+
# Set the QAST of the think we're to bind, then delegate to
191+
# the compilation of the QAST::Var to handle the rest.
192+
my $*BINDVAL := @children[1];
193+
$qastcomp.as_post(@children[0])
194+
});
195+
179196
# Straight mappings to Parrot opcodes.
180197
QAST::Operations.add_core_pirop_mapping('add_i', 'add', 'Iii');
181198
QAST::Operations.add_core_pirop_mapping('neg_i', 'neg', 'Ii');

0 commit comments

Comments
 (0)