Skip to content

Commit

Permalink
Handle some variable declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 31, 2011
1 parent 0052c45 commit ba48854
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions compilers/opsc/src/Ops/JIT.pm
Expand Up @@ -399,6 +399,23 @@ our multi method process(PAST::Val $val, %c) {
our multi method process(PAST::Var $var, %c) {
my $res;
if $var.isdecl {
# There is some challanges here.
# .vivibase can be:
# 1. Native type. E.g. "int".
# 2. Typedefed native type. E.g. "opcode_t".
# 3. Struct (pointer)
my $vivibase := subst($var.vivibase, / \s* $/, '');
$!debug && say("# Variable '$vivibase'");

# Assume that all types have constructor in LLVM::Type.
my $ctor := pir::get_hll_global__pps(<LLVM Type>, $vivibase);
my $type := $ctor();
if $var<pointer> {
$type := LLVM::Type::pointer($type);
}

my $res := $!builder.alloca($type, :name($var.name));
%c<variables>{ $var.name } := $res;
}
else {
if $var.scope eq 'register' {
Expand Down
2 changes: 1 addition & 1 deletion t/jit/jitted.ops
Expand Up @@ -29,7 +29,7 @@ op say(in INT) :base_io {
op say(in STR) :base_io {
STRING * const s = $1;
/* if (s && s->bufused) */
if ($1)
if (s)
Parrot_io_printf(interp, "%Ss", $1);
Parrot_io_printf(interp, "\n");
}
Expand Down
2 changes: 1 addition & 1 deletion t/jit/test.t
Expand Up @@ -53,10 +53,10 @@ say("================= INVOKE ===================");
$pc := $call($pc, $interp);
say("================= DONE ===================");

#%jit_context<_module>.dump();

sub func($name, $sig) {
pir::dlfunc__ppss(undef, $name, $sig);
}

#%jit_context<_module>.dump();
# vim: ft=perl6

0 comments on commit ba48854

Please sign in to comment.