Skip to content

Commit

Permalink
Migrate Function and BasicBlock to be Opaque
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 7, 2011
1 parent 2ae9971 commit 3f98103
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
8 changes: 2 additions & 6 deletions runtime/parrot/library/LLVM/BasicBlock.pm
@@ -1,9 +1,5 @@
class LLVM::BasicBlock {
has $!ref;

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

method _get_ptr() { $!ref };
class LLVM::BasicBlock is LLVM::Opaque {
method BUILD($ref) { self.wrap($ptr) };
};

# vim: ft=perl6
7 changes: 2 additions & 5 deletions runtime/parrot/library/LLVM/Function.pm
@@ -1,8 +1,7 @@
class LLVM::Function {
class LLVM::Function is LLVM::Opaque {
our $counter;
has $!ptr;

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

method append_basic_block($name?) {
LLVM::BasicBlock.new.BUILD(
Expand All @@ -13,8 +12,6 @@ class LLVM::Function {
method set_linkage($linkage) {
%LLVM::F<LLVMSetLinkage>($!ptr, $linkage);
}

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

# vim: ft=perl6
4 changes: 2 additions & 2 deletions t/library/llvm.t
Expand Up @@ -46,8 +46,8 @@ ok( 1, "return created");
$module.dump();
ok(1, "LLVM::Module dumped");

my $engine := pir::new__psp("LLVM_Engine", $module._get_ptr());
my $call := $engine.create($function._get_ptr(), "I");
my $engine := pir::new__psp("LLVM_Engine", $module.unwrap());
my $call := $engine.create($function.unwrap(), "I");
my $res := -1;
$res := $call();
ok(1, "Function called");
Expand Down

0 comments on commit 3f98103

Please sign in to comment.