summaryrefslogtreecommitdiff
path: root/bindings/ocaml/llvm/llvm_ocaml.c
diff options
context:
space:
mode:
authorTorok Edwin <edwintorok@gmail.com>2011-10-06 12:12:50 +0000
committerTorok Edwin <edwintorok@gmail.com>2011-10-06 12:12:50 +0000
commitc44943ed4f4f2d44b6668e6b51eb355f8310660c (patch)
tree315bd17a2494cbef968ab40d0fe70abf8179f458 /bindings/ocaml/llvm/llvm_ocaml.c
parent624c5edcd485a210faa61113f38938bdb6a0cc58 (diff)
downloadllvm-c44943ed4f4f2d44b6668e6b51eb355f8310660c.tar.gz
llvm-c44943ed4f4f2d44b6668e6b51eb355f8310660c.tar.bz2
llvm-c44943ed4f4f2d44b6668e6b51eb355f8310660c.tar.xz
C/OCaml API to retrieve struct name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/ocaml/llvm/llvm_ocaml.c')
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c
index 1c1a526fd7..28f0977aba 100644
--- a/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/bindings/ocaml/llvm/llvm_ocaml.c
@@ -287,6 +287,20 @@ CAMLprim LLVMTypeRef llvm_packed_struct_type(LLVMContextRef C,
Wosize_val(ElementTypes), 1);
}
+/* lltype -> string option */
+CAMLprim value llvm_struct_name(LLVMTypeRef Ty)
+{
+ CAMLparam0();
+ const char *C = LLVMGetStructName(Ty);
+ if (C) {
+ CAMLlocal1(result);
+ result = caml_alloc_small(1, 0);
+ Store_field(result, 0, caml_copy_string(C));
+ CAMLreturn(result);
+ }
+ CAMLreturn(Val_int(0));
+}
+
/* lltype -> lltype array */
CAMLprim value llvm_struct_element_types(LLVMTypeRef StructTy) {
value Tys = alloc(LLVMCountStructElementTypes(StructTy), 0);