Displaying 2 results from an estimated 2 matches for "runtype".
Did you mean:
rbntype
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
.... :-)
As I understand it, the simplest approach is to box all values, which means
that every value is stored as a struct containing the type (an enum) and the
value itself (inline if it is no bigger than a pointer or as a pointer to a
larger data structure otherwise). Something like this:
enum runtype {
Int;
Float;
Array;
}
struct array {
int length;
box *a;
}
union value {
int n; // 64-bit
float x; // 64-bit
array* u; // >64-bit
}
struct box {
runtype t;
value v;
}
So you'd create an int with:
box make_int(int n) {
box b;
b.t = Int;
b.v.n = n;
return...
2007 Nov 26
2
[LLVMdev] Fibonacci example in OCaml
On Nov 26, 2007, at 00:47, Jon Harrop wrote:
> Here is a complete 104-line native code compiler for a tiny subset
> of OCaml that is expressive enough to compile an external Fibonacci
> program:
>
> [...]
>
> I was kind of hoping that function pointers would just magically
> work, so this:
>
> do (if 1 <= 2 then fib else fib) 40
>
> would run, but