Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 49 lines (42 sloc) 1.084 kB
162305c @tombagby First import
authored
1 #include "llvmruby.h"
c604653 @tombagby better inspecting methods for modules and functions
authored
2 #include <sstream>
162305c @tombagby First import
authored
3
4 extern "C" {
173ea1f @tombagby functions get names and types now
authored
5 VALUE
9336a62 @tombagby make functions work more properly, clean many things, expose executio…
authored
6 llvm_function_wrap(Function *f) {
7 return Data_Wrap_Struct(cLLVMFunction, NULL, NULL, f);
162305c @tombagby First import
authored
8 }
9
173ea1f @tombagby functions get names and types now
authored
10 VALUE
11 llvm_function_create_block(VALUE self) {
9336a62 @tombagby make functions work more properly, clean many things, expose executio…
authored
12 BasicBlock *bb = BasicBlock::Create("bb", LLVM_FUNCTION(self));
162305c @tombagby First import
authored
13 return llvm_basic_block_wrap(bb);
14 }
15
9336a62 @tombagby make functions work more properly, clean many things, expose executio…
authored
16 VALUE
17 llvm_function_arguments(VALUE self) {
18 Function *f = LLVM_FUNCTION(self);
19 VALUE arg_array = rb_ary_new();
20 Function::arg_iterator args = f->arg_begin();
21 while(args != f->arg_end()) {
22 Value *arg = args++;
23 rb_ary_push(arg_array, llvm_value_wrap(arg));
24 }
25 return arg_array;
162305c @tombagby First import
authored
26 }
c604653 @tombagby better inspecting methods for modules and functions
authored
27
28 VALUE
29 llvm_function_inspect(VALUE self) {
30 Function *f = LLVM_FUNCTION(self);
31 std::ostringstream strstrm;
32 strstrm << *f;
33 return rb_str_new2(strstrm.str().c_str());
34 }
1038881 @plessl Added support for getting a list of the basic blocks in a function, a…
plessl authored
35
36 VALUE
37 llvm_function_get_basic_block_list(VALUE self) {
38 Function *f = LLVM_FUNCTION(self);
39 VALUE bb_array = rb_ary_new();
40 Function::iterator bbs = f->begin();
41 while(bbs != f->end()) {
42 BasicBlock *bb = bbs++;
43 rb_ary_push(bb_array, llvm_basic_block_wrap(bb));
44 }
45 return bb_array;
46 }
47
162305c @tombagby First import
authored
48 }
Something went wrong with that request. Please try again.