Browse Source

adjust to cl_init changes

Simon Krajewski 1 year ago
parent
commit
48aaef0ca3
2 changed files with 14 additions and 7 deletions
  1. 8 1
      src/compiler/hxb/hxbReader.ml
  2. 6 6
      src/compiler/hxb/hxbWriter.ml

+ 8 - 1
src/compiler/hxb/hxbReader.ml

@@ -1394,6 +1394,10 @@ class hxb_reader
 			let cf = Option.get c.cl_constructor in
 			let cf = Option.get c.cl_constructor in
 			self#read_class_field_and_overloads_data cf
 			self#read_class_field_and_overloads_data cf
 		) in
 		) in
+		let _ = self#read_option (fun f ->
+			let cf = Option.get c.cl_init in
+			self#read_class_field_and_overloads_data cf
+		) in
 		let rec loop ref_kind num cfl = match cfl with
 		let rec loop ref_kind num cfl = match cfl with
 			| cf :: cfl ->
 			| cf :: cfl ->
 				assert (num > 0);
 				assert (num > 0);
@@ -1404,7 +1408,6 @@ class hxb_reader
 		in
 		in
 		loop CfrMember (read_uleb128 ch) c.cl_ordered_fields;
 		loop CfrMember (read_uleb128 ch) c.cl_ordered_fields;
 		loop CfrStatic (read_uleb128 ch) c.cl_ordered_statics;
 		loop CfrStatic (read_uleb128 ch) c.cl_ordered_statics;
-		c.cl_init <- self#read_option (fun () -> self#read_texpr self#start_texpr);
 		(match c.cl_kind with KModuleFields md -> md.m_statics <- Some c; | _ -> ());
 		(match c.cl_kind with KModuleFields md -> md.m_statics <- Some c; | _ -> ());
 
 
 	method read_enum_fields (e : tenum) =
 	method read_enum_fields (e : tenum) =
@@ -1561,6 +1564,7 @@ class hxb_reader
 				| 0 -> CfrStatic
 				| 0 -> CfrStatic
 				| 1 -> CfrMember
 				| 1 -> CfrMember
 				| 2 -> CfrConstructor
 				| 2 -> CfrConstructor
+				| 3 -> CfrInit
 				| _ -> die "" __LOC__
 				| _ -> die "" __LOC__
 			in
 			in
 			let cf =  match kind with
 			let cf =  match kind with
@@ -1580,6 +1584,8 @@ class hxb_reader
 					end
 					end
 				| CfrConstructor ->
 				| CfrConstructor ->
 					Option.get c.cl_constructor
 					Option.get c.cl_constructor
+				| CfrInit ->
+					Option.get c.cl_init
 			in
 			in
 			let pick_overload cf depth =
 			let pick_overload cf depth =
 				let rec loop depth cfl = match cfl with
 				let rec loop depth cfl = match cfl with
@@ -1776,6 +1782,7 @@ class hxb_reader
 				in
 				in
 
 
 				c.cl_constructor <- self#read_option read_field;
 				c.cl_constructor <- self#read_option read_field;
+				c.cl_init <- self#read_option read_field;
 				let read_fields i =
 				let read_fields i =
 					let rec loop acc_l acc_pm i =
 					let rec loop acc_l acc_pm i =
 						if i = 0 then
 						if i = 0 then

+ 6 - 6
src/compiler/hxb/hxbWriter.ml

@@ -951,6 +951,8 @@ module HxbWriter = struct
 			let r = match kind with
 			let r = match kind with
 				| CfrStatic | CfrConstructor ->
 				| CfrStatic | CfrConstructor ->
 					find_overload c;
 					find_overload c;
+				| CfrInit ->
+					Some(c,0)
 				| CfrMember ->
 				| CfrMember ->
 					(* For member overloads we need to find the correct class, which is a mess. *)
 					(* For member overloads we need to find the correct class, which is a mess. *)
 					let rec loop c = match find_overload c with
 					let rec loop c = match find_overload c with
@@ -1985,6 +1987,7 @@ module HxbWriter = struct
 		| TClassDecl c ->
 		| TClassDecl c ->
 			Chunk.write_uleb128 writer.chunk c.cl_flags;
 			Chunk.write_uleb128 writer.chunk c.cl_flags;
 			Chunk.write_option writer.chunk c.cl_constructor (write_class_field_forward writer);
 			Chunk.write_option writer.chunk c.cl_constructor (write_class_field_forward writer);
+			Chunk.write_option writer.chunk c.cl_init (write_class_field_forward writer);
 
 
 			(* Write in reverse order so reader can read tail-recursively without List.rev *)
 			(* Write in reverse order so reader can read tail-recursively without List.rev *)
 			let write_fields cfl =
 			let write_fields cfl =
@@ -2060,14 +2063,9 @@ module HxbWriter = struct
 				in
 				in
 
 
 				Chunk.write_option writer.chunk c.cl_constructor (write_field CfrConstructor);
 				Chunk.write_option writer.chunk c.cl_constructor (write_field CfrConstructor);
+				Chunk.write_option writer.chunk c.cl_init (write_field CfrInit);
 				Chunk.write_list writer.chunk c.cl_ordered_fields (write_field CfrMember);
 				Chunk.write_list writer.chunk c.cl_ordered_fields (write_field CfrMember);
 				Chunk.write_list writer.chunk c.cl_ordered_statics (write_field CfrStatic);
 				Chunk.write_list writer.chunk c.cl_ordered_statics (write_field CfrStatic);
-				Chunk.write_option writer.chunk c.cl_init (fun e ->
-					let fctx,close = start_texpr writer e.epos in
-					write_texpr writer fctx e;
-					let new_chunk = close() in
-					Chunk.export_data new_chunk writer.chunk
-				);
 				match !c_expr_chunks with
 				match !c_expr_chunks with
 				| [] ->
 				| [] ->
 					()
 					()
@@ -2175,6 +2173,8 @@ module HxbWriter = struct
 					Chunk.write_string writer.chunk cf.cf_name
 					Chunk.write_string writer.chunk cf.cf_name
 				| CfrConstructor ->
 				| CfrConstructor ->
 					Chunk.write_u8 writer.chunk 2;
 					Chunk.write_u8 writer.chunk 2;
+				| CfrInit ->
+					Chunk.write_u8 writer.chunk 3;
 				end;
 				end;
 				Chunk.write_uleb128 writer.chunk depth
 				Chunk.write_uleb128 writer.chunk depth
 			) items;
 			) items;