Skip to content

Commit

Permalink
Provide default .BUILD and fix Builder to use unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 7, 2011
1 parent 3f98103 commit 158897b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion runtime/parrot/library/LLVM/BasicBlock.pm
@@ -1,5 +1,4 @@
class LLVM::BasicBlock is LLVM::Opaque {
method BUILD($ref) { self.wrap($ptr) };
};

# vim: ft=perl6
6 changes: 3 additions & 3 deletions runtime/parrot/library/LLVM/Builder.pm
Expand Up @@ -18,7 +18,7 @@ class LLVM::Builder {

# LLVMPositionBuilder => "vppp",
multi method set_position(LLVM::BasicBlock $bb, $value) {
%LLVM::F<LLVMPositionBuilder>($!ref, $bb._get_ptr(), $value);
%LLVM::F<LLVMPositionBuilder>($!ref, $bb.unwrap(), $value);
}

# LLVMPositionBuilderBefore => "vpp",
Expand All @@ -28,7 +28,7 @@ class LLVM::Builder {

# LLVMPositionBuilderAtEnd => "vpp",
multi method set_position(LLVM::BasicBlock $bb) {
%LLVM::F<LLVMPositionBuilderAtEnd>($!ref, $bb._get_ptr());
%LLVM::F<LLVMPositionBuilderAtEnd>($!ref, $bb.unwrap());
}

# LLVMGetInsertBlock => "pp",
Expand Down Expand Up @@ -128,7 +128,7 @@ class LLVM::Builder {
method call($func, *@args, :$name?) {
%LLVM::F<LLVMBuildCall>(
$!ref,
$func._get_ptr,
$func.unwrap(),
LLVM::convert_to_struct(@args),
+@args,
$name // ""
Expand Down
2 changes: 0 additions & 2 deletions runtime/parrot/library/LLVM/Function.pm
@@ -1,8 +1,6 @@
class LLVM::Function is LLVM::Opaque {
our $counter;

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

method append_basic_block($name?) {
LLVM::BasicBlock.new.BUILD(
%LLVM::F<LLVMAppendBasicBlock>($!ptr, $name ?? $name !! "block" ~~ $counter++)
Expand Down
3 changes: 3 additions & 0 deletions runtime/parrot/library/LLVM/Opaque.pm
@@ -1,6 +1,9 @@
class LLVM::Opaque {
has $!ptr;

# Default implementation of BUILD.
method BUILD($ptr) { self.wrap($ptr) }

method wrap($ptr) { $!ptr := $ptr; self };
method unwrap() { $!ptr };
};
Expand Down

0 comments on commit 158897b

Please sign in to comment.