Skip to content

Commit

Permalink
Add LLVM::Function for real
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 6, 2011
1 parent eaed6fe commit a3e2d28
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions runtime/parrot/library/LLVM/Function.pm
@@ -0,0 +1,14 @@
class LLVM::Function {
our $counter;
has $!ptr;

method BUILD($ptr) { $!ptr := $ptr; self };

method append_basic_block($name?) {
%LLVM::F<LLVMAppendBasicBlock>($!ptr, $name ?? $name !! "block" ~~ $counter++);
}

method _get_ptr() { $!ptr };
};

# vim: ft=perl6
2 changes: 1 addition & 1 deletion runtime/parrot/library/LLVM/Module.pm
Expand Up @@ -25,7 +25,7 @@ class LLVM::Module {
0, # is var args
);

%LLVM::F<LLVMAddFunction>($!ref, $name, $type);
LLVM::Function.new.BUILD(%LLVM::F<LLVMAddFunction>($!ref, $name, $type));
}

method _get_ptr() { $!ref };
Expand Down
3 changes: 3 additions & 0 deletions t/library/llvm.t
Expand Up @@ -10,8 +10,11 @@ Q:PIR {

my $module := LLVM::Module.new.BUILD("HELLO");
ok(pir::defined($module), "LLVM::Module created");
ok( $module ~~ LLVM::Module, ".. with proper type");

my $function := $module.add_function("hello", "");
ok(pir::defined($function), "Function created");
ok( $function ~~ LLVM::Function, ".. with proper type");

# This will dump to stderr.
$module.dump();
Expand Down

0 comments on commit a3e2d28

Please sign in to comment.