Browse Source

remove a_default (#12451)

Simon Krajewski 1 day ago
parent
commit
dce7e29fb0

+ 0 - 7
src-json/meta.json

@@ -180,13 +180,6 @@
 		"doc": "",
 		"platforms": ["cpp"]
 	},
-	{
-		"name": "DefaultValue",
-		"metadata": ":defaultValue",
-		"doc": "Default value for abstracts",
-		"targets": ["TAbstract"],
-		"internal": true
-	},
 	{
 		"name": "DefParam",
 		"metadata": ":defParam",

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

@@ -1584,10 +1584,6 @@ class hxb_reader
 		a.a_write <- self#read_option (fun () -> self#read_field_ref);
 		a.a_call <- self#read_option (fun () -> self#read_field_ref);
 		a.a_constructor <- self#read_option (fun () -> self#read_field_ref);
-		a.a_default <- self#read_option (fun () -> 
-			let fctx = self#start_texpr in
-			let e = self#read_texpr fctx in
-			Lazy.from_val e);
 
 		a.a_ops <- self#read_list (fun () ->
 			let i = read_byte ch in

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

@@ -1953,13 +1953,6 @@ module HxbWriter = struct
 		Chunk.write_option writer.chunk a.a_write (write_field_ref writer c CfrStatic);
 		Chunk.write_option writer.chunk a.a_call (write_field_ref writer c CfrStatic);
 		Chunk.write_option writer.chunk a.a_constructor (write_field_ref writer c CfrStatic);
-		Chunk.write_option writer.chunk a.a_default (fun lazy_texpr ->
-			let texpr = Lazy.force lazy_texpr in
-			let fctx,close = start_texpr writer texpr.epos in
-			catch_unbound_ttp (fun () -> write_texpr writer fctx texpr) "default value" None;
-			let expr_pre_chunk,expr_chunk = close() in
-			Chunk.export_data expr_pre_chunk writer.chunk;
-			Chunk.export_data expr_chunk writer.chunk);
 
 		Chunk.write_list writer.chunk a.a_ops (fun (op, cf) ->
 			Chunk.write_u8 writer.chunk (binop_index op);

+ 0 - 1
src/core/tFunctions.ml

@@ -302,7 +302,6 @@ let null_abstract = {
 	a_constructor = None;
 	a_extern = false;
 	a_enum = false;
-	a_default = None;
 }
 
 let create_dependency mdep origin =

+ 0 - 1
src/core/tOther.ml

@@ -304,7 +304,6 @@ let mk_abstract m path pos name_pos =
 		a_extern = false;
 		a_enum = false;
 		a_call = None;
-		a_default = None;
 	}
 
 module TClass = struct

+ 0 - 1
src/core/tPrinting.ml

@@ -593,7 +593,6 @@ module Printer = struct
 			"a_array",s_list ", " (fun cf -> cf.cf_name) a.a_array;
 			"a_read",s_opt (fun cf -> cf.cf_name) a.a_read;
 			"a_write",s_opt (fun cf -> cf.cf_name) a.a_write;
-			"a_default",s_opt (fun lazy_texpr -> lazy_texpr |> Lazy.force |> s_expr_ast true "" s_type) a.a_default;
 		]
 
 	let s_tvar_extra ve =

+ 0 - 1
src/core/tType.ml

@@ -398,7 +398,6 @@ and tabstract = {
 	mutable a_constructor : tclass_field option;
 	mutable a_extern : bool;
 	mutable a_enum : bool;
-	mutable a_default : texpr Lazy.t option;
 }
 
 and module_type =

+ 0 - 12
src/core/texpr.ml

@@ -547,18 +547,6 @@ module Builder = struct
 	let index basic e index t p =
 		mk (TArray (e,mk (TConst (TInt (Int32.of_int index))) basic.tint p)) t p
 
-	let rec default_value t p = match t with
-		| TAbstract({a_default = Some f},_) ->
-			{(Lazy.force f) with etype = t; epos = p}
-		| TInst _ | TEnum _ | TAbstract _ | TFun _ | TAnon _ | TDynamic _ | TMono {tm_type = None} ->
-			mk (TConst TNull) t p
-		| TLazy r ->
-			default_value (lazy_type r) p
-		| TMono {tm_type = Some t} ->
-			default_value t p
-		| TType(td,tl) ->
-			default_value (apply_typedef td tl) p
-
 	let resolve_and_make_static_call c name args p =
 		ignore(c.cl_build());
 		let cf = try

+ 0 - 1
src/macro/macroApi.ml

@@ -1084,7 +1084,6 @@ and encode_tabstract a =
 		"array", encode_array (List.map encode_cfield a.a_array);
 		"resolve", (match a.a_read with None -> vnull | Some cf -> encode_cfref cf);
 		"resolveWrite", (match a.a_write with None -> vnull | Some cf -> encode_cfref cf);
-		"defaultValue", (match a.a_default with None -> vnull | Some lazy_texpr -> encode_ref lazy_texpr (fun lazy_texpr -> lazy_texpr |> Lazy.force |> encode_texpr) (fun () -> "default value") )
 	]
 
 and encode_efield f =

+ 0 - 17
src/typing/typeloadModule.ml

@@ -172,19 +172,6 @@ module ModuleLevel = struct
 					let priv = List.mem AbPrivate d.d_flags in
 					let path = make_path name priv d.d_meta p in
 					let p_enum_meta = Meta.maybe_get_pos Meta.Enum d.d_meta in
-					let a_default = try
-						begin match Meta.get Meta.DefaultValue d.d_meta with
-						| (_,[e],_) ->
-							Some (Lazy.from_fun (fun () ->
-								let ctx = TyperManager.clone_for_expr ctx_m FunStatic FunNotFunction in
-								type_expr ctx e WithType.value
-							))
-						| _ ->
-							raise Not_found
-						end
-					with Not_found ->
-						None
-					in
 					let a = {
 						a_path = path;
 						a_private = priv;
@@ -211,11 +198,7 @@ module ModuleLevel = struct
 						a_constructor = None;
 						a_extern = List.mem AbExtern d.d_flags;
 						a_enum = List.mem AbEnum d.d_flags || p_enum_meta <> None;
-						a_default;
 					} in
-					delay ctx_m.g PBuildModule (fun () ->
-						match a.a_default with | None -> () | Some l -> ignore(Lazy.force l)
-					);
 					begin match p_enum_meta with
 						| None when a.a_enum -> a.a_meta <- (Meta.Enum,[],null_pos) :: a.a_meta; (* HAXE5: remove *)
 						| None -> ()

+ 0 - 3
std/StdTypes.hx

@@ -43,7 +43,6 @@
 	@see https://haxe.org/manual/types-basic-types.html
 	@see https://haxe.org/manual/types-nullability.html
 **/
-@:defaultValue(0.0)
 @:coreType @:notNull @:runtimeValue abstract Float {}
 
 /**
@@ -59,7 +58,6 @@
 	@see https://haxe.org/manual/std-math-integer-math.html
 	@see https://haxe.org/manual/types-nullability.html
 **/
-@:defaultValue(0)
 @:coreType @:notNull @:runtimeValue abstract Int to Float {}
 
 #if (java || hl || cpp)
@@ -93,7 +91,6 @@ abstract Null<T> from T to T {}
 	@see https://haxe.org/manual/types-bool.html
 	@see https://haxe.org/manual/types-nullability.html
 **/
-@:defaultValue(false)
 @:coreType @:notNull @:runtimeValue abstract Bool {}
 
 /**

+ 1 - 1
std/cpp/Char.hx

@@ -22,4 +22,4 @@
 
 package cpp;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract Char from Int to Int {}
+@:coreType @:notNull @:runtimeValue abstract Char from Int to Int {}

+ 1 - 1
std/cpp/Char16.hx

@@ -22,4 +22,4 @@
 
 package cpp;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract Char16 from Int to Int {}
+@:coreType @:notNull @:runtimeValue abstract Char16 from Int to Int {}

+ 1 - 1
std/cpp/Int16.hx

@@ -22,4 +22,4 @@
 
 package cpp;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract Int16 from Int to Int {}
+@:coreType @:notNull @:runtimeValue abstract Int16 from Int to Int {}

+ 1 - 1
std/cpp/Int32.hx

@@ -22,4 +22,4 @@
 
 package cpp;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract Int32 from Int to Int {}
+@:coreType @:notNull @:runtimeValue abstract Int32 from Int to Int {}

+ 0 - 1
std/cpp/Int64.hx

@@ -22,7 +22,6 @@
 
 package cpp;
 
-@:defaultValue(0)
 @:coreType @:notNull @:runtimeValue abstract Int64 from Int {
 
 	/**

+ 1 - 1
std/cpp/Int8.hx

@@ -22,4 +22,4 @@
 
 package cpp;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract Int8 from Int to Int {}
+@:coreType @:notNull @:runtimeValue abstract Int8 from Int to Int {}

+ 1 - 1
std/cpp/SizeT.hx

@@ -23,5 +23,5 @@
 package cpp;
 
 @:native("size_t")
-@:scalar @:coreType @:notNull @:defaultValue(0)
+@:scalar @:coreType @:notNull
 extern abstract SizeT from(Int) to(Int) {}

+ 1 - 1
std/cpp/UInt16.hx

@@ -22,4 +22,4 @@
 
 package cpp;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract UInt16 from Int to Int {}
+@:coreType @:notNull @:runtimeValue abstract UInt16 from Int to Int {}

+ 1 - 1
std/cpp/UInt32.hx

@@ -22,4 +22,4 @@
 
 package cpp;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract UInt32 from Int to Int {}
+@:coreType @:notNull @:runtimeValue abstract UInt32 from Int to Int {}

+ 1 - 1
std/cpp/UInt64.hx

@@ -22,7 +22,7 @@
 
 package cpp;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract UInt64 from Int {
+@:coreType @:notNull @:runtimeValue abstract UInt64 from Int {
 
 	/**
 		Destructively cast to Int

+ 1 - 1
std/cpp/UInt8.hx

@@ -22,4 +22,4 @@
 
 package cpp;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract UInt8 from Int to Int {}
+@:coreType @:notNull @:runtimeValue abstract UInt8 from Int to Int {}

+ 0 - 5
std/haxe/macro/Type.hx

@@ -548,11 +548,6 @@ typedef AbstractType = BaseType & {
 		The method used for resolving unknown field access, if available.
 	**/
 	var resolveWrite:Null<ClassField>;
-
-	/**
-		The expression given as a default value for this abstract, if available.
-	**/
-	var defaultValue:Null<Ref<TypedExpr>>;
 }
 
 /**

+ 1 - 2
std/hl/I64.hx

@@ -22,8 +22,7 @@
 
 package hl;
 
-@:defaultValue(0)
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract I64 from Int {
+@:coreType @:notNull @:runtimeValue abstract I64 from Int {
 
 	/**
 		Destructively cast to Int

+ 1 - 1
std/hl/UI16.hx

@@ -22,4 +22,4 @@
 
 package hl;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract UI16 to Int from Int {}
+@:coreType @:notNull @:runtimeValue abstract UI16 to Int from Int {}

+ 1 - 1
std/hl/UI8.hx

@@ -22,4 +22,4 @@
 
 package hl;
 
-@:coreType @:notNull @:runtimeValue @:defaultValue(0) abstract UI8 to Int from Int {}
+@:coreType @:notNull @:runtimeValue abstract UI8 to Int from Int {}

+ 1 - 1
std/jvm/Char16.hx

@@ -1,3 +1,3 @@
 package jvm;
 
-@:notNull @:runtimeValue @:coreType @:defaultValue(0) extern abstract Char16 from Int {}
+@:notNull @:runtimeValue @:coreType extern abstract Char16 from Int {}

+ 1 - 1
std/jvm/Int16.hx

@@ -1,3 +1,3 @@
 package jvm;
 
-@:notNull @:runtimeValue @:coreType @:defaultValue(0) extern abstract Int16 from Int {}
+@:notNull @:runtimeValue @:coreType extern abstract Int16 from Int {}

+ 0 - 1
std/jvm/Int64.hx

@@ -1,6 +1,5 @@
 package jvm;
 
-@:defaultValue(0)
 @:notNull @:runtimeValue @:coreType extern abstract Int64 from Int from Float {
 	@:op(A + B) public static function addI(lhs:Int64, rhs:Int):Int64;
 

+ 1 - 1
std/jvm/Int8.hx

@@ -1,3 +1,3 @@
 package jvm;
 
-@:notNull @:runtimeValue @:coreType @:defaultValue(0) extern abstract Int8 from Int {}
+@:notNull @:runtimeValue @:coreType extern abstract Int8 from Int {}