diff --git a/runtime/parrot/library/LLVM/Function.pm b/runtime/parrot/library/LLVM/Function.pm new file mode 100644 index 0000000000..9b5e911b1a --- /dev/null +++ b/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($!ptr, $name ?? $name !! "block" ~~ $counter++); + } + + method _get_ptr() { $!ptr }; +}; + +# vim: ft=perl6 diff --git a/runtime/parrot/library/LLVM/Module.pm b/runtime/parrot/library/LLVM/Module.pm index 41525ee26b..b1516f3bd5 100644 --- a/runtime/parrot/library/LLVM/Module.pm +++ b/runtime/parrot/library/LLVM/Module.pm @@ -25,7 +25,7 @@ class LLVM::Module { 0, # is var args ); - %LLVM::F($!ref, $name, $type); + LLVM::Function.new.BUILD(%LLVM::F($!ref, $name, $type)); } method _get_ptr() { $!ref }; diff --git a/t/library/llvm.t b/t/library/llvm.t index 62c348ebf3..37b646ba34 100644 --- a/t/library/llvm.t +++ b/t/library/llvm.t @@ -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();