Skip to content

Commit

Permalink
Merge pull request HaxeFoundation#2877 from HaxeFoundation/development
Browse files Browse the repository at this point in the history
3.1.3
  • Loading branch information
Simn committed Apr 13, 2014
2 parents a04aec3 + 102bf02 commit 7be3067
Show file tree
Hide file tree
Showing 47 changed files with 4,172 additions and 3,504 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ env:
- TARGET=java
- TARGET=cs
- TARGET=flash8
- TARGET=polygonal-ds
- TARGET=flambe
- TARGET=hxtemplo
- TARGET=munit
- TARGET=openfl-samples

matrix:
fast_finish: true
Expand All @@ -35,5 +40,6 @@ script:
- sudo make install
- cd tests/
- mkdir ~/haxelib && haxelib setup ~/haxelib
- haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src
- haxe -version
- haxe -main RunTravis --interp
- haxe -main RunTravis -lib hx-yaml --interp
85 changes: 83 additions & 2 deletions codegen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -770,10 +770,10 @@ module Abstract = struct
{e with etype = m}
| TCall({eexpr = TField(_,FStatic({cl_path=[],"Std"},{cf_name = "string"}))},[e1]) when (match follow e1.etype with TAbstract({a_impl = Some _},_) -> true | _ -> false) ->
begin match follow e1.etype with
| TAbstract({a_impl = Some c} as a,_) ->
| TAbstract({a_impl = Some c} as a,tl) ->
begin try
let cf = PMap.find "toString" c.cl_statics in
make_static_call ctx c cf a [] [e1] ctx.t.tstring e.epos
make_static_call ctx c cf a tl [e1] ctx.t.tstring e.epos
with Not_found ->
e
end
Expand Down Expand Up @@ -1621,3 +1621,84 @@ module UnificationCallback = struct
| _ ->
check (Type.map_expr (run f) e)
end;;

module DeprecationCheck = struct

let curclass = ref null_class

let warned_positions = Hashtbl.create 0

let print_deprecation_message com meta s p_usage =
let s = match meta with
| _,[EConst(String s),_],_ -> s
| _ -> Printf.sprintf "Usage of this %s is deprecated" s
in
if not (Hashtbl.mem warned_positions p_usage) then begin
Hashtbl.replace warned_positions p_usage true;
com.warning s p_usage;
end

let check_meta com meta s p_usage =
try
print_deprecation_message com (Meta.get Meta.Deprecated meta) s p_usage;
with Not_found ->
()

let check_cf com cf p = check_meta com cf.cf_meta "field" p

let check_class com c p = if c != !curclass then check_meta com c.cl_meta "class" p

let check_enum com en p = check_meta com en.e_meta "enum" p

let check_ef com ef p = check_meta com ef.ef_meta "enum field" p

let check_typedef com t p = check_meta com t.t_meta "typedef" p

let check_module_type com mt p = match mt with
| TClassDecl c -> check_class com c p
| TEnumDecl en -> check_enum com en p
| _ -> ()

let run com =
let rec expr e = match e.eexpr with
| TField(e1,fa) ->
expr e1;
begin match fa with
| FStatic(c,cf) | FInstance(c,cf) ->
check_class com c e.epos;
check_cf com cf e.epos
| FAnon cf ->
check_cf com cf e.epos
| FClosure(co,cf) ->
(match co with None -> () | Some c -> check_class com c e.epos);
check_cf com cf e.epos
| FEnum(en,ef) ->
check_enum com en e.epos;
check_ef com ef e.epos;
| _ ->
()
end
| TNew(c,_,el) ->
List.iter expr el;
check_class com c e.epos;
(match c.cl_constructor with None -> () | Some cf -> check_cf com cf e.epos)
| TTypeExpr(mt) | TCast(_,Some mt) ->
check_module_type com mt e.epos
| TMeta((Meta.Deprecated,_,_) as meta,e1) ->
print_deprecation_message com meta "field" e1.epos;
expr e1;
| _ ->
Type.iter expr e
in
List.iter (fun t -> match t with
| TClassDecl c ->
curclass := c;
let field cf = match cf.cf_expr with None -> () | Some e -> expr e in
(match c.cl_constructor with None -> () | Some cf -> field cf);
(match c.cl_init with None -> () | Some e -> expr e);
List.iter field c.cl_ordered_statics;
List.iter field c.cl_ordered_fields;
| _ ->
()
) com.types
end
8 changes: 5 additions & 3 deletions common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ module Define = struct
| Dce
| DceDebug
| Debug
| DeprecationWarnings
| Display
| DllExport
| DllImport
Expand Down Expand Up @@ -201,7 +200,9 @@ module Define = struct
| NetTarget
| NoCompilation
| NoCOpt
| NoDeprecationWarnings
| NoFlashOverride
| NoDebug
| NoInline
| NoOpt
| NoPatternMatching
Expand Down Expand Up @@ -243,7 +244,6 @@ module Define = struct
| Dce -> ("dce","The current DCE mode")
| DceDebug -> ("dce_debug","Show DCE log")
| Debug -> ("debug","Activated when compiling with -debug")
| DeprecationWarnings -> ("deprecation-warnings","Warn if fields annotated with @:deprecated are used")
| Display -> ("display","Activated during completion")
| DllExport -> ("dll_export", "GenCPP experimental linking")
| DllImport -> ("dll_import", "GenCPP experimental linking")
Expand Down Expand Up @@ -273,6 +273,8 @@ module Define = struct
| NetworkSandbox -> ("network-sandbox","Use local network sandbox instead of local file access one")
| NoCompilation -> ("no-compilation","Disable CPP final compilation")
| NoCOpt -> ("no_copt","Disable completion optimization (for debug purposes)")
| NoDebug -> ("no_debug","Remove all debug macros from cpp output")
| NoDeprecationWarnings -> ("no-deprecation-warnings","Do not warn if fields annotated with @:deprecated are used")
| NoFlashOverride -> ("no-flash-override", "Change overrides on some basic classes into HX suffixed methods, flash only")
| NoOpt -> ("no_opt","Disable optimizations")
| NoPatternMatching -> ("no_pattern_matching","Disable pattern matching")
Expand Down Expand Up @@ -890,7 +892,7 @@ let find_file ctx f =
(match r with
| None -> raise Not_found
| Some f -> f)


let get_full_path f = try Extc.get_full_path f with _ -> f

Expand Down
23 changes: 22 additions & 1 deletion extra/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
2014-03-39: 3.1.2
2014-04-13: 3.1.3

Bugfixes:

all : fixed handling of abstract variance
flash : ensure correct endianess in haxe.io.BytesBuffer
cpp : fixed issue involving class paths with spaces
php : fixed >>>
macro : fixed haxe.macro.Compiler.keep

General improvements and optimizations:

all : give @:deprecated warnings by default, allow -D no-deprecation-warnings
cpp : optimized Vector implementation

Standard Library:

all : renamed Bytes.readDouble/Float to getDouble/Float to avoid inheritance issues
all : deprecated Bytes.readString in favor of getString
all : added pretty-printing to haxe.format.JsonPrinter (and haxe.Json)

2014-03-29: 3.1.2

Bugfixes:

Expand Down
70 changes: 2 additions & 68 deletions filters.ml
Original file line number Diff line number Diff line change
Expand Up @@ -797,72 +797,6 @@ let rename_local_vars com e =
loop e;
e

let check_deprecation com =
let curclass = ref null_class in
let definition_positions = (Common.defined_value_safe com Define.DeprecationWarnings) = "def-pos" in
let warned_positions = Hashtbl.create 0 in
let get_deprecation_message meta s p_usage p_definition =
try
let s = match Meta.get Meta.Deprecated meta with
| _,[EConst(String s),_],_ -> s
| _ -> Printf.sprintf "Usage of this %s is deprecated" s
in
if not (Hashtbl.mem warned_positions p_usage) then begin
Hashtbl.replace warned_positions p_usage true;
com.warning s p_usage;
end;
if definition_positions then com.warning "Defined here" p_definition
with Not_found ->
()
in
let check_cf cf p = get_deprecation_message cf.cf_meta "field" p cf.cf_pos in
let check_class c p = if c != !curclass then get_deprecation_message c.cl_meta "class" p c.cl_pos in
let check_enum en p = get_deprecation_message en.e_meta "enum" p en.e_pos in
let check_ef ef p = get_deprecation_message ef.ef_meta "enum field" p ef.ef_pos in
let check_module_type mt p = match mt with
| TClassDecl c -> check_class c p
| TEnumDecl en -> check_enum en p
| _ -> ()
in
let rec expr e = match e.eexpr with
| TField(e1,fa) ->
expr e1;
begin match fa with
| FStatic(c,cf) | FInstance(c,cf) ->
check_class c e.epos;
check_cf cf e.epos
| FAnon cf ->
check_cf cf e.epos
| FClosure(co,cf) ->
(match co with None -> () | Some c -> check_class c e.epos);
check_cf cf e.epos
| FEnum(en,ef) ->
check_enum en e.epos;
check_ef ef e.epos;
| _ ->
()
end
| TNew(c,_,el) ->
List.iter expr el;
check_class c e.epos;
(match c.cl_constructor with None -> () | Some cf -> check_cf cf e.epos)
| TTypeExpr(mt) | TCast(_,Some mt) ->
check_module_type mt e.epos
| _ ->
Type.iter expr e
in
List.iter (fun t -> match t with
| TClassDecl c ->
curclass := c;
let field cf = match cf.cf_expr with None -> () | Some e -> expr e in
(match c.cl_constructor with None -> () | Some cf -> field cf);
(match c.cl_init with None -> () | Some e -> expr e);
List.iter field c.cl_ordered_statics;
List.iter field c.cl_ordered_fields;
| _ ->
()
) com.types

let check_unification com e t =
begin match follow e.etype,follow t with
| TEnum _,TDynamic _ ->
Expand Down Expand Up @@ -1142,8 +1076,8 @@ let post_process_end() =
let run com tctx main =
if com.display = DMUsage then
Codegen.detect_usage com;
if Common.defined com Define.DeprecationWarnings then
check_deprecation com;
if not (Common.defined com Define.NoDeprecationWarnings) then
Codegen.DeprecationCheck.run com;

(* PASS 1: general expression filters *)
let filters = [
Expand Down
21 changes: 18 additions & 3 deletions gencommon.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5714,6 +5714,9 @@ struct
mk_cast to_t e)
| TAbstract (a_to, _), TAbstract(a_from, _) when a_to == a_from ->
e
| TAbstract _, TInst({ cl_kind = KTypeParameter _ }, _)
| TInst({ cl_kind = KTypeParameter _ }, _), TAbstract _ ->
do_unsafe_cast()
| TAbstract _, _
| _, TAbstract _ ->
(try
Expand Down Expand Up @@ -7358,6 +7361,14 @@ struct
let do_field cf cf_type is_static =
let get_field ethis = { eexpr = TField (ethis, if is_static then FStatic (cl, cf) else FInstance(cl, cf)); etype = cf_type; epos = pos } in
let this = if is_static then mk_classtype_access cl pos else { eexpr = TConst(TThis); etype = t; epos = pos } in
let value_local = if is_float then match follow cf_type with
| TInst({ cl_kind = KTypeParameter _ }, _) ->
mk_cast t_dynamic value_local
| _ ->
value_local
else
value_local
in

let ret =
{
Expand Down Expand Up @@ -7450,7 +7461,7 @@ struct
let do_field cf cf_type static =
let this = if static then mk_classtype_access cl pos else { eexpr = TConst(TThis); etype = t; epos = pos } in
match is_float, follow cf_type with
| true, TInst( { cl_kind = KTypeParameter _ }, [] ) ->
| true, TInst( { cl_kind = KTypeParameter _ }, _ ) ->
mk_return (mk_cast basic.tfloat (mk_cast t_dynamic (get_field cf cf_type this cl cf.cf_name)))
| _ ->
mk_return (maybe_cast (get_field cf cf_type this cl cf.cf_name ))
Expand Down Expand Up @@ -9154,11 +9165,15 @@ struct
| (conds,e) :: tl ->
{ eexpr = TIf(mk_many_cond conds, run e, Some(loop tl)); etype = e.etype; epos = e.epos }
| [] -> match default with
| None -> gen.gcon.error "Empty switch" e.epos; assert false
| None ->
raise Exit
| Some d -> run d
in

{ e with eexpr = TBlock(fst_block @ [loop cases]) }
try
{ e with eexpr = TBlock(fst_block @ [loop cases]) }
with | Exit ->
{ e with eexpr = TBlock [] }
end
| _ -> Type.map_expr run e
in
Expand Down
Loading

0 comments on commit 7be3067

Please sign in to comment.