2
0
Simon Krajewski 5 жил өмнө
parent
commit
4b02b9ec97

+ 1 - 1
src/codegen/gencommon/abstractImplementationFix.ml

@@ -28,7 +28,7 @@ let add_abstract_params = function
 				cf.cf_params <- cf.cf_params @ a.a_params
 			| cf when Meta.has Meta.Impl cf.cf_meta ->
 				(match cf.cf_expr with
-				| Some({ eexpr = TFunction({ tf_args = (v, _) :: _ }) }) when Meta.has Meta.This v.v_meta ->
+				| Some({ eexpr = TFunction({ tf_args = (v, _) :: _ }) }) when var_has_meta v Meta.This ->
 					cf.cf_params <- cf.cf_params @ a.a_params
 				| _ -> ())
 			| _ -> ()

+ 1 - 1
src/context/display/displayEmitter.ml

@@ -89,7 +89,7 @@ let display_variable ctx v p = match ctx.com.display.dms_kind with
 	| DMTypeDefinition -> raise_position_of_type v.v_type
 	| DMUsage _ -> ReferencePosition.set (v.v_name,v.v_pos,SKVariable v)
 	| DMHover ->
-		let ct = CompletionType.from_type (get_import_status ctx) ~values:(get_value_meta v.v_meta) v.v_type in
+		let ct = CompletionType.from_type (get_import_status ctx) ~values:(get_value_meta (get_var_meta v)) v.v_type in
 		raise_hover (make_ci_local v (v.v_type,ct)) None p
 	| _ -> ()
 

+ 1 - 1
src/context/display/displayToplevel.ml

@@ -283,7 +283,7 @@ let collect ctx tk with_type sort =
 		(* locals *)
 		PMap.iter (fun _ v ->
 			if not (is_gen_local v) then
-				add (make_ci_local v (tpair ~values:(get_value_meta v.v_meta) v.v_type)) (Some v.v_name)
+				add (make_ci_local v (tpair ~values:(get_value_meta (get_var_meta v)) v.v_type)) (Some v.v_name)
 		) ctx.locals;
 
 		let add_field scope origin cf =

+ 1 - 1
src/core/json/genjson.ml

@@ -299,7 +299,7 @@ and generate_tvar ctx v =
 		"type",generate_type ctx v.v_type;
 		"capture",jbool (has_var_flag v VCaptured);
 		"extra",jopt generate_extra v.v_extra;
-		"meta",generate_metadata ctx v.v_meta;
+		"meta",generate_metadata ctx (get_var_meta v);
 		"pos",generate_pos ctx v.v_pos;
 		"isFinal",jbool (has_var_flag v VFinal);
 		"isInline",jbool (match v.v_extra with Some {v_expr = Some _} -> true | _ -> false);

+ 36 - 2
src/core/tFunctions.ml

@@ -55,7 +55,6 @@ let alloc_var =
 			v_type = t;
 			v_id = !uid;
 			v_extra = None;
-			v_meta = [];
 			v_pos = p;
 			v_flags = (match kind with VUser TVOLocalFunction -> int_of_var_flag VFinal | _ -> 0);
 		}
@@ -777,4 +776,39 @@ let type_has_meta t m =
 let var_extra params e = {
 	v_params = params;
 	v_expr = e;
-}
+	v_meta = [];
+}
+
+let set_var_params v params = match v.v_extra with
+	| Some ve ->
+		v.v_extra <- Some {ve with v_params = params}
+	| None ->
+		v.v_extra <- Some (var_extra params None)
+
+let set_var_expr v e = match v.v_extra with
+	| Some ve ->
+		v.v_extra <- Some {ve with v_expr = Some e}
+	| None ->
+		v.v_extra <- Some (var_extra [] (Some e))
+
+let var_has_meta v m = match v.v_extra with
+	| Some ve -> has_meta m ve.v_meta
+	| None -> false
+
+let get_var_meta v = match v.v_extra with
+	| Some ve -> ve.v_meta
+	| None -> []
+
+let set_var_meta v m = match v.v_extra with
+	| Some ve ->
+		v.v_extra <- Some {ve with v_meta = m}
+	| None ->
+		let ve = var_extra [] None in
+		v.v_extra <- Some {ve with v_meta = m}
+
+let add_var_meta v m = match v.v_extra with
+	| Some ve ->
+		v.v_extra <- Some {ve with v_meta = m :: ve.v_meta}
+	| None ->
+		let ve = var_extra [] None in
+		v.v_extra <- Some {ve with v_meta = [m]}

+ 1 - 1
src/core/tOther.ml

@@ -100,7 +100,7 @@ module TExprToExpr = struct
 		| TNew (c,pl,el) -> ENew ((match (try convert_type (TInst (c,pl)) with Exit -> convert_type (TInst (c,[]))) with CTPath p -> p,null_pos | _ -> die "" __LOC__),List.map convert_expr el)
 		| TUnop (op,p,e) -> EUnop (op,p,convert_expr e)
 		| TFunction f ->
-			let arg (v,c) = (v.v_name,v.v_pos), false, v.v_meta, mk_type_hint v.v_type null_pos, (match c with None -> None | Some c -> Some (convert_expr c)) in
+			let arg (v,c) = (v.v_name,v.v_pos), false, (get_var_meta v), mk_type_hint v.v_type null_pos, (match c with None -> None | Some c -> Some (convert_expr c)) in
 			EFunction (FKAnonymous,{ f_params = []; f_args = List.map arg f.tf_args; f_type = mk_type_hint f.tf_type null_pos; f_expr = Some (convert_expr f.tf_expr) })
 		| TVar (v,eo) ->
 			EVars ([(v.v_name,v.v_pos), has_var_flag v VFinal, mk_type_hint v.v_type v.v_pos, eopt eo])

+ 1 - 1
src/core/tPrinting.ml

@@ -592,7 +592,7 @@ module Printer = struct
 			"v_type",s_type v.v_type;
 			"v_capture",string_of_bool (has_var_flag v VCaptured);
 			"v_extra",s_opt s_tvar_extra v.v_extra;
-			"v_meta",s_metadata v.v_meta;
+			"v_meta",s_metadata (get_var_meta v);
 			"v_pos",s_pos v.v_pos;
 		]
 

+ 1 - 1
src/core/tType.ml

@@ -70,6 +70,7 @@ and tconstant =
 and tvar_extra = {
 	v_params : type_params;
 	v_expr : texpr option;
+	v_meta : metadata;
 }
 
 and tvar_origin =
@@ -93,7 +94,6 @@ and tvar = {
 	mutable v_type : t;
 	mutable v_kind : tvar_kind;
 	mutable v_extra : tvar_extra option;
-	mutable v_meta : metadata;
 	mutable v_flags : int;
 	v_pos : pos;
 }

+ 1 - 1
src/core/texpr.ml

@@ -303,8 +303,8 @@ let duplicate_tvars e =
 	let vars = Hashtbl.create 0 in
 	let copy_var v =
 		let v2 = alloc_var v.v_kind v.v_name v.v_type v.v_pos in
-		v2.v_meta <- v.v_meta;
 		v2.v_extra <- v.v_extra;
+		set_var_meta v2 (get_var_meta v);
 		Hashtbl.add vars v.v_id v2;
 		v2;
 	in

+ 1 - 1
src/filters/capturedVars.ml

@@ -88,7 +88,7 @@ let captured_vars com e =
 
 	let mk_var v used =
 		let v2 = alloc_var v.v_kind v.v_name (PMap.find v.v_id used) v.v_pos in
-		v2.v_meta <- v.v_meta;
+		set_var_meta v2 (get_var_meta v);
 		v2
 	in
 

+ 4 - 4
src/filters/exceptions.ml

@@ -179,8 +179,8 @@ let throw_native ctx e_thrown t p =
 	mk (TThrow e_native) t p
 
 let set_needs_exception_stack v =
-	if not (Meta.has Meta.NeedsExceptionStack v.v_meta) then
-		v.v_meta <- (Meta.NeedsExceptionStack,[],null_pos) :: v.v_meta
+	if not (var_has_meta v Meta.NeedsExceptionStack) then
+		add_var_meta v (Meta.NeedsExceptionStack,[],null_pos)
 
 (**
 	Transform user-written `catches` to a set of catches, which would not require
@@ -433,7 +433,7 @@ let insert_save_stacks tctx =
 		let rec contains_insertion_points e =
 			match e.eexpr with
 			| TTry (e, catches) ->
-				List.exists (fun (v, _) -> Meta.has Meta.NeedsExceptionStack v.v_meta) catches
+				List.exists (fun (v, _) -> var_has_meta v Meta.NeedsExceptionStack) catches
 				|| contains_insertion_points e
 				|| List.exists (fun (_, e) -> contains_insertion_points e) catches
 			| _ ->
@@ -462,7 +462,7 @@ let insert_save_stacks tctx =
 				let e1 = map_expr run e1 in
 				let catches =
 					List.map (fun ((v, body) as catch) ->
-						if Meta.has Meta.NeedsExceptionStack v.v_meta then
+						if var_has_meta v Meta.NeedsExceptionStack then
 							let exprs =
 								match body.eexpr with
 								| TBlock exprs ->

+ 1 - 1
src/filters/tre.ml

@@ -100,7 +100,7 @@ let is_recursive_method_call cls field callee args =
 	match callee.eexpr, args with
 	(* member abstract function*)
 	| TField (_, FStatic (_, cf)), { eexpr = TLocal v } :: _ when has_meta Meta.Impl cf.cf_meta ->
-		cf == field && has_meta Meta.This v.v_meta
+		cf == field && var_has_meta v Meta.This
 	(* static method *)
 	| TField (_, FStatic (_, cf)), _ ->
 		cf == field

+ 2 - 2
src/generators/gencpp.ml

@@ -2173,7 +2173,7 @@ let ctx_function_signature ctx include_names tfun abi =
 
 
 let cpp_var_name_of var =
-   let rename = get_meta_string var.v_meta Meta.Native in
+   let rename = get_meta_string (get_var_meta var) Meta.Native in
    if rename <> "" then
       rename
    else
@@ -2186,7 +2186,7 @@ let cpp_var_debug_name_of v =
       | _ :: meta -> loop meta
       | [] -> v.v_name
    in
-   loop v.v_meta
+   loop (get_var_meta v)
 ;;
 
 

+ 1 - 1
src/generators/genhl.ml

@@ -974,7 +974,7 @@ let real_name v =
 		| (Meta.RealPath,[EConst (String(name,_)),_],_) :: _ -> name
 		| _ :: l -> loop l
 	in
-	match loop v.v_meta with
+	match loop (get_var_meta v) with
 	| "_gthis" -> "this"
 	| name -> name
 

+ 10 - 10
src/generators/genlua.ml

@@ -682,9 +682,9 @@ and gen_expr ?(local=true) ctx e = begin
         spr ctx " end )({";
         concat ctx ", " (fun ((f,_,_),e) -> print ctx "%s = " (anon_field f); gen_value ctx e) fields;
         spr ctx "})";
-    | TField ({eexpr = TLocal v}, f) when Meta.has Meta.MultiReturn v.v_meta ->
+    | TField ({eexpr = TLocal v}, f) when var_has_meta v Meta.MultiReturn ->
         (* field of a multireturn local var is actually just a local var *)
-        let (_, args, pos) =  Meta.get (Meta.Custom ":lua_mr_id") v.v_meta  in
+        let (_, args, pos) =  Meta.get (Meta.Custom ":lua_mr_id") (get_var_meta v)  in
         (match args with
          | [(EConst(String(id,_)), _)] ->
              spr ctx (id ^ "_" ^ (ident v.v_name) ^ "_" ^ (field_name f));
@@ -768,11 +768,11 @@ and gen_expr ?(local=true) ctx e = begin
                     spr ctx " = ";
                     gen_value ctx e1;
 
-                | _ when Meta.has Meta.MultiReturn v.v_meta ->
+                | _ when var_has_meta v Meta.MultiReturn ->
                     (* multi-return var is generated as several vars for unpacking *)
                     let id = temp ctx in
                     let temp_expr = (EConst(String(id,SDoubleQuotes)), Globals.null_pos) in
-                    v.v_meta <- (Meta.Custom ":lua_mr_id", [temp_expr], v.v_pos) :: v.v_meta;
+                    add_var_meta v (Meta.Custom ":lua_mr_id", [temp_expr], v.v_pos);
                     let name = ident v.v_name in
                     let names =
                         match follow v.v_type with
@@ -794,7 +794,7 @@ and gen_expr ?(local=true) ctx e = begin
 
                     (* if it was a multi-return var but it was used as a value itself, *)
                     (* we have to box it in an object conforming to a multi-return extern class *)
-                    let is_boxed_multireturn = Meta.has (Meta.Custom ":lua_mr_box") v.v_meta in
+                    let is_boxed_multireturn = var_has_meta v (Meta.Custom ":lua_mr_box") in
                     let e = if is_boxed_multireturn then mk_mr_box ctx e else e in
                     (match e.eexpr with
                     | TCast ({ eexpr = TTypeExpr mt } as e1, None) when (match mt with TClassDecl {cl_path = ([],"Array")} -> false | _ -> true) ->
@@ -1851,7 +1851,7 @@ let transform_multireturn ctx = function
                         so it will later be generated as multiple locals unpacking the value
                     *)
                     | TVar (v, Some ({ eexpr = TCall _ } as ecall)) when is_multireturn v.v_type ->
-                        v.v_meta <- (Meta.MultiReturn,[],v.v_pos) :: v.v_meta;
+						add_var_meta v (Meta.MultiReturn,[],v.v_pos);
                         let ecall = Type.map_expr loop ecall in
                         { e with eexpr = TVar (v, Some ecall) }
 
@@ -1876,7 +1876,7 @@ let transform_multireturn ctx = function
 
 
                         (* if we found a field access for a multi-return local - that's fine, because it'll be generated as a local var *)
-                    | TField ({ eexpr = TLocal v}, _) when Meta.has Meta.MultiReturn v.v_meta ->
+                    | TField ({ eexpr = TLocal v}, _) when var_has_meta v Meta.MultiReturn ->
                         e
                     | TReturn Some(e2) ->
                         if is_multireturn e2.etype then
@@ -1887,9 +1887,9 @@ let transform_multireturn ctx = function
 						if we found usage of local var we previously marked with @:multiReturn as a value itself,
 						remove the @:multiReturn meta and add "box me" meta so it'll be boxed on var initialization
 					*)
-                    | TLocal v when Meta.has Meta.MultiReturn v.v_meta ->
-                        v.v_meta <- List.filter (fun (m,_,_) -> m <> Meta.MultiReturn) v.v_meta;
-                        v.v_meta <- (Meta.Custom ":lua_mr_box", [], v.v_pos) :: v.v_meta;
+                    | TLocal v when var_has_meta v Meta.MultiReturn ->
+                        set_var_meta v (List.filter (fun (m,_,_) -> m <> Meta.MultiReturn) (get_var_meta v));
+                        add_var_meta v (Meta.Custom ":lua_mr_box", [], v.v_pos);
                         e
 
                     | _ ->

+ 2 - 2
src/generators/genpy.ml

@@ -96,7 +96,7 @@ module KeywordHandler = struct
 		else s
 
 	let check_var_declaration v =
-		if not (Meta.has Meta.This v.v_meta) then
+		if not (var_has_meta v Meta.This) then
 			if Hashtbl.mem kwds2 v.v_name then v.v_name <- "_hx_" ^ v.v_name
 end
 
@@ -1862,7 +1862,7 @@ module Generator = struct
 			| TFunction(f) ->
 				let args = if add_self then
 					let v = alloc_var VGenerated "self" t_dynamic p in
-					v.v_meta <- (Meta.This,[],p) :: v.v_meta;
+					add_var_meta v (Meta.This,[],p);
 					(v,None) :: f.tf_args
 				else
 					f.tf_args

+ 1 - 1
src/macro/macroApi.ml

@@ -1154,7 +1154,7 @@ and encode_tvar v =
 		"t", encode_type v.v_type;
 		"capture", vbool (has_var_flag v VCaptured);
 		"extra", vopt f_extra v.v_extra;
-		"meta", encode_meta v.v_meta (fun m -> v.v_meta <- m);
+		"meta", encode_meta (get_var_meta v) (fun m -> set_var_meta v m);
 		"$", encode_unsafe (Obj.repr v);
 	]
 

+ 4 - 4
src/optimization/analyzer.ml

@@ -144,7 +144,7 @@ module Ssa = struct
 			update_reaching_def ctx v bb;
 			let v' = alloc_var v.v_kind v.v_name v.v_type v.v_pos in
 			declare_var ctx.graph v' bb;
-			v'.v_meta <- v.v_meta;
+			set_var_meta v' (get_var_meta v);
 			if has_var_flag v VCaptured then add_var_flag v' VCaptured;
 			add_var_def ctx.graph bb v';
 			set_reaching_def ctx.graph v' (get_reaching_def ctx.graph v);
@@ -649,14 +649,14 @@ module LocalDce = struct
 
 	let rec apply ctx =
 		let is_used v =
-			Meta.has Meta.Used v.v_meta
+			var_has_meta v Meta.Used
 		in
 		let keep v =
-			is_used v || ((match v.v_kind with VUser _ | VInlined -> true | _ -> false) && not ctx.config.local_dce) || ExtType.has_reference_semantics v.v_type || has_var_flag v VCaptured || Meta.has Meta.This v.v_meta
+			is_used v || ((match v.v_kind with VUser _ | VInlined -> true | _ -> false) && not ctx.config.local_dce) || ExtType.has_reference_semantics v.v_type || has_var_flag v VCaptured || var_has_meta v Meta.This
 		in
 		let rec use v =
 			if not (is_used v) then begin
-				v.v_meta <- (Meta.Used,[],null_pos) :: v.v_meta;
+				add_var_meta v (Meta.Used,[],null_pos);
 				(try expr (get_var_value ctx.graph v) with Not_found -> ());
 				begin match Ssa.get_reaching_def ctx.graph v with
 					| None -> use (get_var_origin ctx.graph v)

+ 1 - 1
src/optimization/analyzerTypes.ml

@@ -210,7 +210,7 @@ module Graph = struct
 		} in
 		DynArray.add g.g_var_infos vi;
 		let i = DynArray.length g.g_var_infos - 1 in
-		v.v_extra <- Some(var_extra [] (Some (mk (TConst (TInt (Int32.of_int i))) t_dynamic null_pos)));
+		set_var_expr v (mk (TConst (TInt (Int32.of_int i))) t_dynamic null_pos);
 		vi
 
 	let get_var_info g v = match v.v_extra with

+ 6 - 6
src/optimization/inline.ml

@@ -309,7 +309,7 @@ class inline_state ctx ethis params cf f p = object(self)
 				i_var = v;
 				i_subst = v';
 				i_outside = false;
-				i_abstract_this = Meta.has Meta.This v.v_meta;
+				i_abstract_this = var_has_meta v Meta.This;
 				i_captured = false;
 				i_write = false;
 				i_called = 0;
@@ -317,7 +317,7 @@ class inline_state ctx ethis params cf f p = object(self)
 				i_read = 0;
 				i_default_value = None;
 			} in
-			i.i_subst.v_meta <- List.filter (fun (m,_,_) -> m <> Meta.This) v.v_meta;
+			set_var_meta i.i_subst (List.filter (fun (m,_,_) -> m <> Meta.This) (get_var_meta v));
 			Hashtbl.add locals v.v_id i;
 			Hashtbl.add locals i.i_subst.v_id i;
 			i
@@ -330,7 +330,7 @@ class inline_state ctx ethis params cf f p = object(self)
 				i_var = v;
 				i_subst = v;
 				i_outside = true;
-				i_abstract_this = Meta.has Meta.This v.v_meta;
+				i_abstract_this = var_has_meta v Meta.This;
 				i_captured = false;
 				i_write = false;
 				i_called = 0;
@@ -449,7 +449,7 @@ class inline_state ctx ethis params cf f p = object(self)
 					l.i_force_temp <- true;
 				end;
 				(* We use a null expression because we only care about the type (for abstract casts). *)
-				if l.i_abstract_this then l.i_subst.v_extra <- Some (var_extra [] (Some {e with eexpr = TConst TNull}));
+				if l.i_abstract_this then set_var_expr l.i_subst {e with eexpr = TConst TNull};
 				loop ((l,e) :: acc) pl al false
 			| [], (v,opt) :: al ->
 				let l = self#declare v in
@@ -598,8 +598,8 @@ class inline_state ctx ethis params cf f p = object(self)
 				if not (self#read v).i_outside then begin
 					v.v_type <- map_type v.v_type;
 					match v.v_extra with
-					| Some ({v_expr = Some e} as ve) ->
-						v.v_extra <- Some(var_extra ve.v_params (Some (map_expr_type map_type e)));
+					| Some {v_expr = Some e} ->
+						set_var_expr v (map_expr_type map_type e);
 					| _ ->
 						()
 				end

+ 2 - 2
src/typing/calls.ml

@@ -47,10 +47,10 @@ let make_call ctx e params t ?(force_inline=false) p =
 		let config = Inline.inline_config cl f params t in
 		ignore(follow f.cf_type); (* force evaluation *)
 		(match cl, ctx.curclass.cl_kind, params with
-			| Some c, KAbstractImpl _, { eexpr = TLocal { v_meta = v_meta } } :: _ when c == ctx.curclass ->
+			| Some c, KAbstractImpl _, { eexpr = TLocal v } :: _ when c == ctx.curclass ->
 				if
 					f.cf_name <> "_new"
-					&& has_meta Meta.This v_meta
+					&& var_has_meta v Meta.This
 					&& has_class_field_flag f CfModifiesThis
 				then
 					if assign_to_this_is_allowed ctx then

+ 1 - 1
src/typing/forLoop.ml

@@ -287,7 +287,7 @@ module IterationKind = struct
 		in
 		let gen_int_iter e1 pt f_get f_length =
 			let index = gen_local ctx t_int v.v_pos in
-			index.v_meta <- (Meta.ForLoopVariable,[],null_pos) :: index.v_meta;
+			add_var_meta index (Meta.ForLoopVariable,[],null_pos);
 			let arr, avars = (match e1.eexpr with
 				| TLocal _ -> e1, None
 				| _ ->

+ 1 - 1
src/typing/generic.ml

@@ -94,7 +94,7 @@ let generic_substitute_expr gctx e =
 			Hashtbl.find vars v.v_id
 		with Not_found ->
 			let v2 = alloc_var v.v_kind v.v_name (generic_substitute_type gctx v.v_type) v.v_pos in
-			v2.v_meta <- v.v_meta;
+			set_var_meta v2 (get_var_meta v);
 			Hashtbl.add vars v.v_id v2;
 			v2
 	in

+ 2 - 2
src/typing/nullSafety.ml

@@ -197,7 +197,7 @@ let get_arguments_meta callee expected_args_count =
 				empty_list expected_args_count
 			)
 		| TFunction { tf_args = args } when expected_args_count = List.length args ->
-			List.map (fun (v,_) -> v.v_meta) args
+			List.map (fun (v,_) -> get_var_meta v) args
 		| _ ->
 			empty_list expected_args_count
 
@@ -1344,7 +1344,7 @@ class expr_checker mode immediate_execution report =
 					check_both();
 					if not (self#can_pass_expr right_expr left_expr.etype p) then
 						match left_expr.eexpr with
-						| TLocal v when contains_unsafe_meta v.v_meta -> ()
+						| TLocal v when contains_unsafe_meta (get_var_meta v) -> ()
 						| _ ->
 							self#error "Cannot assign nullable value here." [p; right_expr.epos; left_expr.epos]
 					else

+ 3 - 3
src/typing/typeloadFields.ml

@@ -141,7 +141,7 @@ let get_struct_init_super_info ctx c p =
 				List.fold_left (fun (args,exprs) (v,value) ->
 					let opt = match value with
 						| Some _ -> true
-						| None -> Meta.has Meta.Optional v.v_meta
+						| None -> var_has_meta v Meta.Optional
 					in
 					let t = if opt then ctx.t.tnull v.v_type else v.v_type in
 					(v.v_name,opt,t) :: args,(mk (TLocal v) v.v_type p) :: exprs
@@ -184,8 +184,8 @@ let ensure_struct_init_constructor ctx c ast_fields p =
 				let v = alloc_var VGenerated cf.cf_name t p in
 				let ef = mk (TField(ethis,FInstance(c,params,cf))) cf.cf_type p in
 				let ev = mk (TLocal v) v.v_type p in
-				if opt && not (Meta.has Meta.Optional v.v_meta) then
-					v.v_meta <- (Meta.Optional,[],null_pos) :: v.v_meta;
+				if opt && not (var_has_meta v Meta.Optional) then
+					add_var_meta v (Meta.Optional,[],null_pos);
 				(* this.field = <constructor_argument> *)
 				let assign_expr = mk (TBinop(OpAssign,ef,ev)) cf.cf_type p in
 				let e =

+ 2 - 2
src/typing/typeloadFunction.ml

@@ -99,10 +99,10 @@ let type_function ctx args ret fmode f do_display p =
 	let fargs = List.map2 (fun (n,c,t) ((_,pn),_,m,_,_) ->
 		let c = process_function_arg ctx n t c do_display pn in
 		let v = add_local_with_origin ctx TVOArgument n t pn in
-		v.v_meta <- v.v_meta @ m;
+		set_var_meta v (get_var_meta v @ m);
 		if do_display && DisplayPosition.display_position#enclosed_in pn then
 			DisplayEmitter.display_variable ctx v pn;
-		if n = "this" then v.v_meta <- (Meta.This,[],null_pos) :: v.v_meta;
+		if n = "this" then add_var_meta v(Meta.This,[],null_pos);
 		v,c
 	) args f.f_args in
 	ctx.curfun <- fmode;

+ 7 - 6
src/typing/typer.ml

@@ -37,7 +37,7 @@ let check_assign ctx e =
 	match e.eexpr with
 	| TLocal v when has_var_flag v VFinal ->
 		error "Cannot assign to final" e.epos
-	| TLocal {v_extra = None} | TArray _ | TField _ | TIdent _ ->
+	| TLocal _ | TArray _ | TField _ | TIdent _ ->
 		()
 	| TConst TThis | TTypeExpr _ when ctx.untyped ->
 		()
@@ -640,11 +640,11 @@ let rec type_binop ctx op e1 e2 is_assign_op with_type p =
 			in
 			let l = save_locals ctx in
 			let v,init_exprs,abstr_this_to_modify = match et.eexpr with
-				| TLocal v when not (Meta.has Meta.This v.v_meta) -> v,[],None
+				| TLocal v when not (var_has_meta v Meta.This) -> v,[],None
 				| _ ->
 					let v = gen_local ctx ta ef.epos in
 					(match et.eexpr with
-					| TLocal { v_meta = m } -> v.v_meta <- Meta.copy_from_to Meta.This m v.v_meta
+					| TLocal v' -> set_var_meta v (Meta.copy_from_to Meta.This (get_var_meta v') (get_var_meta v))
 					| _ -> ()
 					);
 					let decl_v e = mk (TVar (v,Some e)) ctx.t.tvoid p in
@@ -2062,7 +2062,7 @@ and type_local_function ctx kind f with_type p =
 		| None -> None
 		| Some v ->
 			let v = (add_local_with_origin ctx TVOLocalFunction v ft pname) in
-			if params <> [] then v.v_extra <- Some (var_extra params None);
+			if params <> [] then set_var_params v params;
 			Some v
 	) in
 	let curfun = match ctx.curfun with
@@ -2083,9 +2083,10 @@ and type_local_function ctx kind f with_type p =
 	match v with
 	| None -> e
 	| Some v ->
-		Typeload.generate_args_meta ctx.com None (fun m -> v.v_meta <- m :: v.v_meta) f.f_args;
+		Typeload.generate_args_meta ctx.com None (fun m -> add_var_meta v m) f.f_args;
 		let open LocalUsage in
-		if params <> [] || inline then v.v_extra <- Some (var_extra params (if inline then Some e else None));
+		if params <> [] then set_var_params v params;
+		if inline then set_var_expr v e;
 		if ctx.in_display && DisplayPosition.display_position#enclosed_in v.v_pos then
 			DisplayEmitter.display_variable ctx v v.v_pos;
 		let rec loop = function

+ 2 - 2
src/typing/typerDisplay.ml

@@ -47,7 +47,7 @@ let completion_item_of_expr ctx e =
 		make_ci_expr e t
 	in
 	let rec loop e = match e.eexpr with
-		| TLocal v | TVar(v,_) -> make_ci_local v (tpair ~values:(get_value_meta v.v_meta) v.v_type)
+		| TLocal v | TVar(v,_) -> make_ci_local v (tpair ~values:(get_value_meta (get_var_meta v)) v.v_type)
 		| TField(e1,FStatic(c,cf)) ->
 			let te,c,cf = DisplayToplevel.maybe_resolve_macro_field ctx e.etype c cf in
 			Display.merge_core_doc ctx (TClassDecl c);
@@ -257,7 +257,7 @@ let rec handle_signature_display ctx e_ast with_type =
 				| TConst TSuper ->
 					find_constructor_types e1.etype
 				| TLocal v ->
-					[e1.etype,None,get_value_meta v.v_meta]
+					[e1.etype,None,get_value_meta (get_var_meta v)]
 				| _ -> [e1.etype,None,PMap.empty]
 			in
 			handle_call tl el e1.epos