diff --git a/compilers/opsc/src/Ops/Trans/JIT.pm b/compilers/opsc/src/Ops/Trans/JIT.pm index 69e4675136..6d05dd4cfe 100644 --- a/compilers/opsc/src/Ops/Trans/JIT.pm +++ b/compilers/opsc/src/Ops/Trans/JIT.pm @@ -70,7 +70,34 @@ our method access_arg:type ($num, %ctx) { method goto_offset($offset, %ctx) { #"return (opcode_t *)cur_opcode + $offset"; - 'goto L' ~ (%ctx + $offset); + #'goto L' ~ (%ctx + $offset); + my $target := %ctx + $offset; + my $jump_to := %ctx{$target}; + + pir::die("No target found") unless pir::defined($jump_to); + pir::die("Crappy target") unless $jump_to ~~ LLVM::BasicBlock; + + # TODO Handle non-existing block. + my $builder := %ctx; + $builder.br($jump_to); + + # Preserve interace contract. + 'goto L' ~ $target; +} + +method goto_address($address, %ctx) { + # XXX Actually handle goto + my $builder := %ctx; + my $retval := %ctx; + $builder.store( + LLVM::Constant::null( + LLVM::Type::pointer(LLVM::Type::int32()) + ), + $retval, + ); + $builder.br(%ctx); + + ""; } =item opcode_at