[LLVMdev] Supporting Classes using OCaml.

Frank White frankwhite1003 at gmail.com
Wed Jul 18 21:36:57 PDT 2012


Hello all...

I'm trying to create a simple language that supports classes using the
OCaml API.

When I use the web page demo to produce the intermediate code for the
following C++ example ...

class MyClass {
 public:
   MyClass();
   int c;
};

MyClass::MyClass () {
 c=55;
}

...I get something like this ....

%class.MyClass = type { i32 }

@MyClass::MyClass() = alias void (%class.MyClass*)* @MyClass::MyClass()
define void @MyClass::MyClass()(%class.MyClass* %this) unnamed_addr
nounwind uwtable align 2 {
  %1 = alloca %class.MyClass*, align 8
  store %class.MyClass* %this, %class.MyClass** %1, align 8
  %2 = load %class.MyClass** %1
  %3 = getelementptr inbounds %class.MyClass* %2, i32 0, i32 0
  store i32 55, i32* %3, align 4
  ret void
}

...however I didn't see any function in the API that generates the named
type command that is produced in the result.

Is there an OCaml function which emits code for named structure types?  Or
this there a means of obtaining an equivalent result.  Any comments would
be greatly appreciated.

Thanks,
Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120719/c2e1652d/attachment.html>


More information about the llvm-dev mailing list