Prechádzať zdrojové kódy

encode Void directly because it actually appears a lot

Simon Krajewski 1 rok pred
rodič
commit
b7cec3e271

+ 2 - 0
src/compiler/hxb/hxbReader.ml

@@ -737,6 +737,8 @@ class hxb_reader
 			api#basic_types.tbool
 		| 103 ->
 			api#basic_types.tstring
+		| 104 ->
+			api#basic_types.tvoid
 		| i ->
 			error (Printf.sprintf "Bad type instance id: %i" i)
 

+ 3 - 0
src/compiler/hxb/hxbWriter.ml

@@ -952,6 +952,9 @@ class hxb_writer
 		| TInst ({cl_path = ([],"String")},[]) ->
 			self#write_type_instance_byte 103;
 			None
+		| TAbstract ({a_path = ([],"Void")},[]) ->
+			self#write_type_instance_byte 104;
+			None
 		| TMono r ->
 			Monomorph.close r;
 			begin match r.tm_type with

+ 1 - 0
src/context/common.ml

@@ -904,6 +904,7 @@ let clone com is_macro_context =
 	{ com with
 		cache = None;
 		basic = { t with
+			tvoid = mk_mono();
 			tint = mk_mono();
 			tfloat = mk_mono();
 			tbool = mk_mono();

+ 4 - 1
src/typing/typerEntry.ml

@@ -91,7 +91,10 @@ let create com macros =
 		match t with
 		| TAbstractDecl a ->
 			(match snd a.a_path with
-			| "Void" -> ctx.t.tvoid <- TAbstract (a,[]);
+			| "Void" ->
+				let t = TAbstract (a,[]) in
+				Type.unify t ctx.t.tvoid;
+				ctx.t.tvoid <- t;
 			| "Float" ->
 				let t = (TAbstract (a,[])) in
 				Type.unify t ctx.t.tfloat;