|
@@ -5741,6 +5741,7 @@ let write_c version file (code:code) =
|
|
|
let version_revision = (version mod 100) in
|
|
|
let ver_str = Printf.sprintf "%d.%d.%d" version_major version_minor version_revision in
|
|
|
line ("// Generated by HLC " ^ ver_str ^ " (HL v" ^ string_of_int code.version ^")");
|
|
|
+ line "#define HLC_BOOT";
|
|
|
line "#include <hlc.h>";
|
|
|
let types = gather_types code in
|
|
|
let tfuns = Array.create (Array.length code.functions + Array.length code.natives) ([],HVoid) in
|
|
@@ -5814,14 +5815,15 @@ let write_c version file (code:code) =
|
|
|
let name = tname o.pname in
|
|
|
line ("struct _" ^ name ^ " {");
|
|
|
block();
|
|
|
- (match o.psuper with
|
|
|
- | None ->
|
|
|
- expr ("hl_type *$type");
|
|
|
- | Some c ->
|
|
|
- expr ("struct _" ^ tname c.pname));
|
|
|
- Array.iter (fun (n,_,t) ->
|
|
|
- expr (var_type n t)
|
|
|
- ) o.pfields;
|
|
|
+ let rec loop o =
|
|
|
+ (match o.psuper with
|
|
|
+ | None -> expr ("hl_type *$type");
|
|
|
+ | Some c -> loop c);
|
|
|
+ Array.iter (fun (n,_,t) ->
|
|
|
+ expr (var_type n t)
|
|
|
+ ) o.pfields;
|
|
|
+ in
|
|
|
+ loop o;
|
|
|
unblock();
|
|
|
expr "}";
|
|
|
| HEnum e ->
|
|
@@ -5829,7 +5831,7 @@ let write_c version file (code:code) =
|
|
|
if Array.length pl <> 0 then begin
|
|
|
line ("typedef struct {");
|
|
|
block();
|
|
|
- expr "struct _venum";
|
|
|
+ expr "int index";
|
|
|
Array.iteri (fun i t ->
|
|
|
expr (var_type ("p" ^ string_of_int i) t)
|
|
|
) pl;
|
|
@@ -6666,19 +6668,19 @@ let write_c version file (code:code) =
|
|
|
match t with
|
|
|
| HObj o ->
|
|
|
sexpr "obj$%d.m = &ctx" i;
|
|
|
- (match o.pclassglobal with None -> () | Some g -> sexpr "obj$%d.global_value = &global$%d" i g);
|
|
|
+ (match o.pclassglobal with None -> () | Some g -> sexpr "obj$%d.global_value = (void**)&global$%d" i g);
|
|
|
sexpr "type$%d.obj = &obj$%d" i i
|
|
|
| HNull t | HRef t ->
|
|
|
sexpr "type$%d.tparam = %s" i (type_value t)
|
|
|
| HEnum e ->
|
|
|
sexpr "type$%d.tenum = &enum$%d" i i;
|
|
|
- if e.eglobal <> 0 then sexpr "enum$%d.global_value = &global$%d" i e.eglobal;
|
|
|
+ if e.eglobal <> 0 then sexpr "enum$%d.global_value = (void**)&global$%d" i e.eglobal;
|
|
|
Array.iteri (fun cid (_,_,tl) ->
|
|
|
if Array.length tl > 0 then begin
|
|
|
line "{";
|
|
|
block();
|
|
|
sexpr "%s *_e = NULL" (enum_constr_type e cid);
|
|
|
- Array.iteri (fun pid _ -> sexpr "eoffsets$%d_%d[%d] = (int)&_e->p%d" i cid pid pid) tl;
|
|
|
+ Array.iteri (fun pid _ -> sexpr "eoffsets$%d_%d[%d] = (int)(int_val)&_e->p%d" i cid pid pid) tl;
|
|
|
unblock();
|
|
|
line "}";
|
|
|
end
|