瀏覽代碼

Merge branch 'development' of github.com:HaxeFoundation/haxe into development

Nicolas Cannasse 12 年之前
父節點
當前提交
f8c23e9041
共有 100 個文件被更改,包括 2184 次插入2356 次删除
  1. 68 1
      README.md
  2. 14 0
      ast.ml
  3. 158 38
      codegen.ml
  4. 16 0
      common.ml
  5. 17 17
      doc/CHANGES.txt
  6. 1 1
      doc/ImportAll.hx
  7. 0 202
      doc/install.ml
  8. 2 2
      doc/setup.cpp
  9. 10 51
      genas3.ml
  10. 40 58
      gencommon.ml
  11. 32 74
      gencpp.ml
  12. 6 3
      gencs.ml
  13. 8 5
      genjava.ml
  14. 10 60
      genjs.ml
  15. 80 57
      genneko.ml
  16. 16 52
      genphp.ml
  17. 7 3
      genswf8.ml
  18. 17 10
      genswf9.ml
  19. 10 13
      genxml.ml
  20. 11 6
      interp.ml
  21. 30 8
      main.ml
  22. 260 362
      matcher.ml
  23. 20 11
      optimizer.ml
  24. 48 44
      parser.ml
  25. 96 80
      std/Array.hx
  26. 1 1
      std/Class.hx
  27. 28 25
      std/Date.hx
  28. 7 7
      std/DateTools.hx
  29. 34 34
      std/EReg.hx
  30. 2 2
      std/Enum.hx
  31. 1 1
      std/EnumValue.hx
  32. 3 3
      std/IntIterator.hx
  33. 39 39
      std/Lambda.hx
  34. 21 21
      std/List.hx
  35. 23 22
      std/Map.hx
  36. 38 38
      std/Math.hx
  37. 50 48
      std/Reflect.hx
  38. 15 15
      std/Std.hx
  39. 19 8
      std/StdTypes.hx
  40. 47 47
      std/String.hx
  41. 22 13
      std/StringBuf.hx
  42. 56 52
      std/StringTools.hx
  43. 62 63
      std/Type.hx
  44. 2 2
      std/Xml.hx
  45. 8 0
      std/cpp/_std/StringBuf.hx
  46. 0 10
      std/cpp/_std/haxe/ds/StringMap.hx
  47. 5 5
      std/cpp/_std/sys/FileSystem.hx
  48. 3 3
      std/cpp/_std/sys/io/File.hx
  49. 1 0
      std/cs/StringBuilder.hx
  50. 0 69
      std/cs/_std/Array.hx
  51. 0 47
      std/cs/_std/Date.hx
  52. 3 3
      std/cs/_std/EReg.hx
  53. 1 50
      std/cs/_std/Reflect.hx
  54. 1 1
      std/cs/_std/String.hx
  55. 6 0
      std/cs/_std/StringBuf.hx
  56. 1 68
      std/cs/_std/Sys.hx
  57. 1 1
      std/cs/_std/Type.hx
  58. 1 4
      std/cs/_std/haxe/Int64.hx
  59. 1 1
      std/cs/_std/haxe/ds/IntMap.hx
  60. 4 34
      std/cs/_std/sys/FileSystem.hx
  61. 2 5
      std/cs/_std/sys/io/File.hx
  62. 0 3
      std/cs/_std/sys/io/FileInput.hx
  63. 0 3
      std/cs/_std/sys/io/FileOutput.hx
  64. 1 1
      std/haxe/CallStack.hx
  65. 10 10
      std/haxe/EnumFlags.hx
  66. 31 31
      std/haxe/EnumTools.hx
  67. 25 24
      std/haxe/Http.hx
  68. 1 1
      std/haxe/Json.hx
  69. 3 3
      std/haxe/Log.hx
  70. 4 4
      std/haxe/Resource.hx
  71. 14 13
      std/haxe/Serializer.hx
  72. 9 9
      std/haxe/Template.hx
  73. 19 19
      std/haxe/Timer.hx
  74. 19 16
      std/haxe/Unserializer.hx
  75. 3 3
      std/haxe/Utf8.hx
  76. 8 7
      std/haxe/ds/ArraySort.hx
  77. 64 10
      std/haxe/ds/BalancedTree.hx
  78. 6 0
      std/haxe/ds/EnumValueMap.hx
  79. 29 14
      std/haxe/ds/GenericStack.hx
  80. 12 13
      std/haxe/ds/IntMap.hx
  81. 40 0
      std/haxe/ds/ObjectMap.hx
  82. 11 14
      std/haxe/ds/StringMap.hx
  83. 23 21
      std/haxe/ds/Vector.hx
  84. 40 1
      std/haxe/ds/WeakMap.hx
  85. 15 0
      std/haxe/io/BytesBuffer.hx
  86. 15 1
      std/haxe/io/BytesInput.hx
  87. 7 0
      std/haxe/io/BytesOutput.hx
  88. 44 25
      std/haxe/io/Path.hx
  89. 132 37
      std/haxe/macro/Context.hx
  90. 1 1
      std/haxe/macro/JSGenApi.hx
  91. 33 33
      std/haxe/macro/Printer.hx
  92. 41 0
      std/haxe/macro/Type.hx
  93. 16 16
      std/haxe/macro/TypeTools.hx
  94. 1 1
      std/haxe/remoting/SocketProtocol.hx
  95. 2 0
      std/haxe/rtti/CType.hx
  96. 16 1
      std/haxe/rtti/XmlParser.hx
  97. 0 69
      std/java/_std/Array.hx
  98. 0 46
      std/java/_std/Date.hx
  99. 3 3
      std/java/_std/EReg.hx
  100. 1 3
      std/java/_std/Math.hx

+ 68 - 1
README.md

@@ -1 +1,68 @@
-See http://haxe.org
+![Haxe logo](http://haxe.org/img/haxe2/logo.png)
+# [Haxe - The Cross-Platform Toolkit](http://haxe.org)
+
+Haxe is an open source toolkit that allows you to easily build cross-platform tools and applications that target many mainstream platforms. The Haxe toolkit includes:
+
+ * **The Haxe programming language**, a modern, high-level, strictly-typed programming language
+ * **The Haxe cross-compiler**, a state-of-the-art, lightning-speed compiler for many targets
+ * **The Haxe standard library**, a complete, cross-platform library of common functionality
+
+Haxe allows you to compile for the following targets:
+
+ * C++
+ * C#
+ * Flash
+ * Java
+ * JavaScript
+ * NekoVM
+ * PHP
+
+You can try Haxe directly from your browser at [try.haxe.org](http://try.haxe.org)!
+
+For more information about Haxe, head to the [offical Haxe website](http://haxe.org).
+
+## License 
+
+The Haxe project has several licenses, covering different parts of the projects.
+
+ * The Haxe compiler is released under the GNU General Public License version 2 or any later version.
+ * The Haxe libraries are released under a "two-clause" BSD license.
+ * The Neko runtime is licensed under the GNU Lesser General Public License version 2.1 or any later version.
+
+For the complete Haxe licenses, please see http://haxe.org/doc/license or [doc/LICENSE.txt](doc/LICENSE.txt).
+
+## Installing Haxe
+
+The latest stable release is [Haxe v3.0](http://haxe.org/download). Pre-built binaries are available for your platform:
+
+ * **[Windows installer](http://haxe.org/file/haxe-3.0.0-win.exe)**
+ * **[OSX installer](http://haxe.org/file/haxe-3.0.0-osx-installer.dmg)**
+ * **[Linux 32-bit binaries](http://haxe.org/file/haxe-3.0.0-linux32.tar.gz)**
+ * **[Linux 64-bit binaries](http://haxe.org/file/haxe-3.0.0-linux64.tar.gz)**
+
+## Building from source
+
+ 1. Clone the repository using git. Be sure to initialize and fetch the submodules.
+
+        git clone git://github.com/HaxeFoundation/haxe.git
+        cd haxe
+        git submodule init
+        git submodule update
+
+ 2. Follow the [documentation on building Haxe for your platform](http://haxe.org/doc/build).
+
+## Using Haxe
+
+For information on on using Haxe, consult the [Haxe documentation](http://haxe.org/doc):
+
+ * [Haxe introduction](http://haxe.org/doc/intro), an introduction to the Haxe toolkit
+ * [Haxe language reference](http://haxe.org/ref), an overview of the Haxe programming language
+ * [Haxe API](http://haxe.org/api), a reference for the Haxe standard and native APIs
+ * [Haxelib](http://lib.haxe.org/), a repository of Haxe libraries for a variety of needs
+
+## Community
+
+The can get help and talk with fellow Haxers from around the world via:
+
+ * the [official Haxe Google Group](https://groups.google.com/forum/#!forum/haxelang)
+ * the [Haxe IRC chatroom](http://unic0rn.github.io/tiramisu/haxe/), #haxe on chat.freenode.net

+ 14 - 0
ast.ml

@@ -54,6 +54,7 @@ module Meta = struct
 		| DynamicObject
 		| Enum
 		| EnumConstructorParam
+		| Exhaustive
 		| Expose
 		| Extern
 		| FakeEnum
@@ -84,6 +85,7 @@ module Meta = struct
 		| Meta
 		| Macro
 		| MaybeUsed
+		| MatchAny
 		| MultiType
 		| Native
 		| NativeGen
@@ -136,6 +138,9 @@ module Meta = struct
 
 	let has m ml = List.exists (fun (m2,_,_) -> m = m2) ml
 	let get m ml = List.find (fun (m2,_,_) -> m = m2) ml
+
+	let to_string_ref = ref (fun _ -> assert false)
+	let to_string (m : strict_meta) : string = !to_string_ref m
 end
 
 type keyword =
@@ -676,3 +681,12 @@ let map_expr loop (e,p) =
 	| EMeta (m,e) -> EMeta(m, loop e)
 	) in
 	(e,p)
+
+let rec s_expr (e,_) =
+	match e with
+	| EConst c -> s_constant c
+	| EParenthesis e -> "(" ^ (s_expr e) ^ ")"
+	| EArrayDecl el -> "[" ^ (String.concat "," (List.map s_expr el)) ^ "]"
+	| EObjectDecl fl -> "{" ^ (String.concat "," (List.map (fun (n,e) -> n ^ ":" ^ (s_expr e)) fl)) ^ "}"
+	| EBinop (op,e1,e2) -> s_expr e1 ^ s_binop op ^ s_expr e2
+	| _ -> "'???'"

+ 158 - 38
codegen.ml

@@ -851,18 +851,32 @@ let rec local_usage f e =
 				local_usage f e;
 			))
 		) catchs;
-	| TMatch (e,_,cases,def) ->
-		local_usage f e;
-		List.iter (fun (_,vars,e) ->
-			let cc f =
-				(match vars with
-				| None -> ()
-				| Some l ->	List.iter (function None -> () | Some v -> f (Declare v)) l);
+	| TPatMatch dt ->
+		List.iter (fun (v,eo) ->
+			f (Declare v);
+			match eo with None -> () | Some e -> local_usage f e
+		) dt.dt_var_init;
+		let rec fdt dt = match dt with
+			| DTBind(bl,dt) ->
+				List.iter (fun ((v,_),e) ->
+					f (Declare v);
+					local_usage f e
+				) bl;
+				fdt dt
+			| DTExpr e -> local_usage f e
+			| DTGuard(e,dt1,dt2) ->
 				local_usage f e;
-			in
-			f (Block cc)
-		) cases;
-		(match def with None -> () | Some e -> local_usage f e);
+				fdt dt1;
+				(match dt2 with None -> () | Some dt -> fdt dt)
+			| DTSwitch(e,cl) ->
+				local_usage f e;
+				List.iter (fun (e,dt) ->
+					local_usage f e;
+					fdt dt
+				) cl
+			| DTGoto _ -> ()
+		in
+		Array.iter fdt dt.dt_dt_lookup
 	| _ ->
 		iter (local_usage f) e
 
@@ -924,7 +938,8 @@ let captured_vars com e =
 					v, e
 			) catchs in
 			mk (TTry (wrap used expr,catchs)) e.etype e.epos
-		| TMatch (expr,enum,cases,def) ->
+		(* TODO: find out this does *)
+(* 		| TMatch (expr,enum,cases,def) ->
 			let cases = List.map (fun (il,vars,e) ->
 				let pos = e.epos in
 				let e = ref (wrap used e) in
@@ -943,7 +958,7 @@ let captured_vars com e =
 				il, vars, !e
 			) cases in
 			let def = match def with None -> None | Some e -> Some (wrap used e) in
-			mk (TMatch (wrap used expr,enum,cases,def)) e.etype e.epos
+			mk (TMatch (wrap used expr,enum,cases,def)) e.etype e.epos *)
 		| TFunction f ->
 			(*
 				list variables that are marked as used, but also used in that
@@ -1176,17 +1191,29 @@ let rename_local_vars com e =
 				loop e;
 				old()
 			) catchs;
-		| TMatch (e,_,cases,def) ->
-			loop e;
-			List.iter (fun (_,vars,e) ->
-				let old = save() in
-				(match vars with
-				| None -> ()
-				| Some l ->	List.iter (function None -> () | Some v -> declare v e.epos) l);
-				loop e;
-				old();
-			) cases;
-			(match def with None -> () | Some e -> loop e);
+		| TPatMatch dt ->
+			let rec fdt dt = match dt with
+				| DTSwitch(e,cl) ->
+					loop e;
+					List.iter (fun (_,dt) ->
+						let old = save() in
+						fdt dt;
+						old();
+					) cl;
+				| DTBind(bl,dt) ->
+					List.iter (fun ((v,p),e) ->
+						declare v e.epos
+					) bl;
+					fdt dt
+				| DTExpr e -> loop e;
+				| DTGuard(e,dt1,dt2) ->
+					loop e;
+					fdt dt1;
+					(match dt2 with None -> () | Some dt -> fdt dt)
+				| DTGoto _ ->
+					()
+			in
+			Array.iter fdt dt.dt_dt_lookup
 		| TTypeExpr t ->
 			check t
 		| TNew (c,_,_) ->
@@ -1289,21 +1316,35 @@ let check_local_vars_init e =
 				v
 			) cases in
 			(match def with
+			| None when (match e.eexpr with TMeta((Meta.Exhaustive,_,_),_) | TParenthesis({eexpr = TMeta((Meta.Exhaustive,_,_),_)}) -> true | _ -> false) ->
+				(match cvars with
+				| cv :: cvars ->
+					PMap.iter (fun i b -> if b then vars := PMap.add i b !vars) cv;
+					join vars cvars
+				| [] -> ())
 			| None -> ()
 			| Some e ->
 				loop vars e;
 				join vars cvars)
-		| TMatch (e,_,cases,def) ->
-			loop vars e;
-			let old = !vars in
-			let cvars = List.map (fun (_,vl,e) ->
-				vars := old;
-				loop vars e;
-				restore vars old [];
-				!vars
-			) cases in
-			(match def with None -> () | Some e -> vars := old; loop vars e);
-			join vars cvars
+		| TPatMatch dt ->
+			let cvars = ref [] in
+			let rec fdt dt = match dt with
+				| DTExpr e ->
+					let old = !vars in
+					loop vars e;
+					restore vars old [];
+					cvars := !vars :: !cvars
+				| DTSwitch(e,cl) ->
+					loop vars e;
+					List.iter (fun (_,dt) -> fdt dt) cl
+				| DTGuard(e,dt1,dt2) ->
+					fdt dt1;
+					(match dt2 with None -> () | Some dt -> fdt dt)
+				| DTBind(_,dt) -> fdt dt
+				| DTGoto _ -> ()
+			in
+			Array.iter fdt dt.dt_dt_lookup;
+			join vars !cvars
 		(* mark all reachable vars as initialized, since we don't exit the block  *)
 		| TBreak | TContinue | TReturn None ->
 			vars := PMap.map (fun _ -> true) !vars
@@ -1354,7 +1395,7 @@ module Abstract = struct
 		| Some { eexpr = TFunction fd } when cf.cf_kind = Method MethInline ->
 			let config = if Meta.has Meta.Impl cf.cf_meta then (Some (a.a_types <> [] || cf.cf_params <> [], map)) else None in
 			(match Optimizer.type_inline ctx cf fd ethis args t config p true with
-				| Some e -> (match e.eexpr with TCast(e,None) -> e | _ -> e)
+				| Some e -> e
 				| None -> def())
 		| _ ->
 			def()
@@ -1531,6 +1572,85 @@ module Abstract = struct
 	let handle_abstract_casts ctx e =
 		loop ctx e
 end
+
+module PatternMatchConversion = struct
+
+ 	type cctx = {
+		ctx : typer;
+		mutable eval_stack : ((tvar * pos) * texpr) list list;
+		dt_lookup : dt array;
+	}
+
+	let group_cases cases =
+		let dt_eq dt1 dt2 = match dt1,dt2 with
+			| DTGoto i1, DTGoto i2 when i1 = i2 -> true
+			(* TODO equal bindings *)
+			| _ -> false
+		in
+		match List.rev cases with
+		| [] -> []
+		| [con,dt] -> [[con],dt]
+		| (con,dt) :: cases ->
+			let tmp,ldt,cases = List.fold_left (fun (tmp,ldt,acc) (con,dt) ->
+				if dt_eq dt ldt then
+					(con :: tmp,dt,acc)
+				else
+					([con],dt,(tmp,ldt) :: acc)
+			) ([con],dt,[]) cases in
+			match tmp with
+			| [] -> cases
+			| tmp -> ((tmp,ldt) :: cases)
+
+	let rec convert_dt cctx dt =
+		match dt with
+		| DTBind (bl,dt) ->
+			cctx.eval_stack <- bl :: cctx.eval_stack;
+			let e = convert_dt cctx dt in
+			cctx.eval_stack <- List.tl cctx.eval_stack;
+			mk (TBlock [
+				mk (TVars (List.map (fun ((v,_),e) -> v,Some e) bl)) cctx.ctx.t.tvoid e.epos;
+				e
+			]) e.etype e.epos
+		| DTGoto i ->
+			convert_dt cctx (cctx.dt_lookup.(i))
+		| DTExpr e ->
+			e
+		| DTGuard(e,dt1,dt2) ->
+			let ethen = convert_dt cctx dt1 in
+			mk (TIf(e,ethen,match dt2 with None -> None | Some dt -> Some (convert_dt cctx dt))) ethen.etype (punion e.epos ethen.epos)
+		| DTSwitch(e_st,cl) ->
+			let def = ref None in
+			let cases = List.filter (fun (e,dt) ->
+ 				match e.eexpr with
+ 				| TMeta((Meta.MatchAny,_,_),_) ->
+					def := Some (convert_dt cctx dt);
+					false
+				| _ ->
+					true
+			) cl in
+			let cases = group_cases cases in
+			let cases = List.map (fun (cl,dt) -> cl,convert_dt cctx dt) cases in
+			mk (TSwitch(e_st,cases,!def)) (mk_mono()) e_st.epos
+
+	let to_typed_ast ctx dt p =
+		let first = dt.dt_dt_lookup.(dt.dt_first) in
+		let cctx = {
+			ctx = ctx;
+			dt_lookup = dt.dt_dt_lookup;
+			eval_stack = [];
+		} in
+		let e = convert_dt cctx first in
+		let e = { e with epos = p; etype = dt.dt_type} in
+		if dt.dt_var_init = [] then
+			e
+		else begin
+			mk (TBlock [
+				mk (TVars dt.dt_var_init) t_dynamic e.epos;
+				e;
+			]) dt.dt_type e.epos
+		end
+end
+
 (* -------------------------------------------------------------------------- *)
 (* USAGE *)
 
@@ -1854,11 +1974,11 @@ let rec constructor_side_effects e =
 		true
 	| TField (_,FEnum _) ->
 		false
-	| TUnop _ | TArray _ | TField _ | TCall _ | TNew _ | TFor _ | TWhile _ | TSwitch _ | TMatch _ | TReturn _ | TThrow _ ->
+	| TUnop _ | TArray _ | TField _ | TEnumParameter _ | TCall _ | TNew _ | TFor _ | TWhile _ | TSwitch _ | TPatMatch _ | TReturn _ | TThrow _ ->
 		true
 	| TBinop _ | TTry _ | TIf _ | TBlock _ | TVars _
 	| TFunction _ | TArrayDecl _ | TObjectDecl _
-	| TParenthesis _ | TTypeExpr _ | TLocal _
+	| TParenthesis _ | TTypeExpr _ | TLocal _ | TMeta _
 	| TConst _ | TContinue | TBreak | TCast _ ->
 		try
 			Type.iter (fun e -> if constructor_side_effects e then raise Exit) e;

+ 16 - 0
common.ml

@@ -93,6 +93,8 @@ type platform_config = {
 	pf_add_final_return : bool;
 	(** does the platform natively support overloaded functions *)
 	pf_overload : bool;
+	(** does the platform generator handle pattern matching *)
+	pf_pattern_matching : bool;
 }
 
 type context = {
@@ -311,6 +313,7 @@ module MetaInfo = struct
 		| DynamicObject -> ":dynamicObject",("Used internally to identify the Dynamic Object implementation",[Platforms [Java;Cs]; UsedOn TClass; Internal])
 		| Enum -> ":enum",("Used internally to annotate a class that was generated from an enum",[Platforms [Java;Cs]; UsedOn TClass; Internal])
 		| EnumConstructorParam -> ":enumConstructorParam",("Used internally to annotate GADT type parameters",[UsedOn TClass; Internal])
+		| Exhaustive -> ":exhaustive",("",[Internal])
 		| Expose -> ":expose",("Makes the class available on the window object",[HasParam "?Name=Class path";UsedOn TClass;Platform Js])
 		| Extern -> ":extern",("Marks the field as extern so it is not generated",[UsedOn TClassField])
 		| FakeEnum -> ":fakeEnum",("Treat enum as collection of values of the specified type",[HasParam "Type name";UsedOn TEnum])
@@ -341,6 +344,7 @@ module MetaInfo = struct
 		| Meta -> ":meta",("Internally used to mark a class field as being the metadata field",[])
 		| Macro -> ":macro",("(deprecated)",[])
 		| MaybeUsed -> ":maybeUsed",("Internally used by DCE to mark fields that might be kept",[Internal])
+		| MatchAny -> ":matchAny",("Internally used to mark the default case when pattern matching",[Internal])
 		| MultiType -> ":multiType",("Specifies that an abstract chooses its this-type from its @:to functions",[UsedOn TAbstract])
 		| Native -> ":native",("Rewrites the path of a class or enum during generation",[HasParam "Output type path";UsedOnEither [TClass;TEnum]])
 		| NativeGen -> ":nativeGen",("Annotates that a type should be treated as if it were an extern definition - platform native",[Platforms [Java;Cs]; UsedOnEither[TClass;TEnum]])
@@ -432,6 +436,7 @@ let default_config =
 		pf_pad_nulls = false;
 		pf_add_final_return = false;
 		pf_overload = false;
+		pf_pattern_matching = false;
 	}
 
 let get_config com =
@@ -451,6 +456,7 @@ let get_config com =
 			pf_pad_nulls = false;
 			pf_add_final_return = false;
 			pf_overload = false;
+			pf_pattern_matching = false;
 		}
 	| Js ->
 		{
@@ -464,6 +470,7 @@ let get_config com =
 			pf_pad_nulls = false;
 			pf_add_final_return = false;
 			pf_overload = false;
+			pf_pattern_matching = false;
 		}
 	| Neko ->
 		{
@@ -477,6 +484,7 @@ let get_config com =
 			pf_pad_nulls = true;
 			pf_add_final_return = false;
 			pf_overload = false;
+			pf_pattern_matching = false;
 		}
 	| Flash when defined Define.As3 ->
 		{
@@ -490,6 +498,7 @@ let get_config com =
 			pf_pad_nulls = false;
 			pf_add_final_return = true;
 			pf_overload = false;
+			pf_pattern_matching = false;
 		}
 	| Flash ->
 		{
@@ -503,6 +512,7 @@ let get_config com =
 			pf_pad_nulls = false;
 			pf_add_final_return = false;
 			pf_overload = false;
+			pf_pattern_matching = false;
 		}
 	| Php ->
 		{
@@ -521,6 +531,7 @@ let get_config com =
 			pf_pad_nulls = true;
 			pf_add_final_return = false;
 			pf_overload = false;
+			pf_pattern_matching = false;
 		}
 	| Cpp ->
 		{
@@ -534,6 +545,7 @@ let get_config com =
 			pf_pad_nulls = true;
 			pf_add_final_return = true;
 			pf_overload = false;
+			pf_pattern_matching = false;
 		}
 	| Cs ->
 		{
@@ -547,6 +559,7 @@ let get_config com =
 			pf_pad_nulls = true;
 			pf_add_final_return = false;
 			pf_overload = true;
+			pf_pattern_matching = false;
 		}
 	| Java ->
 		{
@@ -560,6 +573,7 @@ let get_config com =
 			pf_pad_nulls = true;
 			pf_add_final_return = false;
 			pf_overload = true;
+			pf_pattern_matching = false;
 		}
 
 let create v args =
@@ -824,3 +838,5 @@ let rec close_times() =
 	| [] -> ()
 	| t :: _ -> close t; close_times()
 
+;;
+Ast.Meta.to_string_ref := fun m -> fst (MetaInfo.to_string m)

+ 17 - 17
doc/CHANGES.txt

@@ -280,7 +280,7 @@
 	all : added --dead-code-elimination, removes unused functions from the output
 	     (beta feature could not make in the final release)
 	all : added @:keep to prevent --dead-code-elimination of class/method
-	flash9 : fixed issues with loading a haXe SWF (boot_XXXX class extends flash.Boot)
+	flash9 : fixed issues with loading a Haxe SWF (boot_XXXX class extends flash.Boot)
 	all : allow to inline override methods (if the superclass method is not inlined already)
 	all : fixed escape sequences in literal regular expressions
 	flash9 : fixed Xml.setNodeValue
@@ -319,7 +319,7 @@
 	compiler : fixed -no-opt
 	flash : allow several -swf-lib
 		no longer support automatic creation of classes for f8 swfs in f9 mode
-		classes defined in f9 swf are not redefinable in haXe code (use extern)
+		classes defined in f9 swf are not redefinable in Haxe code (use extern)
 	flash9 : allow direct access and completion with classes defined in -swf-lib's
 	flash9 : remove imported libraries debug infos when not compiled with -debug
 	all : only display errors with --display if no completion matched
@@ -347,7 +347,7 @@
 	php : removed eval() everywhere and simplified _hx_lambda
 	php : fixed return type for Std.string() with integers and floats
 	php : fixed php.Lib.rethrow
-	all : added custom haXe serialization
+	all : added custom Haxe serialization
 	php : aligned php.Web.parseMultipart signature with neko implementation
 	cpp : Added source location and stack dump for errors in debug mode
 	cpp : Remapped more keywords
@@ -460,7 +460,7 @@
 	php: fixed String.charCodeAt
 	php: minor optimization (removed foreach from std code)
 	php: implemented haxe.Stack
-	php: changed exception handler to use haXe call stack
+	php: changed exception handler to use Haxe call stack
 	php: changed special vars to use the » prefix instead of __
 	php: fixed use of reserved keywords for var names
 	php: List iterator is now class based (faster)
@@ -477,16 +477,16 @@
 	bugfix for flash.display.BitmapDataChannel and GraphicsPathCommand (allow inline static)
 	resolve environment variable in -cmd commands
 	added flash.Vector.indexOf and lastIndexOf
-	fixed bug in interfaces that define the method toString (haXe/PHP)
+	fixed bug in interfaces that define the method toString (Haxe/PHP)
 	fixed bug in haxe.io.BytesInput.readBytes in Flash9 (was throwing Eof if full buffer can't be readed)
 	fixed implements/extends special classes when they are imported
 	StringBuf now uses an array for JS implementation (around same on FF, faster on IE)
-	fixed assignment of field length in anonym objects (haXe/PHP)
+	fixed assignment of field length in anonym objects (Haxe/PHP)
 	fixed addEventListener typing for flash9
 	fixed __vector__ generation for AS3 target
 	fix with inline functions : position is now the inserted position and not the original one (better error reporting)
 	added SWC output support
-	fixed issues with unset of values in for loops and executing blocks that return functions (haXe/PHP)
+	fixed issues with unset of values in for loops and executing blocks that return functions (Haxe/PHP)
 	"throw" type is now Unknown instead of Dynamic (prevent type-hole in "if A else if B else throw")
 	added __foreach__ for flash9/as3
 	fixed f9 verify error with different kind of functions
@@ -511,7 +511,7 @@
 	speedup Array.remove on flash9/js
 
 2008-11-23: 2.02
-	Std.is(MyInterface, Class) now returns true (haXe/PHP)
+	Std.is(MyInterface, Class) now returns true (Haxe/PHP)
 	php arrays are wrapped into _hx_array instances, fixes issues with references (array cast, access out of bounds ...)
 	removed untested php classes (php.DBase, php.IniHash)
 	added -D use_rtti_doc
@@ -564,12 +564,12 @@
 	always use full classes paths for genAS3
 	prevent different get/set property accesses when implementing an interface
 	fixed assign of dynamicfunction references in PHP
-	haXe/PHP now generates code for extern classes __init__
+	Haxe/PHP now generates code for extern classes __init__
 	added strings literal support in haxe.Template
-	fixed Process arguments and exitCode() in haXe/PHP
-	fixed hierarchy problem for classes with the name from different packages haXe/PHP
+	fixed Process arguments and exitCode() in Haxe/PHP
+	fixed hierarchy problem for classes with the name from different packages Haxe/PHP
 	php.db.Mysql now throws an exception when tries to connect to an unexistant DB
-	fixed blocks in if statements for haXe/PHP
+	fixed blocks in if statements for Haxe/PHP
 	added php check on the full hierarchy for colliding names
 	added support for "g" modifier in EReg for PHP
 	PHP now generates __toString for classes that have toString defined
@@ -591,7 +591,7 @@
 	fixed current package bug in inherited constructor type
 	delayed type-parameter constraints check (allow mutual rec extends for SPOD)
 	improved unclosed macro error reporting
-	haXe/PHP integration
+	Haxe/PHP integration
 	renamed NekoSocketConnection to SyncSocketConnection (php support)
 	fixes in genAs3
 	fix for flash9 : always coerce call return type
@@ -769,7 +769,7 @@
 	optional enums arguments on Flash9 are now automatically Null
 	forbid usage of type parameters in static functions
 	fixed Std.int with negative numbers
-	fixed some F9 issues with haXe-specific Array, Date and Math methods
+	fixed some F9 issues with Haxe-specific Array, Date and Math methods
 	used AS3 namespace for F9 Array and String instance methods
 	fixed F9 with uninitialized integer registers
 	fixed F9 + operator with Dynamic/Null operands
@@ -781,7 +781,7 @@
 	fixed stack overflow with static setter
 	fixed package completion bug when -cp points to an not existing dir
 	fix duplicate sandboxes tags with -swf
-	__resolve in haXe Remoting is now public
+	__resolve in Haxe Remoting is now public
 
 2007-07-25: 1.14
 	fixed no error when invalid "catch" expression
@@ -961,7 +961,7 @@
 	fixed scope bug in try/catch with Flash9
 	added remoting over XMLSocket and LocalConnection for Flash9
 	fixed Std.is(*,null) = false
-	allowed >64K haXe/neko strings
+	allowed >64K Haxe/neko strings
 	-debug and stack traces support for Flash and JS
 	minor changes in xml output
 
@@ -995,7 +995,7 @@
 	some method renamed in neko.FileSystem.
 	added neko.remoting.Server.setLogger
 	fixed bug in haxe.Serializer on neko (was preventing List serialization)
-	fixed bugs in haXe.Unserializer on neko (invalid enum tag & pbs with UTF8 strings)
+	fixed bugs in Haxe.Unserializer on neko (invalid enum tag & pbs with UTF8 strings)
 	fixed sqlite escape & quote , added BOOL support
 	allowed direct property access in getter/setter (prevent rec loop)
 	allowed event-driven neko http requests

+ 1 - 1
doc/ImportAll.hx

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, The haXe Project Contributors
+ * Copyright (c) 2005, The Haxe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:

+ 0 - 202
doc/install.ml

@@ -1,202 +0,0 @@
-(*
- *  Haxe installer
- *  Copyright (c)2005 Nicolas Cannasse
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *)
-
-#load "unix.cma"
-
-(* ----- BEGIN CONFIGURATION ---- *)
-
-let bytecode = false
-let native = true
-
-(* ------ END CONFIGURATION ----- *)
-
-let os_type = Sys.os_type
-
-(* remove the comment to compile with windows using ocaml cygwin *)
-(* let os_type = "Cygwin" *)
-
-let obj_ext = match os_type with "Win32" -> ".obj" | _ -> ".o"
-let exe_ext = match os_type with "Win32" | "Cygwin" -> ".exe" | _ -> ""
-let ocamloptflags = match os_type with "Unix" -> "-cclib -fno-stack-protector " | _ -> ""
-
-let zlib_path = match os_type with
-	| "Win32" -> "libs/extc/zlib/"
-	| _ -> "./"
-
-let zlib = match os_type with
-	| "Win32" -> zlib_path ^ "zlib.lib"
-	| _ ->
-		try
-			List.find Sys.file_exists ["/usr/lib/libz.dylib";"/usr/lib64/libz.so.1";"/usr/lib/libz.so.1";"/lib/libz.so.1";"/usr/lib/libz.so.4.1";"/lib/x86_64-linux-gnu/libz.so.1"]
-		with
-			Not_found ->
-				failwith "LibZ was not found on your system, please install it or modify the search directories in the install script"
-
-let msg m =
-	prerr_endline m;
-	flush stdout
-
-let command c =
-	msg ("> " ^ c);
-	if Sys.command c <> 0 then failwith ("Error while running " ^ c)
-
-let cvs root cmd =
-	command ("cvs -z3 -d" ^ root ^ " " ^ cmd)
-
-let ocamlc file =
-	if bytecode then command ("ocamlc -c " ^ file);
-	if native then command ("ocamlopt -c " ^ ocamloptflags ^ file)
-
-let modules l ext =
-	String.concat " " (List.map (fun f -> f ^ ext) l)
-
-;;
-
-
-let download() =
-	command "svn co http://haxe.googlecode.com/svn/trunk haxe";
-in
-
-let compile_libs() =
-	Sys.chdir "haxe/libs";
-
-	(* EXTLIB *)
-	Sys.chdir "extlib";
-	command ("ocaml install.ml -nodoc -d .. " ^ (if bytecode then "-b " else "") ^ (if native then "-n" else ""));
-	msg "";
-	Sys.chdir "..";
-
-	(* EXTC *)
-	Sys.chdir "extc";
-	let c_opts = (if Sys.ocaml_version < "3.08" then " -ccopt -Dcaml_copy_string=copy_string " else " ") in
-	command ("ocamlc" ^ c_opts ^ " -I .. -I ../../" ^ zlib_path ^ " extc_stubs.c");
-
-	let options = "-cclib libs/extc/extc_stubs" ^ obj_ext ^ " -cclib " ^ zlib ^ " extc.ml" in
-	let options = if Sys.os_type = "Win32" then options ^ " -cclib shell32.lib" else options in
-	if bytecode then command ("ocamlc -a -I .. -o extc.cma " ^ options);
-	if native then command ("ocamlopt -a -I .. -o extc.cmxa " ^ options);
-	Sys.chdir "..";
-
-	(* SWFLIB *)
-	Sys.chdir "swflib";
-	let files = "-I .. -I ../extc as3.mli as3hl.mli as3code.ml as3parse.ml as3hlparse.ml swf.ml actionScript.ml swfParser.ml png.mli png.ml" in
-	if bytecode then command ("ocamlc -a -o swflib.cma " ^ files);
-	if native then command ("ocamlopt -a -o swflib.cmxa " ^ files);
-	Sys.chdir "..";
-
-	(* NEKO *)
-	Sys.chdir "neko";
-	let files = "-I .. nast.ml nxml.ml binast.ml nbytecode.ml ncompile.ml" in
-	if bytecode then command ("ocamlc -a -o neko.cma " ^ files);
-	if native then command ("ocamlopt -a -o neko.cmxa " ^ files);
-	Sys.chdir "..";
-
-	(* ZIPLIB *)
-	Sys.chdir "ziplib";
-	let files = "-I .. -I ../extc zlib.mli zlib.ml zip.mli zip.ml" in
-	if bytecode then command ("ocamlc -a -o zip.cma " ^ files);
-	if native then command ("ocamlopt -a -o zip.cmxa " ^ files);
-	Sys.chdir "..";
-
-	(* JAVALIB *)
-	Sys.chdir "javalib";
-	let files = "-I .. jData.ml jReader.ml" in
-	if bytecode then command ("ocamlc -a -o java.cma " ^ files);
-	if native then command ("ocamlopt -a -o java.cmxa " ^ files);
-	Sys.chdir "..";
-
-	(* TTFLIB *)
-	Sys.chdir "ttflib";
-	let files = "-I .. -I ../extlib -I ../swflib tTFData.ml tTFParser.ml tTFTools.ml tTFSwfWriter.ml tTFCanvasWriter.ml tTFJsonWriter.ml main.ml" in
-	if bytecode then command ("ocamlc -a -o ttf.cma " ^ files);
-	if native then command ("ocamlopt -a -o ttf.cmxa " ^ files);
-	Sys.chdir "..";
-
-	(* XML-LIGHT *)
-	Sys.chdir "xml-light";
-	command ("ocamlyacc	xml_parser.mly");
-	command ("ocamlc xml.mli dtd.mli xml_parser.mli xml_lexer.mli");
-	command ("ocamllex xml_lexer.mll");
-	let files = "xml_parser.ml xml_lexer.ml dtd.ml xmlParser.mli xmlParser.ml xml.ml" in
-	if bytecode then command ("ocamlc -a -o xml-light.cma " ^ files);
-	if native then command ("ocamlopt -a -o xml-light.cmxa " ^ files);
-	Sys.chdir "..";
-
-	Sys.chdir "../..";
-in
-
-let compile() =
-
-	(try Unix.mkdir "bin" 0o740 with Unix.Unix_error(Unix.EEXIST,_,_) -> ());
-
-	Sys.chdir "haxe";
-	(* HAXE *)
-	command "ocamllex lexer.mll";
-	let libs = [
-		"libs/extLib";
-		"libs/extc/extc";
-		"libs/swflib/swflib";
-		"libs/xml-light/xml-light";
-		"libs/neko/neko";
-		"libs/javalib/java";
-		"unix";
-		"libs/ziplib/zip";
-		"str";
-		"libs/ttflib/ttf"
-	] in
-	let paths = [
-		"libs";
-		"libs/swflib";
-		"libs/xml-light";
-		"libs/extc";
-		"libs/neko";
-		"libs/ziplib";
-		"libs/javalib";
-		"libs/ttflib"
-	] in
-	let mlist = [
-		"ast";"lexer";"type";"common";"parser";"typecore";
-		"genxml";"optimizer";"typeload";"codegen";
-    	"gencommon"; "genneko";"genas3";"genjs";"genswf8";"genswf9";"genswf";"genphp";"gencpp"; "gencs";"genjava";
-		"interp";"typer";"matcher";"dce";"main";
-	] in
-	let path_str = String.concat " " (List.map (fun s -> "-I " ^ s) paths) in
-	let libs_str ext = " " ^ String.concat " " (List.map (fun l -> l ^ ext) libs) ^ " " in
-	ocamlc (path_str ^ " -pp camlp4o " ^ modules mlist ".ml");
-	if bytecode then command ("ocamlc -custom -o ../bin/haxe-byte" ^ exe_ext ^ libs_str ".cma" ^ modules mlist ".cmo");
-	if native then command ("ocamlopt -o ../bin/haxe" ^ exe_ext ^ libs_str ".cmxa" ^ modules mlist ".cmx");
-in
-
-let make_std() =
-
-	if Sys.file_exists "../bin/std" then command (if os_type = "Win32" then "rmdir /S /Q ..\\bin\\std" else "rm -rf ../bin/std");
-	command "svn export -q std ../bin/std";
-
-in
-let startdir = Sys.getcwd() in
-try
-	download();
-	compile_libs();
-	compile();
-	make_std();
-	Sys.chdir startdir;
-with
-	Failure msg ->
-		Sys.chdir startdir;
-		prerr_endline msg; exit 1

+ 2 - 2
doc/setup.cpp

@@ -17,7 +17,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-// this is a small program that do basic haXe setup on Windows
+// this is a small program that do basic Haxe setup on Windows
 #include <windows.h>
 
 static void Set( HKEY k, const char *name, DWORD t, const char *data ) {
@@ -67,6 +67,6 @@ int WINAPI WinMain( HINSTANCE inst, HINSTANCE prev, LPSTR lpCmdLine, int nCmdSho
 	delete kdata;
 	// register 
 	if( strcmp(lpCmdLine,"-silent") != 0 )
-		MessageBox(NULL,"Setup completed, you can start using haXe now","haxesetup",MB_OK | MB_ICONINFORMATION);
+		MessageBox(NULL,"Setup completed, you can start using Haxe now","haxesetup",MB_OK | MB_ICONINFORMATION);
 	return 0;
 }

+ 10 - 51
genas3.ml

@@ -276,7 +276,7 @@ let rec type_str ctx t p =
 let rec iter_switch_break in_switch e =
 	match e.eexpr with
 	| TFunction _ | TWhile _ | TFor _ -> ()
-	| TSwitch _ | TMatch _ when not in_switch -> iter_switch_break true e
+	| TSwitch _ | TPatMatch _ when not in_switch -> iter_switch_break true e
 	| TBreak when in_switch -> raise Exit
 	| _ -> iter (iter_switch_break in_switch) e
 
@@ -580,6 +580,9 @@ and gen_expr ctx e =
 		gen_expr ctx e1;
 		spr ctx ")";
 		gen_field_access ctx e1.etype (field_name s)
+	| TEnumParameter (e,i) ->
+		gen_value ctx e;
+		print ctx ".params[%i]" i;
 	| TField (e,s) ->
    		gen_value ctx e;
 		gen_field_access ctx e.etype (field_name s)
@@ -589,6 +592,8 @@ and gen_expr ctx e =
 		spr ctx "(";
 		gen_value ctx e;
 		spr ctx ")";
+	| TMeta (_,e) ->
+		gen_value ctx e
 	| TReturn eo ->
 		if ctx.in_value <> None then unsupported e.epos;
 		(match eo with
@@ -721,49 +726,7 @@ and gen_expr ctx e =
 			print ctx "catch( %s : %s )" (s_ident v.v_name) (type_str ctx v.v_type e.epos);
 			gen_expr ctx e;
 		) catchs;
-	| TMatch (e,_,cases,def) ->
-		print ctx "{";
-		let bend = open_block ctx in
-		newline ctx;
-		let tmp = gen_local ctx "$e" in
-		print ctx "var %s : enum = " tmp;
-		gen_value ctx e;
-		newline ctx;
-		print ctx "switch( %s.index ) {" tmp;
-		List.iter (fun (cl,params,e) ->
-			List.iter (fun c ->
-				newline ctx;
-				print ctx "case %d:" c;
-			) cl;
-			(match params with
-			| None | Some [] -> ()
-			| Some l ->
-				let n = ref (-1) in
-				let l = List.fold_left (fun acc v -> incr n; match v with None -> acc | Some v -> (v,!n) :: acc) [] l in
-				match l with
-				| [] -> ()
-				| l ->
-					newline ctx;
-					spr ctx "var ";
-					concat ctx ", " (fun (v,n) ->
-						print ctx "%s : %s = %s.params[%d]" (s_ident v.v_name) (type_str ctx v.v_type e.epos) tmp n;
-					) l);
-			gen_block ctx e;
-			print ctx "break";
-		) cases;
-		(match def with
-		| None -> ()
-		| Some e ->
-			newline ctx;
-			spr ctx "default:";
-			gen_block ctx e;
-			print ctx "break";
-		);
-		newline ctx;
-		spr ctx "}";
-		bend();
-		newline ctx;
-		spr ctx "}";
+	| TPatMatch dt -> assert false
 	| TSwitch (e,cases,def) ->
 		spr ctx "switch";
 		gen_value ctx (parent e);
@@ -857,8 +820,10 @@ and gen_value ctx e =
 	| TArray _
 	| TBinop _
 	| TField _
+	| TEnumParameter _
 	| TTypeExpr _
 	| TParenthesis _
+	| TMeta _
 	| TObjectDecl _
 	| TArrayDecl _
 	| TCall _
@@ -924,13 +889,7 @@ and gen_value ctx e =
 			match def with None -> None | Some e -> Some (assign e)
 		)) e.etype e.epos);
 		v()
-	| TMatch (cond,enum,cases,def) ->
-		let v = value true in
-		gen_expr ctx (mk (TMatch (cond,enum,
-			List.map (fun (constr,params,e) -> (constr,params,assign e)) cases,
-			match def with None -> None | Some e -> Some (assign e)
-		)) e.etype e.epos);
-		v()
+	| TPatMatch dt -> assert false
 	| TTry (b,catchs) ->
 		let v = value true in
 		gen_expr ctx (mk (TTry (block (assign b),

+ 40 - 58
gencommon.ml

@@ -25,14 +25,14 @@
 
   This module intends to be a common set of utilities common to all targets.
 
-  It's intended to provide a set of tools to be able to make targets in haXe more easily, and to
+  It's intended to provide a set of tools to be able to make targets in Haxe more easily, and to
   allow the programmer to have more control of how the target language will handle the program.
 
   For example, as of now, the hxcpp target, while greatly done, relies heavily on cpp's own operator
   overloading, and implicit conversions, which make it very hard to deliver a similar solution for languages
   that lack these features.
 
-  So this little framework is here so you can manipulate the HaXe AST and start bringing the AST closer
+  So this little framework is here so you can manipulate the Haxe AST and start bringing the AST closer
   to how it's intenteded to be in your host language.
 
   Rules
@@ -110,7 +110,7 @@ struct
   let mk_heexpr = function
     | TConst _ -> 0 | TLocal _ -> 1 | TArray _ -> 3 | TBinop _ -> 4 | TField _ -> 5 | TTypeExpr _ -> 7 | TParenthesis _ -> 8 | TObjectDecl _ -> 9
     | TArrayDecl _ -> 10 | TCall _ -> 11 | TNew _ -> 12 | TUnop _ -> 13 | TFunction _ -> 14 | TVars _ -> 15 | TBlock _ -> 16 | TFor _ -> 17 | TIf _ -> 18 | TWhile _ -> 19
-    | TSwitch _ -> 20 | TMatch _ -> 21 | TTry _ -> 22 | TReturn _ -> 23 | TBreak -> 24 | TContinue -> 25 | TThrow _ -> 26 | TCast _ -> 27
+    | TSwitch _ -> 20 | TPatMatch _ -> 21 | TTry _ -> 22 | TReturn _ -> 23 | TBreak -> 24 | TContinue -> 25 | TThrow _ -> 26 | TCast _ -> 27 | TMeta _ -> 28 | TEnumParameter _ -> 29
 
   let mk_heetype = function
     | TMono _ -> 0 | TEnum _ -> 1 | TInst _ -> 2 | TType _ -> 3 | TFun _ -> 4
@@ -4451,7 +4451,7 @@ end;;
   and will unwrap statements where expressions are expected, and vice-versa.
 
   It should be one of the first syntax filters to be applied. As a consequence, it's applied after all filters that add code to the AST, and by being
-  the first of the syntax filters, it will also have the AST retain most of the meaning of normal HaXe code. So it's easier to detect cases which are
+  the first of the syntax filters, it will also have the AST retain most of the meaning of normal Haxe code. So it's easier to detect cases which are
   side-effects free, for example
 
   Any target can make use of this, but there is one requirement: The target must accept null to be set to any kind of variable. For example,
@@ -4460,7 +4460,7 @@ end;;
   dependencies:
     While it's best for Expression Unwrap to delay its execution as much as possible, since theoretically any
     filter can return an expression that needs to be unwrapped, it is also desirable for ExpresionUnwrap to have
-    the AST as close as possible as HaXe's, so it can make some correct predictions (for example, so it can
+    the AST as close as possible as Haxe's, so it can make some correct predictions (for example, so it can
     more accurately know what can be side-effects-free and what can't).
     This way, it will run slightly after the Normal priority, so if you don't say that a syntax filter must run
     before Expression Unwrap, it will run after it.
@@ -4602,8 +4602,8 @@ struct
         { expr with eexpr = TWhile(fn cond, block, flag) }
       | TSwitch(cond, el_block_l, default) ->
         { expr with eexpr = TSwitch( fn cond, List.map (fun (el,block) -> (List.map fn el, block)) el_block_l, default ) }
-      | TMatch(cond, enum, cases, default) ->
-        { expr with eexpr = TMatch(fn cond, enum, cases, default) }
+(*       | TMatch(cond, enum, cases, default) ->
+        { expr with eexpr = TMatch(fn cond, enum, cases, default) } *)
       | TReturn(eopt) ->
         { expr with eexpr = TReturn(Option.map fn eopt) }
       | TThrow (texpr) ->
@@ -4655,13 +4655,14 @@ struct
       | TArray _
       | TBinop _
       | TField _
+      | TEnumParameter _
       | TTypeExpr _
       | TObjectDecl _
       | TArrayDecl _
       | TFunction _
       | TCast _
       | TUnop _ -> Expression (expr)
-      | TParenthesis p -> shallow_expr_type p
+      | TParenthesis p | TMeta(_,p) -> shallow_expr_type p
       | TBlock ([e]) -> shallow_expr_type e
       | TCall _
       | TVars _
@@ -4669,7 +4670,7 @@ struct
       | TFor _
       | TWhile _
       | TSwitch _
-      | TMatch _
+      | TPatMatch _
       | TTry _
       | TReturn _
       | TBreak
@@ -4711,6 +4712,7 @@ struct
           | TArray (e1,e2) ->
             aggregate true [e1;e2]
           | TParenthesis e
+          | TMeta(_,e)
           | TField (e,_) ->
             aggregate true [e]
           | TArrayDecl (el) ->
@@ -4793,8 +4795,8 @@ struct
         { right with eexpr = TBlock(apply_assign_block assign_fun el) }
       | TSwitch (cond, elblock_l, default) ->
         { right with eexpr = TSwitch(cond, List.map (fun (el,block) -> (el, mk_get_block assign_fun block)) elblock_l, Option.map (mk_get_block assign_fun) default) }
-      | TMatch (cond, ep, il_vlo_e_l, default) ->
-        { right with eexpr = TMatch(cond, ep, List.map (fun (il,vlo,e) -> (il,vlo,mk_get_block assign_fun e)) il_vlo_e_l, Option.map (mk_get_block assign_fun) default) }
+(*       | TMatch (cond, ep, il_vlo_e_l, default) ->
+        { right with eexpr = TMatch(cond, ep, List.map (fun (il,vlo,e) -> (il,vlo,mk_get_block assign_fun e)) il_vlo_e_l, Option.map (mk_get_block assign_fun) default) } *)
       | TTry (block, catches) ->
         { right with eexpr = TTry(mk_get_block assign_fun block, List.map (fun (v,block) -> (v,mk_get_block assign_fun block) ) catches) }
       | TIf (cond,eif,eelse) ->
@@ -4805,7 +4807,7 @@ struct
       | TReturn _
       | TBreak
       | TContinue -> right
-      | TParenthesis p ->
+      | TParenthesis p | TMeta(_,p) ->
         apply_assign assign_fun p
       | _ ->
         match follow right.etype with
@@ -5101,8 +5103,8 @@ struct
           { e with eexpr = TBlock(block) }
         | TTry (block, catches) ->
           { e with eexpr = TTry(traverse (mk_block block), List.map (fun (v,block) -> (v, traverse (mk_block block))) catches) }
-        | TMatch (cond,ep,il_vol_e_l,default) ->
-          { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) }
+(*         | TMatch (cond,ep,il_vol_e_l,default) ->
+          { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) } *)
         | TSwitch (cond,el_e_l, default) ->
           { e with eexpr = TSwitch(cond, List.map (fun (el,e) -> (el, traverse (mk_block e))) el_e_l, Option.map (fun e -> traverse (mk_block e)) default) }
         | TWhile (cond,block,flag) ->
@@ -5179,6 +5181,7 @@ struct
     let default_implementation gen =
       let rec extract_expr e = match e.eexpr with
         | TParenthesis e
+        | TMeta (_,e)
         | TCast(e,_) -> extract_expr e
         | _ -> e
       in
@@ -6007,8 +6010,8 @@ struct
           { e with eexpr = TWhile (handle (run econd) gen.gcon.basic.tbool econd.etype, run (mk_block e1), flag) }
         | TSwitch (cond, el_e_l, edef) ->
           { e with eexpr = TSwitch(run cond, List.map (fun (el,e) -> (List.map run el, run (mk_block e))) el_e_l, Option.map (fun e -> run (mk_block e)) edef) }
-        | TMatch (cond, en, il_vl_e_l, edef) ->
-          { e with eexpr = TMatch(run cond, en, List.map (fun (il, vl, e) -> (il, vl, run (mk_block e))) il_vl_e_l, Option.map (fun e -> run (mk_block e)) edef) }
+(*         | TMatch (cond, en, il_vl_e_l, edef) ->
+          { e with eexpr = TMatch(run cond, en, List.map (fun (il, vl, e) -> (il, vl, run (mk_block e))) il_vl_e_l, Option.map (fun e -> run (mk_block e)) edef) } *)
         | TFor (v,cond,e1) ->
           { e with eexpr = TFor(v, run cond, run (mk_block e1)) }
         | TTry (e, ve_l) ->
@@ -6021,7 +6024,7 @@ struct
           let rec get_null e =
             match e.eexpr with
             | TConst TNull -> Some e
-            | TParenthesis e -> get_null e
+            | TParenthesis e | TMeta(_,e) -> get_null e
             | _ -> None
           in
           (match get_null expr with
@@ -6658,7 +6661,7 @@ struct
         | TIf(cond,e1,Some e2) ->
           is_side_effects_free cond && is_side_effects_free e1 && is_side_effects_free e2
         | TField(e,_)
-        | TParenthesis e -> is_side_effects_free e
+        | TParenthesis e | TMeta(_,e) -> is_side_effects_free e
         | TArrayDecl el -> List.for_all is_side_effects_free el
         | TCast(e,_) -> is_side_effects_free e
         | _ -> false
@@ -8581,43 +8584,22 @@ struct
     let traverse gen t opt_get_native_enum_tag =
       let rec run e =
         match e.eexpr with
-          | TMatch(cond,(en,eparams),cases,default) ->
-            let cond = run cond in (* being safe *)
+          | TEnumParameter(f, i) ->
+            let f = run f in
             (* check if en was converted to class *)
             (* if it was, switch on tag field and change cond type *)
-            let exprs_before, cond_local, cond = try
+            let f = try
+              let en, eparams = match follow (gen.gfollow#run_f f.etype) with
+                | TEnum(en,p) -> en, p
+                | _ -> raise Not_found
+              in
               let cl = Hashtbl.find t.ec_tbl en.e_path in
-              let cond = { cond with etype = TInst(cl, eparams) } in
-              let exprs_before, new_cond = ensure_local gen cond in
-              exprs_before, new_cond, get_index gen new_cond cl eparams
+              { f with etype = TInst(cl, eparams) }
             with | Not_found ->
-              (*
-                if it's not a class, we'll either use get_native_enum_tag or in a last resource,
-                call Type.getEnumIndex
-              *)
-              match opt_get_native_enum_tag with
-                | Some get_native_etag ->
-                  [], cond, get_native_etag cond
-                | None ->
-                  [], cond, { eexpr = TCall(mk_static_field_access_infer gen.gclasses.cl_type "enumIndex" e.epos [], [cond]); etype = gen.gcon.basic.tint; epos = cond.epos }
+              f
             in
-
-            (* for each case, change cases to expr int, and see if there is any var create *)
-            let change_case (il, params, expr) =
-              let expr = run expr in
-              (* if there are, set var with tarray *)
-              let exprs = tmatch_params_to_exprs gen params cond_local in
-              let expr = match expr.eexpr with
-                | TBlock(bl) -> { expr with eexpr = TBlock(exprs @ bl) }
-                | _ -> { expr with eexpr = TBlock ( exprs @ [expr] ) }
-              in
-              (List.map (fun i -> mk_int gen i e.epos) il, expr)
-            in
-
-            let tswitch = { e with eexpr = TSwitch(cond, List.map change_case cases, Option.map run default) } in
-            (match exprs_before with
-              | [] -> tswitch
-              | _ -> { e with eexpr = TBlock(exprs_before @ [tswitch]) })
+            let cond_array = { (mk_field_access gen f "params" f.epos) with etype = gen.gcon.basic.tarray t_empty } in
+            { e with eexpr = TArray(cond_array, mk_int gen i cond_array.epos); }
           | _ -> Type.map_expr run e
       in
 
@@ -9331,7 +9313,7 @@ struct
 
           new_e
         | TSwitch _
-        | TMatch _ ->
+        | TPatMatch _ ->
           let last_switch = !in_switch in
           in_switch := true;
 
@@ -9423,7 +9405,7 @@ struct
     match e.eexpr with
       | TConst (v) -> Some v
       | TBinop(op, v1, v2) -> aggregate_constant op (get_constant_expr v1) (get_constant_expr v2)
-      | TParenthesis(e) -> get_constant_expr e
+      | TParenthesis(e) | TMeta(_,e) -> get_constant_expr e
       | _ -> None
 
   let traverse gen should_warn handle_switch_break handle_not_final_returns java_mode =
@@ -9555,9 +9537,9 @@ struct
             (el, handle_case (e, ek))
           ) el_e_l, Some def) } in
           ret, !k
-        | TMatch(cond, ep, il_vopt_e_l, None) ->
-          { expr with eexpr = TMatch(cond, ep, List.map (fun (il, vopt, e) -> (il, vopt, handle_case (process_expr e))) il_vopt_e_l, None) }, Normal
-        | TMatch(cond, ep, il_vopt_e_l, Some def) ->
+(*         | TMatch(cond, ep, il_vopt_e_l, None) ->
+          { expr with eexpr = TMatch(cond, ep, List.map (fun (il, vopt, e) -> (il, vopt, handle_case (process_expr e))) il_vopt_e_l, None) }, Normal *)
+(*         | TMatch(cond, ep, il_vopt_e_l, Some def) ->
           let def, k = process_expr def in
           let def = handle_case (def, k) in
           let k = ref k in
@@ -9566,7 +9548,7 @@ struct
             k := aggregate_kind !k ek;
             (il, vopt, handle_case (e, ek))
           ) il_vopt_e_l, Some def) } in
-          ret, !k
+          ret, !k *)
         | TTry (e, catches) ->
           let e, k = process_expr e in
           let k = ref k in
@@ -9847,8 +9829,8 @@ struct
           { e with eexpr = TBlock bl }
         | TTry (block, catches) ->
           { e with eexpr = TTry(traverse (mk_block block), List.map (fun (v,block) -> (v, traverse (mk_block block))) catches) }
-        | TMatch (cond,ep,il_vol_e_l,default) ->
-          { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) }
+(*         | TMatch (cond,ep,il_vol_e_l,default) ->
+          { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) } *)
         | TSwitch (cond,el_e_l, default) ->
           { e with eexpr = TSwitch(cond, List.map (fun (el,e) -> (el, traverse (mk_block e))) el_e_l, Option.map (fun e -> traverse (mk_block e)) default) }
         | TWhile (cond,block,flag) ->

+ 32 - 74
gencpp.ml

@@ -341,7 +341,7 @@ List.filter (function (t,pl) ->
 
 let rec is_function_expr expr =
    match expr.eexpr with
-   | TParenthesis expr -> is_function_expr expr
+   | TParenthesis expr | TMeta(_,expr) -> is_function_expr expr
    | TCast (e,None) -> is_function_expr e
    | TFunction _ -> true
    | _ -> false;;
@@ -758,9 +758,10 @@ let rec iter_retval f retval e =
 		f false e2;
 	| TThrow e
 	| TField (e,_)
+	| TEnumParameter (e,_)
 	| TUnop (_,_,e) ->
 		f true e
-	| TParenthesis e ->
+	| TParenthesis e | TMeta(_,e) ->
 		f retval e
 	| TBlock expr_list when retval ->
 		let rec return_last = function
@@ -790,10 +791,11 @@ let rec iter_retval f retval e =
 		f true e;
 		List.iter (fun (el,e2) -> List.iter (f true) el; f retval e2) cases;
 		(match def with None -> () | Some e -> f retval e)
-	| TMatch (e,_,cases,def) ->
+(* 	| TMatch (e,_,cases,def) ->
 		f true e;
 		List.iter (fun (_,_,e) -> f false e) cases;
-		(match def with None -> () | Some e -> f false e)
+		(match def with None -> () | Some e -> f false e) *)
+	| TPatMatch dt -> assert false
 	| TTry (e,catches) ->
 		f retval e;
 		List.iter (fun (_,e) -> f false e) catches
@@ -856,7 +858,7 @@ let tmatch_params_to_args params =
 let rec is_null expr =
    match expr.eexpr with
    | TConst TNull -> true
-   | TParenthesis expr -> is_null expr
+   | TParenthesis expr | TMeta (_,expr) -> is_null expr
    | TCast (e,None) -> is_null e
    | _ -> false
 ;;
@@ -893,7 +895,7 @@ let find_undeclared_variables_ctx ctx undeclared declarations this_suffix allow_
          let name = keyword_remap tvar.v_name in
 			if  not (Hashtbl.mem declarations name) then
 				Hashtbl.replace undeclared name (type_string expression.etype)
-		| TMatch (condition, enum, cases, default) ->
+(* 		| TMatch (condition, enum, cases, default) ->
 			find_undeclared_variables undeclared declarations this_suffix allow_this condition;
 			List.iter (fun (case_ids,params,expression) ->
 				let old_decs = Hashtbl.copy declarations in
@@ -909,7 +911,7 @@ let find_undeclared_variables_ctx ctx undeclared declarations this_suffix allow_
 			(match default with | None -> ()
 			| Some expr ->
 				find_undeclared_variables undeclared declarations this_suffix allow_this expr;
-			);
+			); *)
 		| TFor (tvar, init, loop) ->
 			let old_decs = Hashtbl.copy declarations in
 			Hashtbl.add declarations (keyword_remap tvar.v_name) ();
@@ -941,6 +943,8 @@ let rec is_dynamic_in_cpp ctx expr =
 	else begin
 		let result = (
 		match expr.eexpr with
+ 		| TEnumParameter( obj, index ) ->
+			true (* TODO? *)
 		| TField( obj, field ) ->
 			let name = field_name field in
 			ctx.ctx_dbgout ("/* ?tfield "^name^" */");
@@ -971,7 +975,7 @@ let rec is_dynamic_in_cpp ctx expr =
                    is_dynamic_in_cpp ctx func
                | _ -> ctx.ctx_dbgout "/* not TFun */";  true
            );
-		| TParenthesis(expr) -> is_dynamic_in_cpp ctx expr
+		| TParenthesis(expr) | TMeta(_,expr) -> is_dynamic_in_cpp ctx expr
       | TCast (e,None) -> is_dynamic_in_cpp ctx e
 		| TLocal { v_name = "__global__" } -> false
 		| TConst TNull -> true
@@ -1246,7 +1250,7 @@ and find_local_functions_and_return_blocks_ctx ctx retval expression =
 			if (retval) then begin
 				define_local_return_block_ctx ctx expression (next_anon_function_name ctx) true;
 			end  (* else we are done *)
-		| TMatch (_, _, _, _)
+		| TPatMatch (_)
 		| TTry (_, _)
 		| TSwitch (_, _, _) when retval ->
 				define_local_return_block_ctx ctx expression (next_anon_function_name ctx) true;
@@ -1266,13 +1270,13 @@ and find_local_functions_and_return_blocks_ctx ctx retval expression =
 			let func_name = next_anon_function_name ctx in
 			output "\n";
 			define_local_function_ctx ctx func_name func
-		| TField (obj,_) when (is_null obj) -> ( )
+		| TField (obj,_) | TEnumParameter (obj,_) when (is_null obj) -> ( )
 		| TArray (obj,_) when (is_null obj) -> ( )
 		| TIf ( _ , _ , _ ) when retval -> (* ? operator style *)
 		   iter_retval find_local_functions_and_return_blocks retval expression
-		| TMatch (_, _, _, _)
+		| TPatMatch (_)
 		| TSwitch (_, _, _) when retval -> ( )
-		| TMatch ( cond , _, _, _)
+		(* | TMatch ( cond , _, _, _) *)
 		| TWhile ( cond , _, _ )
 		| TIf ( cond , _, _ )
 		| TSwitch ( cond , _, _) -> iter_retval find_local_functions_and_return_blocks true cond
@@ -1478,7 +1482,7 @@ and gen_expression ctx retval expression =
 		   check_array_cast (Codegen.Abstract.get_underlying_type abs pl)
       | _ -> ()
    in
-	
+
 	let rec gen_tfield field_object field =
       let member = (field_name field) in
 		let remap_name = keyword_remap member in
@@ -1577,9 +1581,9 @@ and gen_expression ctx retval expression =
       output ("(" ^ !arg_string ^ ");\n");
 	| TCall (func, arg_list) ->
 		let rec is_variable e = match e.eexpr with
-		| TField _ -> false
+		| TField _ | TEnumParameter _ -> false
 		| TLocal { v_name = "__global__" } -> false
-		| TParenthesis p -> is_variable p
+		| TParenthesis p | TMeta(_,p) -> is_variable p
 		| TCast (e,None) -> is_variable e
 		| _ -> true
       in
@@ -1596,7 +1600,7 @@ and gen_expression ctx retval expression =
             end;
             fixed
           )
-		| TParenthesis p -> is_fixed_override p
+		| TParenthesis p | TMeta(_,p) -> is_fixed_override p
 		| _ -> false
       in
       let is_super = (match func.eexpr with | TConst TSuper -> true | _ -> false ) in
@@ -1626,7 +1630,7 @@ and gen_expression ctx retval expression =
                   | "map" -> check_array_cast expression.etype
                   | _ -> ()
                )
-            | TParenthesis p -> cast_array_output p
+            | TParenthesis p | TMeta(_,p) -> cast_array_output p
             | _ -> ()
       in
       cast_array_output func;
@@ -1732,14 +1736,19 @@ and gen_expression ctx retval expression =
 		end
 	(* Get precidence matching haxe ? *)
 	| TBinop (op,expr1,expr2) -> gen_bin_op op expr1 expr2
-	| TField (expr,name) when (is_null expr) -> output "Dynamic()"
-
+	| TField (expr,_) | TEnumParameter (expr,_) when (is_null expr) -> output "Dynamic()"
+	| TEnumParameter (expr,i) ->
+		let enum = match follow expr.etype with TEnum(enum,_) -> enum | _ -> assert false in
+		output (  "(::" ^ (join_class_path_remap enum.e_path "::") ^ "(");
+		gen_expression ctx true expr;
+		output ( "))->__Param(" ^ (string_of_int i) ^ ")")
 	| TField (field_object,field) ->
 		gen_tfield field_object field
 
 	| TParenthesis expr when not retval ->
 			gen_expression ctx retval expr;
 	| TParenthesis expr -> output "("; gen_expression ctx retval expr; output ")"
+	| TMeta (_,expr) -> gen_expression ctx retval expr;
 	| TObjectDecl (
       ("fileName" , { eexpr = (TConst (TString file)) }) ::
          ("lineNumber" , { eexpr = (TConst (TInt line)) }) ::
@@ -1878,8 +1887,9 @@ and gen_expression ctx retval expression =
 	(* These have already been defined in find_local_return_blocks ... *)
 	| TTry (_,_)
 	| TSwitch (_,_,_)
-	| TMatch (_, _, _, _) when (retval && (not return_from_internal_node) )->
+	| TPatMatch (_) when (retval && (not return_from_internal_node) )->
       gen_local_block_call()
+    | TPatMatch dt -> assert false
 	| TSwitch (condition,cases,optional_default)  ->
 		let switch_on_int_constants = (only_int_cases cases) && (not (contains_break expression)) in
 		if (switch_on_int_constants) then begin
@@ -1932,58 +1942,6 @@ and gen_expression ctx retval expression =
 				output ";\n";
 			);
 		end
-	| TMatch (condition, enum, cases, default) ->
-		let tmp_var = get_switch_var ctx in
-		writer#begin_block;
-		output_i (  "::" ^ (join_class_path_remap (fst enum).e_path "::") ^ " " ^ tmp_var ^ " = " );
-		gen_expression ctx true condition;
-		output ";\n";
-
-		let use_if_statements = contains_break expression in
-		let dump_condition = if (use_if_statements) then begin
-			let tmp_name = get_switch_var ctx in
-			output_i ( "int " ^ tmp_name ^ " = (" ^ tmp_var ^ ")->GetIndex();" );
-			let elif = ref "if" in
-			( fun case_ids -> output (!elif ^ " (" ); elif := "else if";
-					output (String.concat "||"
-					(List.map (fun id -> (string_of_int id) ^ "==" ^ tmp_name ) case_ids ) );
-				output ") " )
-		end else begin
-			output_i ("switch((" ^ tmp_var ^ ")->GetIndex())");
-			( fun case_ids ->
-			List.iter (fun id -> output ("case " ^ (string_of_int id) ^ ": ") ) case_ids;
-			)
-		end in
-		writer#begin_block;
-		List.iter (fun (case_ids,params,expression) ->
-			output_i "";
-			dump_condition case_ids;
-			let has_params = match params with | Some _ -> true | _ -> false in
-			if (has_params) then begin
-				writer#begin_block;
-				List.iter (fun (name,vtype,id) -> output_i
-				((type_string vtype) ^ " " ^ (keyword_remap name) ^
-					" = " ^ tmp_var ^ "->__Param(" ^ (string_of_int id) ^ ");\n"))
-						(tmatch_params_to_args params);
-			end;
-			ctx.ctx_return_from_block <- return_from_internal_node;
-			gen_expression ctx false (to_block expression);
-			if (has_params) then writer#end_block;
-			if (not use_if_statements) then output_i ";break;\n";
-		) cases;
-		(match default with
-		| None -> ()
-		|  Some e ->
-			if (use_if_statements) then
-				output_i "else "
-			else
-				output_i "default: ";
-			ctx.ctx_return_from_block <- return_from_internal_node;
-			gen_expression ctx false (to_block e);
-		);
-		writer#end_block;
-		writer#end_block;
-
 	| TTry (expression, catch_list) ->
 		output "try";
 		(* Move this "inside" the try call ... *)
@@ -2356,12 +2314,12 @@ let find_referenced_types ctx obj super_deps constructor_deps header_only for_de
 				| TTry (e,catches) ->
 					List.iter (fun (v,_) -> visit_type v.v_type) catches
 				(* Must visit the enum param types, Type.iter will visit the rest ... *)
-				| TMatch (_,enum,cases,_) ->
+(* 				| TMatch (_,enum,cases,_) ->
 					add_type (fst enum).e_path;
 					List.iter (fun (case_ids,params,expression) ->
 						(match params with
 						| None -> ()
-						| Some l -> List.iter (function None -> () | Some v -> visit_type v.v_type) l  ) ) cases;
+						| Some l -> List.iter (function None -> () | Some v -> visit_type v.v_type) l  ) ) cases; *)
 				(* Must visit type too, Type.iter will visit the expressions ... *)
             | TNew  (klass,params,_) -> begin
                visit_type (TInst (klass,params));

+ 6 - 3
gencs.ml

@@ -850,7 +850,7 @@ let configure gen =
 
   let has_semicolon e =
     match e.eexpr with
-      | TBlock _ | TFor _ | TSwitch _ | TMatch _ | TTry _ | TIf _ -> false
+      | TBlock _ | TFor _ | TSwitch _ | TPatMatch _ | TTry _ | TIf _ -> false
       | TWhile (_,_,flag) when flag = Ast.NormalWhile -> false
       | _ -> true
   in
@@ -882,7 +882,7 @@ let configure gen =
     match e.eexpr with
       | TLocal _ -> e
       | TCast(e,_)
-      | TParenthesis e -> ensure_local e explain
+      | TParenthesis e | TMeta(_,e) -> ensure_local e explain
       | _ -> gen.gcon.error ("This function argument " ^ explain ^ " must be a local variable.") e.epos; e
   in
 
@@ -992,6 +992,8 @@ let configure gen =
           )
         | TParenthesis e ->
           write w "("; expr_s w e; write w ")"
+        | TMeta (_,e) ->
+            expr_s w e
         | TArrayDecl el ->
           print w "new %s" (t_s e.etype);
           write w "{";
@@ -1261,7 +1263,8 @@ let configure gen =
           if !strict_mode then assert false
         | TObjectDecl _ -> write w "[ obj decl not supported ]"; if !strict_mode then assert false
         | TFunction _ -> write w "[ func decl not supported ]"; if !strict_mode then assert false
-        | TMatch _ -> write w "[ match not supported ]"; if !strict_mode then assert false
+        | TPatMatch _ -> write w "[ match not supported ]"; if !strict_mode then assert false
+        | TEnumParameter _ -> write w "[ enum parameter not supported ]"; if !strict_mode then assert false
     )
     and do_call w e el =
       let params, el = extract_tparams [] el in

+ 8 - 5
genjava.ml

@@ -284,12 +284,12 @@ struct
       (* this is hack to not use 'break' on switch cases *)
       | TLocal { v_name = "__fallback__" } when is_switch -> true
       | TCall( { eexpr = TLocal { v_name = "__goto__" } }, _ ) -> true
-      | TParenthesis p -> is_final_return_expr p
+      | TParenthesis p | TMeta (_,p) -> is_final_return_expr p
       | TBlock bl -> is_final_return_block is_switch bl
       | TSwitch (_, el_e_l, edef) ->
         List.for_all (fun (_,e) -> is_final_return_expr e) el_e_l && Option.map_default is_final_return_expr false edef
-      | TMatch (_, _, il_vl_e_l, edef) ->
-        List.for_all (fun (_,_,e) -> is_final_return_expr e)il_vl_e_l && Option.map_default is_final_return_expr false edef
+(*       | TMatch (_, _, il_vl_e_l, edef) ->
+        List.for_all (fun (_,_,e) -> is_final_return_expr e)il_vl_e_l && Option.map_default is_final_return_expr false edef *)
       | TIf (_,eif, Some eelse) ->
         is_final_return_expr eif && is_final_return_expr eelse
       | TFor (_,_,e) ->
@@ -1012,7 +1012,7 @@ let configure gen =
     match e.eexpr with
       | TLocal { v_name = "__fallback__" }
       | TCall ({ eexpr = TLocal( { v_name = "__label__" } ) }, [ { eexpr = TConst(TInt _) } ] ) -> false
-      | TBlock _ | TFor _ | TSwitch _ | TMatch _ | TTry _ | TIf _ -> false
+      | TBlock _ | TFor _ | TSwitch _ | TPatMatch _ | TTry _ | TIf _ -> false
       | TWhile (_,_,flag) when flag = Ast.NormalWhile -> false
       | _ -> true
   in
@@ -1123,6 +1123,8 @@ let configure gen =
         | TTypeExpr mt -> write w (md_s e.epos mt)
         | TParenthesis e ->
           write w "("; expr_s w e; write w ")"
+        | TMeta (_,e) ->
+          expr_s w e
         | TArrayDecl el when t_has_type_param_shallow false e.etype ->
           print w "( (%s) (new java.lang.Object[] " (t_s e.epos e.etype);
           write w "{";
@@ -1388,7 +1390,8 @@ let configure gen =
           if !strict_mode then assert false
         | TObjectDecl _ -> write w "[ obj decl not supported ]"; if !strict_mode then assert false
         | TFunction _ -> write w "[ func decl not supported ]"; if !strict_mode then assert false
-        | TMatch _ -> write w "[ match not supported ]"; if !strict_mode then assert false
+        | TPatMatch _ -> write w "[ match not supported ]"; if !strict_mode then assert false
+        | TEnumParameter _ -> write w "[ enum parameter not supported ]"; if !strict_mode then assert false
     in
     expr_s w e
   in

+ 10 - 60
genjs.ml

@@ -260,7 +260,7 @@ let rec has_return e =
 let rec iter_switch_break in_switch e =
 	match e.eexpr with
 	| TFunction _ | TWhile _ | TFor _ -> ()
-	| TSwitch _ | TMatch _ when not in_switch -> iter_switch_break true e
+	| TSwitch _ | TPatMatch _ when not in_switch -> iter_switch_break true e
 	| TBreak when in_switch -> raise Exit
 	| _ -> iter (iter_switch_break in_switch) e
 
@@ -449,6 +449,9 @@ and gen_expr ctx e =
 			print ctx "($_=";
 			gen_value ctx x;
 			print ctx ",$bind($_,$_%s))" (field f.cf_name))
+	| TEnumParameter (x,i) ->
+		gen_value ctx x;
+		print ctx "[%i]" (i + 2)
 	| TField (x,f) ->
 		gen_value ctx x;
 		let name = field_name f in
@@ -459,6 +462,8 @@ and gen_expr ctx e =
 		spr ctx "(";
 		gen_value ctx e;
 		spr ctx ")";
+	| TMeta (_,e) ->
+		gen_value ctx e
 	| TReturn eo ->
 		if ctx.in_value <> None then unsupported e.epos;
 		(match eo with
@@ -636,58 +641,7 @@ and gen_expr ctx e =
 		bend();
 		newline ctx;
 		spr ctx "}";
-	| TMatch (e,(estruct,_),cases,def) ->
-		let evar = (if List.for_all (fun (_,pl,_) -> pl = None) cases then begin
-			spr ctx "switch( ";
-			gen_value ctx (if Optimizer.need_parent e then Codegen.mk_parent e else e);
-			spr ctx "[1] ) {";
-			"???"
-		end else begin
-			let v = (match e.eexpr with
-				| TLocal v -> v.v_name
-				| _ ->
-					spr ctx "var $e = ";
-					gen_value ctx e;
-					newline ctx;
-					"$e"
-			) in
-			print ctx "switch( %s[1] ) {" v;
-			v
-		end) in
-		List.iter (fun (cl,params,e) ->
-			List.iter (fun c ->
-				newline ctx;
-				print ctx "case %d:" c;
-			) cl;
-			let bend = open_block ctx in
-			(match params with
-			| None -> ()
-			| Some l ->
-				let n = ref 1 in
-				let l = List.fold_left (fun acc v -> incr n; match v with None -> acc | Some v -> (v.v_name,!n) :: acc) [] l in
-				newline ctx;
-				spr ctx "var ";
-				concat ctx ", " (fun (v,n) ->
-					print ctx "%s = %s[%d]" (ident v) evar n;
-				) l);
-			gen_block ctx e;
-			if not (has_return e) then begin
-				newline ctx;
-				print ctx "break";
-			end;
-			bend();
-		) cases;
-		(match def with
-		| None -> ()
-		| Some e ->
-			newline ctx;
-			spr ctx "default:";
-			let bend = open_block ctx in
-			gen_block ctx e;
-			bend();
-		);
-		newline ctx;
-		spr ctx "}"
+	| TPatMatch dt -> assert false
 	| TSwitch (e,cases,def) ->
 		spr ctx "switch";
 		gen_value ctx e;
@@ -784,8 +738,10 @@ and gen_value ctx e =
 	| TArray _
 	| TBinop _
 	| TField _
+	| TEnumParameter _
 	| TTypeExpr _
 	| TParenthesis _
+	| TMeta _
 	| TObjectDecl _
 	| TArrayDecl _
 	| TNew _
@@ -851,13 +807,7 @@ and gen_value ctx e =
 			match def with None -> None | Some e -> Some (assign e)
 		)) e.etype e.epos);
 		v()
-	| TMatch (cond,enum,cases,def) ->
-		let v = value() in
-		gen_expr ctx (mk (TMatch (cond,enum,
-			List.map (fun (constr,params,e) -> (constr,params,assign e)) cases,
-			match def with None -> None | Some e -> Some (assign e)
-		)) e.etype e.epos);
-		v()
+	| TPatMatch dt -> assert false
 	| TTry (b,catchs) ->
 		let v = value() in
 		let block e = mk (TBlock [e]) e.etype e.epos in

+ 80 - 57
genneko.ml

@@ -35,6 +35,7 @@ type context = {
 	mutable curclass : string;
 	mutable curmethod : string;
 	mutable inits : (tclass * texpr) list;
+	mutable label_count : int;
 }
 
 let files = Hashtbl.create 0
@@ -242,12 +243,16 @@ and gen_expr ctx e =
 					call p (ident p ("@closure" ^ string_of_int n)) [tmp;ident p "@fun"]
 			] , p
 		| _ -> assert false)
+	| TEnumParameter (e,i) ->
+		EArray (field p (gen_expr ctx e) "args",int p i),p
 	| TField (e,f) ->
 		field p (gen_expr ctx e) (field_name f)
 	| TTypeExpr t ->
 		gen_type_path p (t_path t)
 	| TParenthesis e ->
 		(EParenthesis (gen_expr ctx e),p)
+	| TMeta (_,e) ->
+		gen_expr ctx e
 	| TObjectDecl fl ->
 		let hasToString = ref false in
 		let fl = List.map (fun (f,e) -> if f = "toString" then hasToString := (match follow e.etype with TFun ([],_) -> true | _ -> false); f , gen_expr ctx e) fl in
@@ -359,64 +364,81 @@ and gen_expr ctx e =
 		gen_expr ctx e
 	| TCast (e1,Some t) ->
 		gen_expr ctx (Codegen.default_cast ~vtmp:"@tmp" ctx.com e1 t e.etype e.epos)
-	| TMatch (e,_,cases,eo) ->
-		let p = pos ctx e.epos in
-		let etmp = (EVars ["@tmp",Some (gen_expr ctx e)],p) in
-		let eindex = field p (ident p "@tmp") "index" in
-		let gen_params params e =
-			match params with
-			| None ->
-				gen_expr ctx e
-			| Some el ->
-				let count = ref (-1) in
-				let vars = List.fold_left (fun acc v ->
-					incr count;
-					match v with
-					| None ->
-						acc
-					| Some v ->
-						let e = (EArray (ident p "@tmp",int p (!count)),p) in
-						let e = (if v.v_capture then call p (builtin p "array") [e] else e) in
-						(v.v_name , Some e) :: acc
-				) [] el in
+ 	| TPatMatch dt ->
+		let num_labels = Array.length dt.dt_dt_lookup in
+		let lc = ctx.label_count in
+		ctx.label_count <- ctx.label_count + num_labels + 1;
+		let get_label i ="label_" ^ (string_of_int (lc + i)) in
+		let goto i = call p (builtin p "goto") [ident p (get_label i)] in
+		let state = Hashtbl.create 0 in
+		let v_name v = "v" ^ (string_of_int v.v_id) in
+		let get_locals e =
+			let locals = Hashtbl.create 0 in
+			let rec loop e = match e.eexpr with
+				| TLocal v -> Hashtbl.replace locals v true
+				| _ -> Type.iter loop e
+			in
+			loop e;
+			Hashtbl.fold (fun v _ l -> if Hashtbl.mem locals v then (v.v_name, Some (field p (ident p "@state") (v_name v))) :: l else l) state []
+		in
+		let rec loop d = match d with
+			| DTGoto i ->
+				goto i
+			| DTBind (bl,dt) ->
+				let block = List.map (fun ((v,_),est) ->
+					let est = gen_expr ctx est in
+					let field = field p (ident p "@state") (v_name v) in
+					Hashtbl.replace state v field;
+					(EBinop ("=",field,est),p)
+				) bl in
+				EBlock (block @ [loop dt]),p
+			| DTExpr e ->
+				let block = [
+					(EBinop ("=",ident p "@ret",gen_expr ctx e),p);
+					goto num_labels;
+				] in
+				(match get_locals e with [] -> EBlock block,p | el -> EBlock ((EVars(el),p) :: block),p)
+			| DTGuard (e,dt1,dt2) ->
+				let eg = match dt2 with
+ 					| None -> (EIf (gen_expr ctx e,loop dt1,None),p)
+					| Some dt -> (EIf (gen_expr ctx e,loop dt1,Some (loop dt)),p)
+				in
+				(match get_locals e with [] -> eg | el -> EBlock [(EVars(el),p);eg],p)
+			| DTSwitch (e,cl) ->
 				let e = gen_expr ctx e in
-				(EBlock [
-					(EVars ["@tmp",Some (field p (ident p "@tmp") "args")],p);
-					(match vars with [] -> null p | _ -> EVars vars,p);
-					e
-				],p)
+				let def = ref None in
+				let cases = ExtList.List.filter_map (fun (e,dt) ->
+					match e.eexpr with
+	 				| TMeta((Meta.MatchAny,_,_),_) ->
+						def := Some (loop dt);
+						None
+					| _ ->
+						Some (gen_expr ctx e,loop dt)
+				) cl in
+				EBlock [
+					(ESwitch (e,cases,!def),p);
+					goto num_labels;
+				],p
 		in
-		(try
-		  (EBlock [
-			etmp;
-			(ESwitch (
-				eindex,
-				List.map (fun (cl,params,e2) ->
-					let cond = match cl with
-						| [s] -> int p s
-						| _ -> raise Exit
-					in
-					cond , gen_params params e2
-				) cases,
-				(match eo with None -> None | Some e -> Some (gen_expr ctx e))
-			),p)
-		  ],p)
-		with
-			Exit ->
-				(EBlock [
-					etmp;
-					(EVars ["@index",Some eindex],p);
-					List.fold_left (fun acc (cl,params,e2) ->
-						let cond = (match cl with
-							| [] -> assert false
-							| c :: l ->
-								let eq c = (EBinop ("==",ident p "@index",int p c),p) in
-								List.fold_left (fun acc c -> (EBinop ("||",acc,eq c),p)) (eq c) l
-						) in
-						EIf (cond,gen_params params e2,Some acc),p
-					) (match eo with None -> null p | Some e -> (gen_expr ctx e)) (List.rev cases)
-				],p)
-		)
+		let acc = DynArray.create () in
+		for i = num_labels -1 downto 0 do
+			let e = loop dt.dt_dt_lookup.(i) in
+			DynArray.add acc (ELabel (get_label i),p);
+			DynArray.add acc e;
+		done;
+		DynArray.add acc (ELabel (get_label num_labels),p);
+		DynArray.add acc (ident p "@ret");
+		let el = DynArray.to_list acc in
+		let var_init = List.fold_left (fun acc (v,eo) -> (v.v_name,(match eo with None -> None | Some e -> Some (gen_expr ctx e))) :: acc) [] dt.dt_var_init in
+		let state_init = Hashtbl.fold (fun v _ l -> (v_name v,null p) :: l) state [] in
+		let init = match var_init,state_init with
+			| [], [] -> []
+			| el, [] -> el
+			| [], vl -> ["@state",Some (EObject vl,p)]
+			| el, vl -> ("@state",Some (EObject vl,p)) :: el
+		in
+		let el = match init with [] -> (goto dt.dt_first) :: el | _ -> (EVars init,p) :: (goto dt.dt_first) :: el in
+		EBlock el,p
 	| TSwitch (e,cases,eo) ->
 		let e = gen_expr ctx e in
 		let eo = (match eo with None -> None | Some e -> Some (gen_expr ctx e)) in
@@ -729,7 +751,7 @@ let generate_libs_init = function
 				"@b", Some (EIf (op "==" es (str p "Windows"),
 					op "+" (call p (ident p "@env") [str p "HAXEPATH"]) (str p "\\lib\\"),
 					Some (ETry (
-						op "+" (call p (loadp "file_contents" 1) [op "+" (call p (ident p "@env") [str p "HOME"]) (str p "./haxelib")]) (str p "/"),
+						op "+" (call p (loadp "file_contents" 1) [op "+" (call p (ident p "@env") [str p "HOME"]) (str p "/.haxelib")]) (str p "/"),
 						"e",
 						(EIf (op "==" es (str p "Linux"),
 							str p "/usr/lib/haxe/lib/",
@@ -763,6 +785,7 @@ let new_context com ver macros =
 		curclass = "$boot";
 		curmethod = "$init";
 		inits = [];
+		label_count = 0;
 	}
 
 let header() =

+ 16 - 52
genphp.ml

@@ -609,6 +609,7 @@ and gen_call ctx e el =
 	| TFunction _, []
 	| TCall _, []
 	| TParenthesis _, []
+	| TMeta _, []
 	| TBlock _, [] ->
 		ctx.is_call <- true;
 		spr ctx "call_user_func(";
@@ -619,6 +620,7 @@ and gen_call ctx e el =
 	| TFunction _, el
 	| TCall _, el
 	| TParenthesis _, el
+	| TMeta _, el
 	| TBlock _, el ->
 		ctx.is_call <- true;
 		spr ctx "call_user_func_array(";
@@ -801,6 +803,7 @@ and gen_field_access ctx isvar e s =
 		gen_member_access ctx isvar e s
 	| TBlock _
 	| TParenthesis _
+	| TMeta _
 	| TObjectDecl _
 	| TArrayDecl _
 	| TNew _ ->
@@ -1001,6 +1004,7 @@ and gen_expr ctx e =
 		| TCall _
 		| TBlock _
 		| TParenthesis _
+		| TMeta _
 		| TArrayDecl _ ->
 			spr ctx "_hx_array_get(";
 			gen_value ctx e1;
@@ -1222,6 +1226,9 @@ and gen_expr ctx e =
 			print ctx " %s " (Ast.s_binop op);
 			gen_value_op ctx e2;
 		));
+	| TEnumParameter(e1,i) ->
+		gen_value ctx e1;
+		print ctx "->params[%d]" i;
 	| TField (e1,s) ->
 		gen_tfield ctx e e1 (field_name s)
 	| TTypeExpr t ->
@@ -1236,6 +1243,8 @@ and gen_expr ctx e =
 			gen_value ctx e;
 			spr ctx ")"
 		);
+	| TMeta (_,e) ->
+		gen_value ctx e
 	| TReturn eo ->
 		(match eo with
 		| None ->
@@ -1294,7 +1303,7 @@ and gen_expr ctx e =
 				| TThrow _
 				| TWhile _
 				| TFor _
-				| TMatch _
+				| TPatMatch _
 				| TTry _
 				| TBreak
 				| TBlock _ ->
@@ -1308,7 +1317,7 @@ and gen_expr ctx e =
 					| TThrow _
 					| TWhile _
 					| TFor _
-					| TMatch _
+					| TPatMatch _
 					| TTry _
 					| TBlock _ -> ()
 					| _ ->
@@ -1576,55 +1585,7 @@ and gen_expr ctx e =
 		bend();
 		newline ctx;
 		spr ctx "}"
-	| TMatch (e,_,cases,def) ->
-		let b = save_locals ctx in
-		let tmp = define_local ctx "__hx__t" in
-		print ctx "$%s = " tmp;
-		gen_value ctx e;
-		newline ctx;
-		print ctx "switch($%s->index) {" tmp;
-		let old_loop = ctx.in_loop in
-		ctx.in_loop <- false;
-		ctx.nested_loops <- ctx.nested_loops + 1;
-		newline ctx;
-		List.iter (fun (cl,params,e) ->
-			List.iter (fun c ->
-				print ctx "case %d:" c;
-				newline ctx;
-			) cl;
-			let b = save_locals ctx in
-			(match params with
-			| None | Some [] -> ()
-			| Some l ->
-				let n = ref (-1) in
-				let l = List.fold_left (fun acc v -> incr n; match v with None -> acc | Some v -> (v.v_name,v.v_type,!n) :: acc) [] l in
-				match l with
-				| [] -> ()
-				| l ->
-					concat ctx "; " (fun (v,t,n) ->
-						let v = define_local ctx v in
-						print ctx "$%s = $%s->params[%d]" v tmp n;
-					) l;
-					newline ctx);
-			restore_in_block ctx in_block;
-			gen_expr ctx (mk_block e);
-			print ctx "break";
-			newline ctx;
-			b()
-		) cases;
-		(match def with
-		| None -> ()
-		| Some e ->
-			spr ctx "default:";
-			restore_in_block ctx in_block;
-			gen_expr ctx (mk_block e);
-			print ctx "break";
-			newline ctx;
-		);
-		ctx.nested_loops <- ctx.nested_loops - 1;
-		ctx.in_loop <- old_loop;
-		spr ctx "}";
-		b()
+	| TPatMatch dt -> assert false
 	| TSwitch (e,cases,def) ->
 		let old_loop = ctx.in_loop in
 		ctx.in_loop <- false;
@@ -1733,6 +1694,7 @@ and canbe_ternary_param e =
 	| TLocal _
 	| TField (_,FEnum _)
 	| TParenthesis _
+	| TMeta _
 	| TObjectDecl _
 	| TArrayDecl _
 	| TCall _
@@ -1760,8 +1722,10 @@ and gen_value ctx e =
 	| TLocal _
 	| TArray _
 	| TBinop _
+	| TEnumParameter _
 	| TField _
 	| TParenthesis _
+	| TMeta _
 	| TObjectDecl _
 	| TArrayDecl _
 	| TCall _
@@ -1811,7 +1775,7 @@ and gen_value ctx e =
 	| TThrow _
 	| TSwitch _
 	| TFor _
-	| TMatch _
+	| TPatMatch _
 	| TIf _
 	| TTry _ ->
 		inline_block ctx e

+ 7 - 3
genswf8.ml

@@ -588,6 +588,10 @@ let rec gen_access ?(read_write=false) ctx forcall e =
 		if read_write then assert false;
 		push ctx [VStr (f,is_protected ctx e.etype f)];
 		VarClosure
+	| TEnumParameter(e,i) ->
+		gen_expr ctx true e;
+		push ctx [VInt i];
+		VarObj
 	| TField (e2,f) ->
 		gen_expr ctx true e2;
 		if read_write then write ctx ADup;
@@ -970,6 +974,7 @@ and gen_expr_2 ctx retval e =
 	match e.eexpr with
 	| TConst TSuper
 	| TConst TThis
+	| TEnumParameter _
 	| TField _
 	| TArray _
 	| TLocal _
@@ -977,7 +982,7 @@ and gen_expr_2 ctx retval e =
 		getvar ctx (gen_access ctx false e)
 	| TConst c ->
 		gen_constant ctx c e.epos
-	| TParenthesis e ->
+	| TParenthesis e | TMeta (_,e) ->
 		gen_expr ctx retval e
 	| TBlock el ->
 		let rec loop = function
@@ -1164,8 +1169,7 @@ and gen_expr_2 ctx retval e =
 		gen_expr ctx retval e
 	| TCast (e1,Some t) ->
 		gen_expr ctx retval (Codegen.default_cast ctx.com e1 t e.etype e.epos)
-	| TMatch (e,_,cases,def) ->
-		gen_match ctx retval e cases def
+	| TPatMatch dt -> assert false
 	| TFor (v,it,e) ->
 		gen_expr ctx true it;
 		let r = alloc_tmp ctx in

+ 17 - 10
genswf9.ml

@@ -862,6 +862,11 @@ let rec gen_access ctx e (forset : 'a) : 'a access =
 		let id, _, _ = property ctx f e1.etype in
 		write ctx HThis;
 		VSuper id
+	| TEnumParameter (e1,i) ->
+		gen_expr ctx true e1;
+		write ctx (HGetProp (ident "params"));
+		write ctx (HSmallInt i);
+		VArray
 	| TField (e1,f) ->
 		let f = field_name f in
 		let id, k, closure = property ctx f e1.etype in
@@ -989,7 +994,7 @@ let rec gen_expr_content ctx retval e =
 		gen_expr ctx true e;
 		write ctx HThrow;
 		no_value ctx retval;
-	| TParenthesis e ->
+	| TParenthesis e | TMeta (_,e) ->
 		gen_expr ctx retval e
 	| TObjectDecl fl ->
 		List.iter (fun (name,e) ->
@@ -1036,7 +1041,8 @@ let rec gen_expr_content ctx retval e =
 	| TLocal _
 	| TTypeExpr _ ->
 		getvar ctx (gen_access ctx e Read)
-	| TArray _ ->
+	(* both accesses return dynamic so let's cast them to the real type *)
+	| TEnumParameter _ | TArray _ ->
 		getvar ctx (gen_access ctx e Read);
 		coerce ctx (classify ctx e.etype)
 	| TBinop (op,e1,e2) ->
@@ -1203,7 +1209,7 @@ let rec gen_expr_content ctx retval e =
 			let rec get_int e =
 				match e.eexpr with
 				| TConst (TInt n) -> if n < 0l || n > 512l then raise Exit; Int32.to_int n
-				| TParenthesis e | TBlock [e] -> get_int e
+				| TParenthesis e | TBlock [e] | TMeta (_,e) -> get_int e
 				| _ -> raise Not_found
 			in
 			List.iter (fun (vl,_) -> List.iter (fun v ->
@@ -1273,7 +1279,7 @@ let rec gen_expr_content ctx retval e =
 		);
 		List.iter (fun j -> j()) jend;
 		branch());
-	| TMatch (e0,_,cases,def) ->
+(* 	| TMatch (e0,_,cases,def) ->
 		let t = classify ctx e.etype in
 		let rparams = alloc_reg ctx (KType (type_path ctx ([],"Array"))) in
 		let has_params = List.exists (fun (_,p,_) -> p <> None) cases in
@@ -1324,7 +1330,8 @@ let rec gen_expr_content ctx retval e =
 		) cases in
 		switch();
 		List.iter (fun j -> j()) jends;
-		free_reg ctx rparams
+		free_reg ctx rparams *)
+	| TPatMatch dt -> assert false
 	| TCast (e1,t) ->
 		gen_expr ctx retval e1;
 		if retval then begin
@@ -1699,15 +1706,15 @@ and generate_function ctx fdata stat =
 			| TReturn (Some e) ->
 				let rec inner_loop e =
 					match e.eexpr with
-					| TSwitch _ | TMatch _ | TFor _ | TWhile _ | TTry _ -> false
+					| TSwitch _ | TPatMatch _ | TFor _ | TWhile _ | TTry _ -> false
 					| TIf _ -> loop e
-					| TParenthesis e -> inner_loop e
+					| TParenthesis e | TMeta(_,e) -> inner_loop e
 					| _ -> true
 				in
 				inner_loop e
 			| TIf (_,e1,Some e2) -> loop e1 && loop e2
 			| TSwitch (_,_,Some e) -> loop e
-			| TParenthesis e -> loop e
+			| TParenthesis e | TMeta(_,e) -> loop e
 			| _ -> false
 		in
 		if not (loop fdata.tf_expr) then write ctx HRetVoid;
@@ -1716,7 +1723,7 @@ and generate_function ctx fdata stat =
 
 and jump_expr_gen ctx e jif jfun =
 	match e.eexpr with
-	| TParenthesis e -> jump_expr_gen ctx e jif jfun
+	| TParenthesis e | TMeta(_,e) -> jump_expr_gen ctx e jif jfun
 	| TBinop (op,e1,e2) ->
 		let j t f =
 			check_binop ctx e1 e2;
@@ -1800,7 +1807,7 @@ let rec is_const e =
 	| TConst _ -> true
 	| TArrayDecl el | TBlock el -> List.for_all is_const el
 	| TObjectDecl fl -> List.for_all (fun (_,e) -> is_const e) fl
-	| TParenthesis e -> is_const e
+	| TParenthesis e | TMeta(_,e) -> is_const e
 	| TFunction _ -> true
 	| _ -> false
 

+ 10 - 13
genxml.ml

@@ -81,21 +81,13 @@ let rec follow_param t =
 	| _ ->
 		t
 
-let rec sexpr (e,_) =
-	match e with
-	| EConst c -> s_constant c
-	| EParenthesis e -> "(" ^ (sexpr e) ^ ")"
-	| EArrayDecl el -> "[" ^ (String.concat "," (List.map sexpr el)) ^ "]"
-	| EObjectDecl fl -> "{" ^ (String.concat "," (List.map (fun (n,e) -> n ^ ":" ^ (sexpr e)) fl)) ^ "}"
-	| _ -> "'???'"
-
 let gen_meta meta =
 	let meta = List.filter (fun (m,_,_) -> match m with Meta.Used | Meta.MaybeUsed | Meta.RealPath -> false | _ -> true) meta in
 	match meta with
 	| [] -> []
 	| _ ->
 		let nodes = List.map (fun (m,el,_) ->
-			node "m" ["n",fst (MetaInfo.to_string m)] (List.map (fun e -> node "e" [] [gen_string (sexpr e)]) el)
+			node "m" ["n",fst (MetaInfo.to_string m)] (List.map (fun e -> node "e" [] [gen_string (Ast.s_expr e)]) el)
 		) meta in
 		[node "meta" [] nodes]
 
@@ -133,7 +125,11 @@ and gen_field att f =
 			| MethInline -> ("get", "inline") :: ("set","null") :: att)
 	) in
 	let att = (match f.cf_params with [] -> att | l -> ("params", String.concat ":" (List.map (fun (n,_) -> n) l)) :: att) in
-	node f.cf_name (if f.cf_public then ("public","1") :: att else att) (gen_type f.cf_type :: gen_meta f.cf_meta @ gen_doc_opt f.cf_doc)
+	let overloads = match List.map (gen_field []) f.cf_overloads with
+		| [] -> []
+		| nl -> [node "overloads" [] nl]
+	in
+	node f.cf_name (if f.cf_public then ("public","1") :: att else att) (gen_type f.cf_type :: gen_meta f.cf_meta @ gen_doc_opt f.cf_doc @ overloads)
 
 let gen_constr e =
 	let doc = gen_doc_opt e.ef_doc in
@@ -161,7 +157,7 @@ let rec exists f c =
 			| None -> false
 			| Some (csup,_) -> exists f csup
 
-let gen_type_decl com pos t =
+let rec gen_type_decl com pos t =
 	let m = (t_infos t).mt_module in
 	match t with
 	| TClassDecl c ->
@@ -200,7 +196,8 @@ let gen_type_decl com pos t =
 		let meta = gen_meta a.a_meta in
 		let sub = (match a.a_from with [] -> [] | l -> [node "from" [] (List.map (fun (t,_) -> gen_type t) l)]) in
 		let super = (match a.a_to with [] -> [] | l -> [node "to" [] (List.map (fun (t,_) -> gen_type t) l)]) in
-		node "abstract" (gen_type_params pos a.a_private (tpath t) a.a_types a.a_pos m) (sub @ super @ doc @ meta)
+		let impl = (match a.a_impl with None -> [] | Some c -> [node "impl" [] [gen_type_decl com pos (TClassDecl c)]]) in
+		node "abstract" (gen_type_params pos a.a_private (tpath t) a.a_types a.a_pos m) (sub @ super @ doc @ meta @ impl)
 
 let att_str att =
 	String.concat "" (List.map (fun (a,v) -> Printf.sprintf " %s=\"%s\"" a v) att)
@@ -342,7 +339,7 @@ let generate_type com t =
 			| _ ->
 			match pl with
 			| [] -> p "@%s " (fst (MetaInfo.to_string m))
-			| l -> p "@%s(%s) " (fst (MetaInfo.to_string m)) (String.concat "," (List.map sexpr pl))
+			| l -> p "@%s(%s) " (fst (MetaInfo.to_string m)) (String.concat "," (List.map Ast.s_expr pl))
 		) ml
 	in
 	let access a =

+ 11 - 6
interp.ml

@@ -1705,7 +1705,7 @@ let std_lib =
 				if i < 0 then
 					acc
 				else
-					let e, v = ExtString.String.split "=" env.(i) in
+					let e, v = ExtString.String.split env.(i) "=" in
 					loop (VArray [|VString e;VString v;acc|]) (i - 1)
 			in
 			loop VNull (Array.length env - 1)
@@ -2108,7 +2108,9 @@ let macro_lib =
 			| VFunction (Fun1 _) ->
 				let ctx = get_ctx() in
 				ctx.curapi.on_type_not_found (fun path ->
-					ctx.do_call VNull f [enc_string path] null_pos
+					match catch_errors ctx (fun () -> ctx.do_call VNull f [enc_string path] null_pos) with
+					| Some v -> v
+					| None -> VNull
 				);
 				VNull
 			| _ -> error()
@@ -4354,7 +4356,7 @@ let rec make_const e =
 		| TBool b -> VBool b
 		| TNull -> VNull
 		| TThis | TSuper -> raise Exit)
-	| TParenthesis e ->
+	| TParenthesis e | TMeta(_,e) ->
 		make_const e
 	| TObjectDecl el ->
 		VObject (obj (hash_field (get_ctx())) (List.map (fun (f,e) -> f, make_const e) el))
@@ -4468,6 +4470,7 @@ let rec make_ast e =
 	| TLocal v -> EConst (mk_ident v.v_name)
 	| TArray (e1,e2) -> EArray (make_ast e1,make_ast e2)
 	| TBinop (op,e1,e2) -> EBinop (op, make_ast e1, make_ast e2)
+	| TEnumParameter (e,i) -> assert false
 	| TField (e,f) -> EField (make_ast e, Type.field_name f)
 	| TTypeExpr t -> fst (mk_path (full_type_path t) e.epos)
 	| TParenthesis e -> EParenthesis (make_ast e)
@@ -4493,7 +4496,7 @@ let rec make_ast e =
 		) cases in
 		let def = match eopt def with None -> None | Some (EBlock [],_) -> Some None | e -> Some e in
 		ESwitch (make_ast e,cases,def)
-	| TMatch (e,(en,_),cases,def) ->
+(* 	| TMatch (e,(en,_),cases,def) ->
 		let scases (idx,args,e) =
 			let p = e.epos in
 			let unused = (EConst (Ident "_"),p) in
@@ -4515,7 +4518,8 @@ let rec make_ast e =
 			) idx, None, (match e.eexpr with TBlock [] -> None | _ -> Some (make_ast e))
 		in
 		let def = match eopt def with None -> None | Some (EBlock [],_) -> Some None | e -> Some e in
-		ESwitch (make_ast e,List.map scases cases,def)
+		ESwitch (make_ast e,List.map scases cases,def) *)
+	| TPatMatch dt -> assert false
 	| TTry (e,catches) -> ETry (make_ast e,List.map (fun (v,e) -> v.v_name, (try make_type v.v_type with Exit -> assert false), make_ast e) catches)
 	| TReturn e -> EReturn (eopt e)
 	| TBreak -> EBreak
@@ -4528,7 +4532,8 @@ let rec make_ast e =
 				let t = (match t with TClassDecl c -> TInst (c,[]) | TEnumDecl e -> TEnum (e,[]) | TTypeDecl t -> TType (t,[]) | TAbstractDecl a -> TAbstract (a,[])) in
 				Some (try make_type t with Exit -> assert false)
 		) in
-		ECast (make_ast e,t))
+		ECast (make_ast e,t)
+	| TMeta (m,e) -> EMeta(m,make_ast e))
 	,e.epos)
 
 ;;

+ 30 - 8
main.ml

@@ -44,7 +44,7 @@ type cache = {
 exception Abort
 exception Completion of string
 
-let version = 300
+let version = 310
 
 let measure_times = ref false
 let prompt = ref false
@@ -105,6 +105,18 @@ let deprecated = [
 	"#Xml has no field createProlog", "Xml.createProlog was renamed to Xml.createProcessingInstruction";
 ]
 
+let limit_string s offset =
+	let rest = 80 - offset in
+	let words = ExtString.String.nsplit s " " in
+	let rec loop i words = match words with
+		| word :: words ->
+			if String.length word + i + 1 > rest then (Printf.sprintf "\n%*s" offset "") :: word :: loop (String.length word) words
+			else (if i = 0 then "" else " ") :: word :: loop (i + 1 + String.length word) words
+		| [] ->
+			[]
+	in
+	String.concat "" (loop 0 words)
+
 let error ctx msg p =
 	let msg = try List.assoc msg deprecated with Not_found -> msg in
 	message ctx msg p;
@@ -1030,20 +1042,23 @@ try
 			did_something := true;
 		),": print version and exit");
 		("--help-defines", Arg.Unit (fun() ->
+			let m = ref 0 in
 			let rec loop i =
 				let d = Obj.magic i in
 				if d <> Define.Last then begin
 					let t, doc = Define.infos d in
-					let str = String.concat "-" (ExtString.String.nsplit t "_") ^ " : " ^ doc in
-					str :: loop (i + 1)
+					if String.length t > !m then m := String.length t;
+					((String.concat "-" (ExtString.String.nsplit t "_")),doc) :: (loop (i + 1))
 				end else
 					[]
 			in
-			let all = List.sort String.compare (loop 0) in
+			let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) (loop 0) in
+			let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" !m n (limit_string doc (!m + 3))) all in
 			List.iter (fun msg -> ctx.com.print (msg ^ "\n")) all;
 			did_something := true
 		),": print help for all compiler specific defines");
 		("--help-metas", Arg.Unit (fun() ->
+			let m = ref 0 in
 			let rec loop i =
 				let d = Obj.magic i in
 				if d <> Meta.Last then begin
@@ -1067,14 +1082,16 @@ try
 							| [p] -> " (" ^ platform_name p ^ " only)"
 							| pl -> " (for " ^ String.concat "," (List.map platform_name pl) ^ ")"
 						) in
-						let str = "@" ^ t ^ params ^ " : " ^ doc ^ pfs in
-						str :: loop (i + 1)
+						let str = "@" ^ t in
+						if String.length str > !m then m := String.length str;
+						(str,params ^ doc ^ pfs) :: loop (i + 1)
 					end else
 						loop (i + 1)
 				end else
 					[]
 			in
-			let all = List.sort String.compare (loop 0) in
+			let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) (loop 0) in
+			let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" !m n (limit_string doc (!m + 3))) all in
 			List.iter (fun msg -> ctx.com.print (msg ^ "\n")) all;
 			did_something := true
 		),": print help for all compiler metadatas");
@@ -1210,6 +1227,11 @@ try
 			Codegen.detect_usage com;
 		let dce_mode = (try Common.defined_value com Define.Dce with _ -> "no") in
 		if not (!gen_as3 || dce_mode = "no" || Common.defined com Define.DocGen) then Dce.run com main (dce_mode = "full" && not !interp);
+		(* always filter empty abstract implementation classes (issue #1885) *)
+		List.iter (fun mt -> match mt with
+			| TClassDecl({cl_kind = KAbstractImpl _} as c) when c.cl_ordered_statics = [] && c.cl_ordered_fields = [] -> c.cl_extern <- true
+			| _ -> ()
+		) com.types;
 		let type_filters = [
 			Codegen.check_private_path;
 			Codegen.remove_generic_base;
@@ -1348,7 +1370,7 @@ with
 			Buffer.add_string b ("<meta name=\"" ^ (fst (MetaInfo.to_string m)) ^ "\"");
 			if el = [] then Buffer.add_string b "/>" else begin
 				Buffer.add_string b ">\n";
-				List.iter (fun e -> Buffer.add_string b ((htmlescape (Genxml.sexpr e)) ^ "\n")) el;
+				List.iter (fun e -> Buffer.add_string b ((htmlescape (Ast.s_expr e)) ^ "\n")) el;
 				Buffer.add_string b "</meta>\n";
 			end
 		) m;

+ 260 - 362
matcher.ml

@@ -25,9 +25,12 @@ open Common
 open Type
 open Typecore
 
+type pvar = tvar * pos
+
 type con_def =
 	| CEnum of tenum * tenum_field
 	| CConst of tconstant
+	| CAny
 	| CType of module_type
 	| CArray of int
 	| CFields of int * (string * tclass_field) list
@@ -39,7 +42,27 @@ and con = {
 	c_pos : pos;
 }
 
-type pvar = tvar * pos
+and st_def =
+	| SVar of tvar
+	| SField of st * string
+	| SEnum of st * tenum_field * int
+	| SArray of st * int
+	| STuple of st * int * int
+
+and st = {
+	st_def : st_def;
+	st_type : t;
+	st_pos : pos;
+}
+
+and dt =
+	| Switch of st * (con * dt) list
+	| Bind of ((tvar * pos) * st) list * dt
+	| Goto of int
+	| Expr of texpr
+	| Guard of texpr * dt * dt option
+
+(* Pattern *)
 
 type pat_def =
 	| PAny
@@ -55,19 +78,6 @@ and pat = {
 	p_pos : pos;
 }
 
-type st_def =
-	| SVar of tvar
-	| SField of st * string
-	| SEnum of st * string * int
-	| SArray of st * int
-	| STuple of st * int * int
-
-and st = {
-	st_def : st_def;
-	st_type : t;
-	st_pos : pos;
-}
-
 type out = {
 	o_expr : texpr;
 	o_guard : texpr option;
@@ -78,28 +88,23 @@ type out = {
 type pat_vec = pat array * out
 type pat_matrix = pat_vec list
 
+(* Context *)
+
 type pattern_ctx = {
 	mutable pc_locals : (string, pvar) PMap.t;
 	mutable pc_sub_vars : (string, pvar) PMap.t option;
 	mutable pc_reify : bool;
 }
 
-type dt =
-	| Out of out * dt option
-	| Switch of st * (con * dt) list
-	| Bind of (pvar * st) list * dt
-	| Goto of int
-
 type matcher = {
 	ctx : typer;
-	stl : st list;
 	need_val : bool;
-	v_lookup : (string,tvar) Hashtbl.t;
+	dt_cache : (dt,int) Hashtbl.t;
+	dt_lut : dt DynArray.t;
+	mutable dt_count : int;
 	mutable outcomes : (pat list,out) PMap.t;
-	mutable out_type : Type.t;
 	mutable toplevel_or : bool;
 	mutable used_paths : (int,bool) Hashtbl.t;
-	mutable eval_stack : (pvar * st) list list;
 }
 
 exception Not_exhaustive of pat * st
@@ -113,6 +118,7 @@ let arity con = match con.c_def with
 	| CArray i -> i
 	| CFields (i,_) -> i
 	| CExpr _ -> 0
+	| CAny -> 0
 
 let mk_st def t p = {
 	st_def = def;
@@ -166,16 +172,23 @@ let mk_subs st con =
 	let map = match follow st.st_type with
 		| TInst(c,pl) -> apply_params c.cl_types pl
 		| TEnum(en,pl) -> apply_params en.e_types pl
+		| TAbstract(a,pl) -> apply_params a.a_types pl
 		| _ -> fun t -> t
 	in
 	match con.c_def with
 	| CFields (_,fl) -> List.map (fun (s,cf) -> mk_st (SField(st,s)) (map cf.cf_type) st.st_pos) fl
 	| CEnum (en,({ef_type = TFun _} as ef)) ->
-		let pl = match follow con.c_type with TEnum(_,pl) | TAbstract({a_this = TEnum(_)},pl)-> pl | TAbstract({a_path = [],"EnumValue"},[]) -> [] | _ -> [] in
+		let rec loop t = match follow t with
+			| TEnum(_,pl) -> pl
+			| TAbstract({a_path = [],"EnumValue"},[]) -> []
+			| TAbstract(a,pl) -> loop (Codegen.Abstract.get_underlying_type a pl)
+			| _ -> []
+		in
+		let pl = loop con.c_type in
 		begin match apply_params en.e_types pl (monomorphs ef.ef_params ef.ef_type) with
 			| TFun(args,r) ->
 				ExtList.List.mapi (fun i (_,_,t) ->
-					mk_st (SEnum(st,ef.ef_name,i)) t st.st_pos
+					mk_st (SEnum(st,ef,i)) t st.st_pos
 				) args
 			| _ ->
 				assert false
@@ -184,7 +197,7 @@ let mk_subs st con =
 	| CArray i ->
 		let t = match follow con.c_type with TInst({cl_path=[],"Array"},[t]) -> t | _ -> assert false in
 		ExtList.List.init i (fun i -> mk_st (SArray(st,i)) t st.st_pos)
-	| CEnum _ | CConst _ | CType _ | CExpr _ ->
+	| CEnum _ | CConst _ | CType _ | CExpr _ | CAny ->
 		[]
 
 let get_tuple_types t = match t with
@@ -195,15 +208,9 @@ let get_tuple_types t = match t with
 
 let s_type = s_type (print_context())
 
-let rec s_expr_small e = match e.eexpr with
-	| TLocal v -> v.v_name
-	| TField (e,s) -> s_expr_small e ^ "." ^ field_name s
-	| TBlock [] -> "{}"
-	| _ -> s_expr (s_type) e
-
-let s_con con = match con.c_def with
+let rec s_con con = match con.c_def with
 	| CEnum(_,ef) -> ef.ef_name
-	| CConst TNull -> "_"
+	| CAny -> "_"
 	| CConst c -> s_const c
 	| CType mt -> s_type_path (t_path mt)
 	| CArray i -> "[" ^(string_of_int i) ^ "]"
@@ -219,42 +226,24 @@ let rec s_pat pat = match pat.p_def with
 	| PBind((v,_),pat) -> v.v_name ^ "=" ^ s_pat pat
 	| PTuple pl -> "(" ^ (String.concat " " (Array.to_list (Array.map s_pat pl))) ^ ")"
 
+let rec s_pat_vec pl =
+	String.concat " " (Array.to_list (Array.map s_pat pl))
+
+let rec s_pat_matrix pmat =
+	String.concat "\n" (List.map (fun (pl,out) -> (s_pat_vec pl) ^ "->" ^ "") pmat)
+
 let st_args l r v =
 	(if l > 0 then (String.concat "," (ExtList.List.make l "_")) ^ "," else "")
 	^ v ^
 	(if r > 0 then "," ^ (String.concat "," (ExtList.List.make r "_")) else "")
 
-let rec s_st st = (match st.st_def with
+let rec s_st st =
+	(match st.st_def with
 	| SVar v -> v.v_name
-	| SEnum (st,n,i) -> s_st st ^ "." ^ n ^ "." ^ (string_of_int i)
+	| SEnum (st,ef,i) -> s_st st ^ "." ^ ef.ef_name ^ "." ^ (string_of_int i)
 	| SArray (st,i) -> s_st st ^ "[" ^ (string_of_int i) ^ "]"
 	| STuple (st,i,a) -> "(" ^ (st_args i (a - i - 1) (s_st st)) ^ ")"
 	| SField (st,n) -> s_st st ^ "." ^ n)
-	(* ^ ":" ^ (s_type st.st_type) *)
-
-let rec s_pat_vec pl =
-	String.concat " " (Array.to_list (Array.map s_pat pl))
-
-let s_out out = ""
-	(* ^ s_expr_small out.o_expr *)
-
-let rec s_pat_matrix pmat =
-	String.concat "\n" (List.map (fun (pl,out) -> (s_pat_vec pl) ^ "->" ^ (s_out out)) pmat)
-
-let rec s_dt tabs tree = tabs ^ match tree with
-	| Out(out,None)->
-		s_out out;
-	| Out(out,Some dt) ->
-		"if (" ^ (s_expr_small (match out.o_guard with Some e -> e | None -> assert false)) ^ ") " ^ (s_out out) ^ " else " ^ s_dt tabs dt
-	| Switch (st, cl) ->
-		"switch(" ^ (s_st st) ^ ") { \n" ^ tabs
-		^ (String.concat ("\n" ^ tabs) (List.map (fun (c,dt) ->
-			"case " ^ (s_con c) ^ ":\n" ^ (s_dt (tabs ^ "\t") dt)
-		) cl))
-		^ "\n" ^ (if String.length tabs = 0 then "" else (String.sub tabs 0 (String.length tabs - 1))) ^ "}"
-	| Bind (bl, dt) -> "bind " ^ (String.concat "," (List.map (fun ((v,_),st) -> v.v_name ^ "(" ^ (string_of_int v.v_id) ^ ") =" ^ (s_st st)) bl)) ^ "\n" ^ (s_dt tabs dt)
-	| Goto i ->
-		"goto " ^ (string_of_int i)
 
 (* Pattern parsing *)
 
@@ -281,6 +270,23 @@ let rec is_value_type = function
 	| _ ->
 		false
 
+(* 	Determines if a type allows null-matching. This is similar to is_nullable, but it infers Null<T> on monomorphs,
+	and enums are not considered nullable *)
+let rec matches_null ctx t = match t with
+	| TMono r ->
+		(match !r with None -> r := Some (ctx.t.tnull (mk_mono())); true | Some t -> matches_null ctx t)
+	| TType ({ t_path = ([],"Null") },[_]) ->
+		true
+	| TLazy f ->
+		matches_null ctx (!f())
+	| TType (t,tl) ->
+		matches_null ctx (apply_params t.t_types tl t.t_type)
+	| TFun _ | TEnum _ ->
+		false
+	| TAbstract (a,_) -> not (Meta.has Meta.NotNull a.a_meta)
+	| _ ->
+		true
+
 let to_pattern ctx e t =
 	let perror p = error "Unrecognized pattern" p in
 	let verror n p = error ("Variable " ^ n ^ " must appear exactly once in each sub-pattern") p in
@@ -297,8 +303,6 @@ let to_pattern ctx e t =
 	let rec loop pctx e t =
 		let p = pos e in
 		match fst e with
-		| EConst(Ident "null") ->
-			error "null-patterns are not allowed" p
 		| ECheckType(e, CTPath({tpackage=["haxe";"macro"]; tname="Expr"})) ->
 			let old = pctx.pc_reify in
 			pctx.pc_reify <- true;
@@ -309,6 +313,9 @@ let to_pattern ctx e t =
 			loop pctx e t
 		| ECast(e1,None) ->
 			loop pctx e1 t
+		| EConst(Ident "null") ->
+			if not (matches_null ctx t) then error ("Null-patterns are only allowed on nullable types (found " ^ (s_type t) ^ ")") p;
+			mk_con_pat (CConst TNull) [] t p
 		| EConst((Ident ("false" | "true") | Int _ | String _ | Float _) as c) ->
 			let e = Codegen.type_constant ctx.com c p in
 			unify ctx e.etype t p;
@@ -562,6 +569,8 @@ let unify_con con1 con2 = match con1.c_def,con2.c_def with
 		t_path mt1 = t_path mt2
 	| CArray a1, CArray a2 ->
 		a1 == a2
+	| CAny, CAny ->
+		true
 	| _ ->
 		false
 
@@ -702,40 +711,46 @@ let column_sigma mctx st pmat =
 	loop pmat;
 	List.rev_map (fun con -> con,not (Hashtbl.mem unguarded con.c_def)) !acc,!bindings
 
-let all_ctors mctx st =
+(* Determines if we have a Null<T>. Unlike is_null, this returns true even if the wrapped type is nullable itself. *)
+let rec is_explicit_null = function
+	| TMono r ->
+		(match !r with None -> false | Some t -> is_null t)
+	| TType ({ t_path = ([],"Null") },[t]) ->
+		true
+	| TLazy f ->
+		is_null (!f())
+	| TType (t,tl) ->
+		is_null (apply_params t.t_types tl t.t_type)
+	| _ ->
+		false
+
+let rec all_ctors mctx t =
 	let h = ref PMap.empty in
-	let inf = match follow st.st_type with
+	(* if is_explicit_null t then h := PMap.add (CConst TNull) Ast.null_pos !h; *)
+	match follow t with
 	| TAbstract({a_path = [],"Bool"},_) ->
 		h := PMap.add (CConst(TBool true)) Ast.null_pos !h;
 		h := PMap.add (CConst(TBool false)) Ast.null_pos !h;
-		false
+		h,false
+	| TAbstract(a,pl) -> all_ctors mctx (Codegen.Abstract.get_underlying_type a pl)
 	| TInst({cl_path=[],"String"},_)
-	| TInst({cl_path=[],"Array"},_)
-	| TAbstract _ ->
-		true
+	| TInst({cl_path=[],"Array"},_) ->
+		h,true
 	| TEnum(en,pl) ->
 		PMap.iter (fun _ ef ->
-			let tc = monomorphs mctx.ctx.type_params st.st_type in
+			let tc = monomorphs mctx.ctx.type_params t in
 			try unify_enum_field en pl ef tc;
 				h := PMap.add (CEnum(en,ef)) ef.ef_pos !h
 			with Unify_error _ ->
 				()
 		) en.e_constrs;
-		false
-	| TInst ({cl_kind = KTypeParameter _},_) ->
-		error "Unapplied type parameter" st.st_pos
+		h,false
 	| TAnon a ->
-		(match !(a.a_status) with
-		| Statics c ->
-			true
-		| _ ->
-			false)
+		h,true
 	| TInst(_,_) ->
-		false
+		h,false
 	| _ ->
-		true
-	in
-	h,inf
+		h,true
 
 let rec collapse_pattern pl = match pl with
 	| pat :: [] ->
@@ -769,11 +784,27 @@ let bind_remaining out pv stl =
 	in
 	loop stl pv
 
-let rec compile mctx stl pmat = match pmat with
+let get_cache mctx dt =
+	match dt with Goto _ -> dt | _ ->
+	try
+		let i = Hashtbl.find mctx.dt_cache dt in
+		Goto i
+	with Not_found ->
+		Hashtbl.replace mctx.dt_cache dt mctx.dt_count;
+		mctx.dt_count <- mctx.dt_count + 1;
+		DynArray.add mctx.dt_lut dt;
+		dt
+
+let rec compile mctx stl pmat =
+	let guard e dt1 dt2 = get_cache mctx (Guard(e,dt1,dt2)) in
+	let expr e = get_cache mctx (Expr e) in
+	let bind bl dt = get_cache mctx (Bind(bl,dt)) in
+	let switch st cl = get_cache mctx (Switch(st,cl)) in
+	get_cache mctx (match pmat with
 	| [] ->
 		(match stl with
 		| st :: stl ->
-			let all,inf = all_ctors mctx st in
+			let all,inf = all_ctors mctx st.st_type in
 			let pl = PMap.foldi (fun cd p acc -> (mk_con_pat cd [] t_dynamic p) :: acc) !all [] in
 			begin match pl,inf with
 				| _,true
@@ -791,12 +822,11 @@ let rec compile mctx stl pmat = match pmat with
 		if i = -1 then begin
 			Hashtbl.replace mctx.used_paths out.o_id true;
 			let bl = bind_remaining out pv stl in
-			let dt = if out.o_guard = None || match pl with [] -> true | _ -> false then
-				Out(out,None)
-			else
-				Out(out,Some (compile mctx stl pl))
+			let dt = match out.o_guard with
+				| None -> expr out.o_expr
+				| Some e -> guard e (expr out.o_expr) (match pl with [] -> None | _ -> Some (compile mctx stl pl))
 			in
-			if bl = [] then dt else Bind(bl,dt)
+			(if bl = [] then dt else bind bl dt)
 		end else if i > 0 then begin
 			let pmat = swap_pmat_columns i pmat in
 			let stls = swap_columns i stl in
@@ -804,7 +834,7 @@ let rec compile mctx stl pmat = match pmat with
 		end else begin
 			let st_head,st_tail = match stl with st :: stl -> st,stl | _ -> assert false in
 			let sigma,bl = column_sigma mctx st_head pmat in
-			let all,inf = all_ctors mctx st_head in
+			let all,inf = all_ctors mctx st_head.st_type in
 			let cases = List.map (fun (c,g) ->
 				if not g then all := PMap.remove c.c_def !all;
 				let spec = spec mctx c pmat in
@@ -815,12 +845,12 @@ let rec compile mctx stl pmat = match pmat with
 			) sigma in
 			let def = default mctx pmat in
 			let dt = match def,cases with
-			| _,[{c_def = CFields _},dt] ->
+ 			| _,[{c_def = CFields _},dt] ->
 				dt
 			| _ when not inf && PMap.is_empty !all ->
-				Switch(st_head,cases)
+				switch st_head cases
 			| [],_ when inf && not mctx.need_val ->
-				Switch(st_head,cases)
+				switch st_head cases
 			| [],_ when inf ->
 				raise (Not_exhaustive(any,st_head))
 			| [],_ ->
@@ -829,14 +859,21 @@ let rec compile mctx stl pmat = match pmat with
 			| def,[] ->
 				compile mctx st_tail def
 			| def,_ ->
-				let cdef = mk_con (CConst TNull) t_dynamic st_head.st_pos in
+				let cdef = mk_con CAny t_dynamic st_head.st_pos in
 				let cases = cases @ [cdef,compile mctx st_tail def] in
-				Switch(st_head,cases)
+				switch st_head cases
 			in
-			if bl = [] then dt else Bind(bl,dt)
-		end
+			if bl = [] then dt else bind bl dt
+		end)
 
-(* Conversion to typed AST *)
+let rec collapse_case el = match el with
+	| e :: [] ->
+		e
+	| e :: el ->
+		let e2 = collapse_case el in
+		EBinop(OpOr,e,e2),punion (pos e) (pos e2)
+	| [] ->
+		assert false
 
 let mk_const ctx p = function
 	| TString s -> mk (TConst (TString s)) ctx.com.basic.tstring p
@@ -846,238 +883,65 @@ let mk_const ctx p = function
 	| TNull -> mk (TConst TNull) (ctx.com.basic.tnull (mk_mono())) p
 	| _ -> error "Unsupported constant" p
 
-let rec st_to_unique_name ctx st = match st.st_def with
-	| SField(st,f) -> st_to_unique_name ctx st ^ "_f" ^ f
-	| SArray(st,i) -> st_to_unique_name ctx st ^ "_a" ^ (string_of_int i)
-	| SEnum(st,n,i) -> st_to_unique_name ctx st ^ "_e" ^ n ^ "_" ^ (string_of_int i)
-	| SVar v -> v.v_name
-	| STuple (st,_,_) -> st_to_unique_name ctx st
-
-let rec st_to_texpr mctx st = match st.st_def with
+let rec convert_st ctx st = match st.st_def with
 	| SVar v -> mk (TLocal v) v.v_type st.st_pos
 	| SField (sts,f) ->
-		let e = st_to_texpr mctx sts in
+		let e = convert_st ctx sts in
 		let fa = try quick_field e.etype f with Not_found -> FDynamic f in
 		mk (TField(e,fa)) st.st_type st.st_pos
-	| SArray (sts,i) -> mk (TArray(st_to_texpr mctx sts,mk_const mctx.ctx st.st_pos (TInt (Int32.of_int i)))) st.st_type st.st_pos
-	| STuple (st,_,_) -> st_to_texpr mctx st
-	| SEnum _ ->
-		let n = st_to_unique_name mctx st in
-		let v = try	Hashtbl.find mctx.v_lookup n with Not_found ->
-			let v = alloc_var n st.st_type in
-			Hashtbl.add mctx.v_lookup n v;
-			v
-		in
-		mctx.ctx.locals <- PMap.add n v mctx.ctx.locals;
-		mk (TLocal v) v.v_type st.st_pos
-
-let rec st_eq st1 st2 = match st1.st_def,st2.st_def with
-	| STuple (st1,i1,_), STuple(st2,i2,_) -> i1 = i2 && st_eq st1 st2
-	| SEnum(st1,_,i1), SEnum(st2,_,i2) -> i1 = i2 && st_eq st1 st2
-	| SField(st1,f1),SField(st2,f2) -> f1 = f2 && st_eq st1 st2
-	| SArray(st1,i1),SArray(st2,i2) -> i1 = i1 && st_eq st1 st2
-	| SVar _, SVar _ -> true
-	| _ -> false
-
-let is_compatible out1 out2 =
-	out1.o_id = out2.o_id
-	&& out1.o_guard = None
-
-let replace_locals mctx out e =
-	let replace v =
-		let rec loop vl = match vl with
-			| vl :: vll -> (try snd (List.find (fun ((v2,_),st) -> v2 == v) vl) with Not_found -> loop vll)
-			| [] -> raise Not_found
-		in
-		loop mctx.eval_stack
-	in
-	let rec loop e = match e.eexpr with
-		| TLocal v ->
-			(try
-				let st = replace v in
-				unify mctx.ctx e.etype st.st_type e.epos;
-				st_to_texpr mctx st
-			with Not_found ->
-				e)
-		| _ ->
-			Type.map_expr loop e
-	in
-	let e = loop e in
-	(*      if not (Common.defined mctx.ctx.com Define.NoUnusedVarWarnings) then
-	Hashtbl.iter (fun _ (v,p) -> if (String.length v.v_name) > 0 && v.v_name.[0] <> '_' then mctx.ctx.com.warning "This variable is unused" p) all_subterms; *)
-	e
-
-let rec to_typed_ast mctx dt =
-	match dt with
-	| Goto _ ->
-		error "Not implemented yet" Ast.null_pos
-	| Out(out,dt) ->
-		replace_locals mctx out begin match out.o_guard,dt with
-			| Some eg,None ->
-				mk (TIf(eg,out.o_expr,None)) t_dynamic out.o_expr.epos
-			| Some eg,Some dt ->
-				let eelse = to_typed_ast mctx dt in
-				mk (TIf(eg,out.o_expr,Some eelse)) eelse.etype (punion out.o_expr.epos eelse.epos)
-			| _,None ->
-				out.o_expr
-			| _ -> assert false
-		end
-	| Bind (bl, dt) ->
-		List.iter (fun ((v,_),st) ->
-			let e = st_to_texpr mctx st in
-			begin match e.eexpr with
-				| TLocal v2 -> v2.v_name <- v.v_name
-				| _ -> ()
-			end;
-		) bl;
-		mctx.eval_stack <- bl :: mctx.eval_stack;
-		let e = to_typed_ast mctx dt in
-		mctx.eval_stack <- List.tl mctx.eval_stack;
-		e
-	| Switch(st,cases) ->
-		match follow st.st_type with
-		| TEnum(en,pl) | TAbstract({a_this = TEnum(en,_)},pl) -> to_enum_switch mctx en pl st cases
-		| TInst({cl_path = [],"Array"},[t]) -> to_array_switch mctx t st cases
-		| t -> to_value_switch mctx t st cases
-
-and group_cases mctx cases to_case =
-	let def = ref None in
-	let group,cases,dto = List.fold_left (fun (group,cases,dto) (con,dt) -> match con.c_def with
-		| CConst TNull ->
-			let e = to_typed_ast mctx dt in
-			def := Some e;
-			(group,cases,dto)
-		| _ -> match dto with
-			| None -> ([to_case con],cases,Some dt)
-			| Some dt2 -> match dt,dt2 with
-				| Out(out1,_),Out(out2,_) when is_compatible out1 out2 ->
-					((to_case con) :: group,cases,dto)
-				| _ ->
-					let e = to_typed_ast mctx dt2 in
-					([to_case con],(List.rev group,e) :: cases, Some dt)
-	) ([],[],None) cases in
-	let cases = List.rev (match group,dto with
-		| [],None ->
-			cases
-		| group,Some dt ->
-			let e = to_typed_ast mctx dt in
-			(List.rev group,e) :: cases
-		| _ ->
-			assert false
-	) in
-	cases,def
-
-and to_enum_switch mctx en pl st cases =
-	let eval = st_to_texpr mctx st in
-	let to_case con = match con.c_def with
-		| CEnum(en,ef) -> en,ef
-		| _ ->
-			error ("Unexpected") con.c_pos
+	| SArray (sts,i) -> mk (TArray(convert_st ctx sts,mk_const ctx st.st_pos (TInt (Int32.of_int i)))) st.st_type st.st_pos
+	| STuple (st,_,_) -> convert_st ctx st
+	| SEnum(sts,ef,i) -> mk (TEnumParameter(convert_st ctx sts, i)) st.st_type st.st_pos
+
+let convert_con ctx con = match con.c_def with
+	| CConst c -> mk_const ctx con.c_pos c
+	| CType mt -> mk (TTypeExpr mt) t_dynamic con.c_pos
+	| CExpr e -> e
+	| CEnum(e,ef) -> mk_const ctx con.c_pos (TInt (Int32.of_int ef.ef_index))
+	| CArray i -> mk_const ctx con.c_pos (TInt (Int32.of_int i))
+	| CAny ->
+		let t = mk_mono() in
+		mk (TMeta((Meta.MatchAny,[],con.c_pos),mk (TConst (TNull)) t con.c_pos)) t con.c_pos
+	| CFields _ -> assert false
+
+let convert_switch ctx st cases loop =
+	let e_st = convert_st ctx st in
+	let p = e_st.epos in
+	let mk_index_call () =
+		let ttype = match follow (Typeload.load_instance ctx { tpackage = ["std"]; tname="Type"; tparams=[]; tsub = None} p true) with TInst(c,_) -> c | t -> assert false in
+		let cf = PMap.find "enumIndex" ttype.cl_statics in
+		let ec = (!type_module_type_ref) ctx (TClassDecl ttype) None p in
+		let ef = mk (TField(ec, FStatic(ttype,cf))) (tfun [e_st.etype] ctx.t.tint) p in
+		make_call ctx ef [e_st] ctx.t.tint p
 	in
-	let type_case group dt p =
-		let group = List.rev group in
-		let en,ef = List.hd group in
-		let save = save_locals mctx.ctx in
-		let etf = follow (monomorphs en.e_types (monomorphs ef.ef_params ef.ef_type)) in
-		(* TODO: this is horrible !!! *)
-		let capture_vars = match dt with
-			| Out(out,None) ->
-				let vl = PMap.foldi (fun k v acc -> (k,v) :: acc) (List.fold_left (fun acc vl -> List.fold_left (fun acc (v,st) -> if PMap.mem v acc then acc else PMap.add v st acc) acc vl) PMap.empty mctx.eval_stack) [] in
-				Some vl
-			| _ ->
-				None
-		in
-		let vl = match etf with
-			| TFun(args,r) ->
-				let vl = ExtList.List.mapi (fun i (_,_,t) ->
-					let st = mk_st (SEnum(st,ef.ef_name,i)) t st.st_pos in
-					let mk_e () = Some (match (st_to_texpr mctx st).eexpr with TLocal v -> v | _ -> assert false) in
-					begin match capture_vars with
-						| Some cvl ->
-							let rec check st2 = st_eq st st2 || match st2.st_def with
-								| SEnum(st,_,_) | SArray(st,_) | STuple(st,_,_) | SField(st,_) -> check st
-								| SVar _ -> false
-							in
-							let rec loop cvl = match cvl with
-								| [] -> None
-								| (_,st2) :: cvl ->
-									if check st2 then mk_e() else loop cvl
-							in
-							loop cvl
-						| _ ->
-							mk_e()
-					end
-				) args in
-				if List.exists (fun e -> e <> None) vl then (Some vl) else None
-			| _ -> None
-		in
-		let e = to_typed_ast mctx dt in
-		save();
-		(List.map (fun (_,ef) -> ef.ef_index) group),vl,e
+	let e = match follow st.st_type with
+	| TEnum(_) ->
+		mk_index_call ()
+	| TAbstract(a,pl) when (match Codegen.Abstract.get_underlying_type a pl with TEnum(_) -> true | _ -> false) ->
+		mk_index_call ()
+	| TInst({cl_path = [],"Array"},_) as t ->
+		mk (TField (e_st,quick_field t "length")) ctx.t.tint p
+	| _ ->
+		e_st
 	in
-	let def = ref None in
-	let group,cases,dto = List.fold_left (fun (group,cases,dto) (con,dt) -> match con.c_def with
+	let null = ref None in
+	let cases = List.filter (fun (con,dt) ->
+		match con.c_def with
 		| CConst TNull ->
-			let e = to_typed_ast mctx dt in
-			def := Some e;
-			(group,cases,dto)
-		| _ -> match dto with
-			| None -> ([to_case con],cases,Some dt)
-			| Some dt2 -> match dt,dt2 with
-				| Out(out1,_),Out(out2,_) when is_compatible out1 out2 ->
-					((to_case con) :: group,cases,dto)
-				| _ ->
-					let g = type_case group dt2 con.c_pos in
-					([to_case con],g :: cases, Some dt)
-	) ([],[],None) cases in
-	let cases = List.rev (match group,dto with
-		| [],None ->
-			cases
-		| group,Some dt ->
-			let g = type_case group dt eval.epos in
-			g :: cases
-		| _ ->
-			assert false
-	) in
-	mk (TMatch(eval,(en,pl),cases,!def)) mctx.out_type eval.epos
-
-and to_value_switch mctx t st cases =
-	let eval = st_to_texpr mctx st in
-	let to_case con = match con.c_def with
-		| CConst c ->
-			mk_const mctx.ctx con.c_pos c
-		| CType mt ->
-			Typer.type_module_type mctx.ctx mt None con.c_pos
-		| CExpr e ->
-			e
+			null := Some (loop dt);
+			false
 		| _ ->
-			error ("Unexpected "  ^ (s_con con)) con.c_pos
-	in
-	let cases,def = group_cases mctx cases to_case in
-	mk (TSwitch(eval,cases,!def)) mctx.out_type eval.epos
-
-and to_array_switch mctx t st cases =
-	let to_case con = match con.c_def with
-		| CArray i ->
-			mk_const mctx.ctx con.c_pos (TInt (Int32.of_int i))
-		| _ ->
-			error ("Unexpected "  ^ (s_con con)) con.c_pos
-	in
-	let cases,def = group_cases mctx cases to_case in
-	let eval = st_to_texpr mctx st in
-	let eval = mk (TField(eval,quick_field eval.etype "length")) mctx.ctx.com.basic.tint st.st_pos in
-	mk (TSwitch(eval,cases,!def)) mctx.out_type eval.epos
-
-(* Main *)
+			true
+	) cases in
+	let e = mk (TMeta((Meta.Exhaustive,[],p), e)) e.etype e.epos in
+	let dt = DTSwitch(e, List.map (fun (c,dt) -> convert_con ctx c, loop dt) cases) in
+	match !null with
+	| None -> dt
+	| Some dt_null ->
+		let econd = mk (TBinop(OpEq,e_st,mk (TConst TNull) (mk_mono()) p)) ctx.t.tbool p in
+		DTGuard(econd,dt_null,Some dt)
 
-let rec collapse_case el = match el with
-	| e :: [] ->
-		e
-	| e :: el ->
-		let e2 = collapse_case el in
-		EBinop(OpOr,e,e2),punion (pos e) (pos e2)
-	| [] ->
-		assert false
+(* Decision tree compilation *)
 
 let match_expr ctx e cases def with_type p =
 	let need_val,with_type,tmono = match with_type with
@@ -1099,14 +963,18 @@ let match_expr ctx e cases def with_type p =
 		| _ -> cases
 	in
 	(* type subject(s) *)
+	let array_match = ref false in
 	let evals = match fst e with
 		| EArrayDecl el | EParenthesis(EArrayDecl el,_) ->
+			array_match := true;
 			List.map (fun e -> type_expr ctx e Value) el
 		| _ ->
 			let e = type_expr ctx e Value in
 			begin match follow e.etype with
 			| TEnum(en,_) when PMap.is_empty en.e_constrs || Meta.has Meta.FakeEnum en.e_meta ->
 				raise Exit
+			| TAbstract({a_path=[],("Int" | "Float" | "Bool")},_) | TInst({cl_path = [],"String"},_) when (Common.defined ctx.com Common.Define.NoPatternMatching) ->
+				raise Exit;
 			| _ ->
 				()
 			end;
@@ -1119,7 +987,7 @@ let match_expr ctx e cases def with_type p =
 		let rec loop e = match e.eexpr with
 			| TField (ef,s) when (match s with FEnum _ -> false | _ -> true) ->
 				mk_st (SField(loop ef,field_name s)) e.etype e.epos
-			| TParenthesis e ->
+			| TParenthesis e | TMeta(_,e) ->
 				loop e
 			| TLocal v ->
 				mk_st (SVar v) e.etype e.epos
@@ -1135,14 +1003,13 @@ let match_expr ctx e cases def with_type p =
 	(* create matcher context *)
 	let mctx = {
 		ctx = ctx;
-		stl = stl;
 		need_val = need_val;
-		v_lookup = Hashtbl.create 0;
 		outcomes = PMap.empty;
-		out_type = mk_mono();
 		toplevel_or = false;
 		used_paths = Hashtbl.create 0;
-		eval_stack = [];
+		dt_cache = Hashtbl.create 0;
+		dt_lut = DynArray.create ();
+		dt_count = 0;
 	} in
 	(* flatten cases *)
 	let cases = List.map (fun (el,eg,e) ->
@@ -1158,7 +1025,7 @@ let match_expr ctx e cases def with_type p =
 		let save = save_locals ctx in
 		(* type case patterns *)
 		let pl,restore,with_type = try (match tl with
-				| [t] ->
+				| [t] when not !array_match ->
 					(* context type parameters are turned into monomorphs until the pattern has been typed *)
 					let monos = List.map (fun _ -> mk_mono()) ctx.type_params in
 					let t = apply_params ctx.type_params monos t in
@@ -1246,36 +1113,9 @@ let match_expr ctx e cases def with_type p =
 			end;
 		end) mctx.outcomes;
 	in
-	begin try
+	let dt = try
 		(* compile decision tree *)
-		let dt = compile mctx stl pl in
-		(* check for unused patterns *)
-		check_unused();
-		(* determine type of switch statement *)
-		let t = if not need_val then
-			mk_mono()
-		else match with_type with
-			| WithType t | WithTypeResume t -> t
-			| _ -> try Typer.unify_min_raise ctx (List.rev_map (fun (_,out) -> out.o_expr) (List.rev pl)) with Error (Unify l,p) -> error (error_msg (Unify l)) p
-		in
-		(* unify with expected type if necessary *)
-		begin match tmono with
-			| None -> ()
-			| Some (WithType t2) -> unify ctx t2 t p
-			| Some (WithTypeResume t2) -> (try unify_raise ctx t2 t p with Error (Unify l,p) -> raise (Typer.WithTypeError (l,p)))
-			| _ -> assert false
-		end;
-		(* generate typed AST from decision tree *)
-		let e = to_typed_ast mctx dt in
-		let e = { e with epos = p; etype = t} in
-		if !var_inits = [] then
-			e
-		else begin
-			mk (TBlock [
-				mk (TVars (List.rev !var_inits)) t_dynamic e.epos;
-				e;
-			]) t e.epos
-		end
+		compile mctx stl pl
 	with Not_exhaustive(pat,st) ->
  		let rec s_st_r top pre st v = match st.st_def with
  			| SVar v1 ->
@@ -1290,18 +1130,76 @@ let match_expr ctx e cases def with_type p =
  				Printf.sprintf "[%s]" (st_args i r (s_st_r top false st v))
  			| SArray(st,i) ->
  				s_st_r false true st (Printf.sprintf "[%i]%s" i (if top then " = " ^ v else v))
+ 			| SField({st_def = SVar v1},f) when v1.v_name.[0] = '`' ->
+ 				f ^ (if top then " = " ^ v else v)
   			| SField(st,f) ->
  				s_st_r false true st (Printf.sprintf ".%s%s" f (if top then " = " ^ v else v))
- 			| SEnum(st,n,i) ->
-				let ef = match follow st.st_type with
- 					| TEnum(en,_) -> PMap.find n en.e_constrs
- 					| _ -> raise Not_found
- 				in
+ 			| SEnum(st,ef,i) ->
  				let len = match follow ef.ef_type with TFun(args,_) -> List.length args | _ -> 0 in
 				s_st_r false false st (Printf.sprintf "%s(%s)" ef.ef_name (st_args i (len - 1 - i) v))
 		in
 		error ("Unmatched patterns: " ^ (s_st_r true false st (s_pat pat))) st.st_pos
+	in
+	(* check for unused patterns *)
+	check_unused();
+	(* determine type of switch statement *)
+	let t = if not need_val then
+		mk_mono()
+	else match with_type with
+		| WithType t | WithTypeResume t -> t
+		| _ -> try Typer.unify_min_raise ctx (List.rev_map (fun (_,out) -> out.o_expr) (List.rev pl)) with Error (Unify l,p) -> error (error_msg (Unify l)) p
+	in
+	(* unify with expected type if necessary *)
+	begin match tmono with
+		| None -> ()
+		| Some (WithType t2) -> unify ctx t2 t p
+		| Some (WithTypeResume t2) -> (try unify_raise ctx t2 t p with Error (Unify l,p) -> raise (Typer.WithTypeError (l,p)))
+		| _ -> assert false
 	end;
+	(* count usage *)
+	let usage = Array.make (DynArray.length mctx.dt_lut) 0 in
+	let first = (match dt with Goto i -> i | _ -> Hashtbl.find mctx.dt_cache dt) in
+	(* we always want to keep the first part *)
+	Array.set usage first 2;
+	let rec loop dt = match dt with
+		| Goto i -> Array.set usage i ((Array.get usage i) + 1)
+		| Switch(st,cl) -> List.iter (fun (_,dt) -> loop dt) cl
+		| Bind(bl,dt) -> loop dt
+		| Expr e -> ()
+		| Guard(e,dt1,dt2) ->
+			loop dt1;
+			match dt2 with None -> () | Some dt -> (loop dt)
+	in
+	DynArray.iter loop mctx.dt_lut;
+	(* filter parts that will be inlined and keep a map to them*)
+	let map = Array.make (DynArray.length mctx.dt_lut) 0 in
+	let lut = DynArray.create() in
+	let rec loop i c =
+		if c < DynArray.length mctx.dt_lut then begin
+			let i' = if usage.(c) > 1 then begin
+				DynArray.add lut (DynArray.get mctx.dt_lut c);
+				i + 1
+			end else i in
+			Array.set map c i;
+		 	loop i' (c + 1)
+		end
+	in
+	loop 0 0;
+	(* reindex *)
+	let rec loop dt = match dt with
+		| Goto i -> if usage.(i) > 1 then DTGoto (map.(i)) else loop (DynArray.get mctx.dt_lut i)
+		| Switch(st,cl) -> convert_switch ctx st cl loop
+		| Bind(bl,dt) -> DTBind(List.map (fun (v,st) -> v,convert_st ctx st) bl,loop dt)
+		| Expr e -> DTExpr e
+		| Guard(e,dt1,dt2) -> DTGuard(e,loop dt1, match dt2 with None -> None | Some dt -> Some (loop dt))
+	in
+	let lut = DynArray.map loop lut in
+	{
+		dt_first = map.(first);
+		dt_dt_lookup = DynArray.to_array lut;
+		dt_type = t;
+		dt_var_init = List.rev !var_inits;
+	}
 ;;
 match_expr_ref := match_expr;
 get_pattern_locals_ref := get_pattern_locals

+ 20 - 11
optimizer.ml

@@ -32,9 +32,9 @@ let has_side_effect e =
 	let rec loop e =
 		match e.eexpr with
 		| TConst _ | TLocal _ | TField (_,FEnum _) | TTypeExpr _ | TFunction _ -> ()
-		| TMatch _ | TNew _ | TCall _ | TField _ | TArray _ | TBinop ((OpAssignOp _ | OpAssign),_,_) | TUnop ((Increment|Decrement),_,_) -> raise Exit
+		| TPatMatch _ | TNew _ | TCall _ | TField _ | TEnumParameter _ | TArray _ | TBinop ((OpAssignOp _ | OpAssign),_,_) | TUnop ((Increment|Decrement),_,_) -> raise Exit
 		| TReturn _ | TBreak | TContinue | TThrow _ | TCast (_,Some _) -> raise Exit
-		| TCast (_,None) | TBinop _ | TUnop _ | TParenthesis _ | TWhile _ | TFor _ | TIf _ | TTry _ | TSwitch _ | TArrayDecl _ | TVars _ | TBlock _ | TObjectDecl _ -> Type.iter loop e
+		| TCast (_,None) | TBinop _ | TUnop _ | TParenthesis _ | TMeta _ | TWhile _ | TFor _ | TIf _ | TTry _ | TSwitch _ | TArrayDecl _ | TVars _ | TBlock _ | TObjectDecl _ -> Type.iter loop e
 	in
 	try
 		loop e; false
@@ -241,14 +241,17 @@ let rec type_inline ctx cf f ethis params tret config p force =
 			let eloop = map false eloop in
 			in_loop := old;
 			{ e with eexpr = TWhile (cond,eloop,flag) }
-		| TMatch (v,en,cases,def) ->
+(* 		| TMatch (v,en,cases,def) ->
 			let term = term && def <> None in
 			let cases = List.map (fun (i,vl,e) ->
 				let vl = opt (List.map (fun v -> opt (fun v -> (local v).i_subst) v)) vl in
 				i, vl, map term e
 			) cases in
 			let def = opt (map term) def in
-			{ e with eexpr = TMatch (map false v,en,cases,def); etype = if term && ret_val then unify_min ctx ((List.map (fun (_,_,e) -> e) cases) @ (match def with None -> [] | Some e -> [e])) else e.etype }
+			{ e with eexpr = TMatch (map false v,en,cases,def); etype = if term && ret_val then unify_min ctx ((List.map (fun (_,_,e) -> e) cases) @ (match def with None -> [] | Some e -> [e])) else e.etype } *)
+		| TPatMatch _ ->
+			cancel_inlining := true; (* TODO *)
+			e
 		| TSwitch (e1,cases,def) when term ->
 			let term = term && def <> None in
 			let cases = List.map (fun (el,e) ->
@@ -332,7 +335,7 @@ let rec type_inline ctx cf f ethis params tret config p force =
 	in
 	let is_writable e =
 		match e.eexpr with
-		| TField _ | TLocal _ | TArray _ -> true
+		| TField _ | TEnumParameter _ | TLocal _ | TArray _ -> true
 		| _  -> false
 	in
 	let force = ref force in
@@ -600,9 +603,9 @@ let standard_precedence op =
 
 let rec need_parent e =
 	match e.eexpr with
-	| TConst _ | TLocal _ | TArray _ | TField _ | TParenthesis _ | TCall _ | TNew _ | TTypeExpr _ | TObjectDecl _ | TArrayDecl _ -> false
+	| TConst _ | TLocal _ | TArray _ | TField _ | TEnumParameter _ | TParenthesis _ | TMeta _ | TCall _ | TNew _ | TTypeExpr _ | TObjectDecl _ | TArrayDecl _ -> false
 	| TCast (e,None) -> need_parent e
-	| TCast _ | TThrow _ | TReturn _ | TTry _ | TMatch _ | TSwitch _ | TFor _ | TIf _ | TWhile _ | TBinop _ | TContinue | TBreak
+	| TCast _ | TThrow _ | TReturn _ | TTry _ | TPatMatch _ | TSwitch _ | TFor _ | TIf _ | TWhile _ | TBinop _ | TContinue | TBreak
 	| TBlock _ | TVars _ | TFunction _ | TUnop _ -> true
 
 let rec add_final_return e t =
@@ -644,7 +647,7 @@ let sanitize_expr com e =
 		match e.eexpr with
 		| TVars _	(* needs to be put into blocks *)
 		| TFor _	(* a temp var is needed for holding iterator *)
-		| TMatch _	(* a temp var is needed for holding enum *)
+		| TPatMatch _	(* a temp var is needed for holding enum *)
 		| TCall ({ eexpr = TLocal { v_name = "__js__" } },_) (* we never know *)
 			-> block e
 		| _ -> e
@@ -714,6 +717,8 @@ let sanitize_expr com e =
 		{ e with eexpr = TFunction f }
 	| TCall (e2,args) ->
 		if need_parent e2 then { e with eexpr = TCall(parent e2,args) } else e
+	| TEnumParameter (e2,i) ->
+		if need_parent e2 then { e with eexpr = TEnumParameter(parent e2,i) } else e
 	| TField (e2,f) ->
 		if need_parent e2 then { e with eexpr = TField(parent e2,f) } else e
 	| TArray (e1,e2) ->
@@ -727,11 +732,11 @@ let sanitize_expr com e =
 		let cases = List.map (fun (el,e) -> el, complex e) cases in
 		let def = (match def with None -> None | Some e -> Some (complex e)) in
 		{ e with eexpr = TSwitch (e1,cases,def) }
-	| TMatch (e1, en, cases, def) ->
+(* 	| TMatch (e1, en, cases, def) ->
 		let e1 = parent e1 in
 		let cases = List.map (fun (el,vars,e) -> el, vars, complex e) cases in
 		let def = (match def with None -> None | Some e -> Some (complex e)) in
-		{ e with eexpr = TMatch (e1,en,cases,def) }
+		{ e with eexpr = TMatch (e1,en,cases,def) } *)
 	| _ ->
 		e
 
@@ -954,7 +959,11 @@ let rec make_constant_expression ctx ?(concat_strings=false) e =
 			Some (mk (TConst (TString (s1 ^ s2))) ctx.com.basic.tstring (punion e1.epos e2.epos))
 		| Some e1, Some e2 -> Some (mk (TBinop(op, e1, e2)) e.etype e.epos)
 		| _ -> None)
-	| TParenthesis e -> Some e
+	| TCast (e1, None) ->
+		(match make_constant_expression ctx e1 with
+		| None -> None
+		| Some e1 -> Some {e with eexpr = TCast(e1,None)})
+	| TParenthesis e | TMeta(_,e) -> Some e
 	| TTypeExpr _ -> Some e
 	(* try to inline static function calls *)
 	| TCall ({ etype = TFun(_,ret); eexpr = TField (_,FStatic (c,cf)) },el) ->

+ 48 - 44
parser.ml

@@ -1114,7 +1114,9 @@ and expr = parser
 		(match s with parser
 		| [< al = psep Comma expr; '(PClose,p2); s >] -> expr_next (ENew (t,al),punion p1 p2) s
 		| [< >] -> serror())
-	| [< '(POpen,p1); e = expr; '(PClose,p2); s >] -> expr_next (EParenthesis e, punion p1 p2) s
+	| [< '(POpen,p1); e = expr; s >] -> (match s with parser
+		| [< '(PClose,p2); s >] -> expr_next (EParenthesis e, punion p1 p2) s
+		| [< '(DblDot,_); t = parse_complex_type; '(PClose,p2); s >] -> expr_next (EParenthesis (ECheckType(e,t),punion p1 p2), punion p1 p2) s)
 	| [< '(BkOpen,p1); l = parse_array_decl; '(BkClose,p2); s >] -> expr_next (EArrayDecl l, punion p1 p2) s
 	| [< inl, p1 = inline_function; name = popt dollar_ident; pl = parse_constraint_params; '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; s >] ->
 		let make e =
@@ -1335,12 +1337,56 @@ and secure_expr s =
 	| [< e = expr >] -> e
 	| [< >] -> serror()
 
+(* eval *)
 type small_type =
 	| TNull
 	| TBool of bool
 	| TFloat of float
 	| TString of string
 
+let is_true = function
+	| TBool false | TNull | TFloat 0. | TString "" -> false
+	| _ -> true
+
+let cmp v1 v2 =
+	match v1, v2 with
+	| TNull, TNull -> 0
+	| TFloat a, TFloat b -> compare a b
+	| TString a, TString b -> compare a b
+	| TBool a, TBool b -> compare a b
+	| TString a, TFloat b -> compare (float_of_string a) b
+	| TFloat a, TString b -> compare a (float_of_string b)
+	| _ -> raise Exit (* always false *)
+
+let rec eval ctx (e,p) =
+	match e with
+	| EConst (Ident i) ->
+		(try TString (Common.raw_defined_value ctx i) with Not_found -> TNull)
+	| EConst (String s) -> TString s
+	| EConst (Int i) -> TFloat (float_of_string i)
+	| EConst (Float f) -> TFloat (float_of_string f)
+	| EBinop (OpBoolAnd, e1, e2) -> TBool (is_true (eval ctx e1) && is_true (eval ctx e2))
+	| EBinop (OpBoolOr, e1, e2) -> TBool (is_true (eval ctx e1) || is_true(eval ctx e2))
+	| EUnop (Not, _, e) -> TBool (not (is_true (eval ctx e)))
+	| EParenthesis e -> eval ctx e
+	| EBinop (op, e1, e2) ->
+		let v1 = eval ctx e1 in
+		let v2 = eval ctx e2 in
+		let compare op =
+			TBool (try op (cmp v1 v2) 0 with _ -> false)
+		in
+		(match op with
+		| OpEq -> compare (=)
+		| OpNotEq -> compare (<>)
+		| OpGt -> compare (>)
+		| OpGte -> compare (>=)
+		| OpLt -> compare (<)
+		| OpLte -> compare (<=)
+		| _ -> error (Custom "Unsupported operation") p)
+	| _ ->
+		error (Custom "Invalid condition expression") p
+
+(* parse main *)
 let parse ctx code =
 	let old = Lexer.save() in
 	let old_cache = !cache in
@@ -1393,51 +1439,9 @@ let parse ctx code =
 			tk
 
 	and enter_macro p =
-		let is_true = function
-			| TBool false | TNull | TFloat 0. | TString "" -> false
-			| _ -> true
-		in
-		let cmp v1 v2 =
-			match v1, v2 with
-			| TNull, TNull -> 0
-			| TFloat a, TFloat b -> compare a b
-			| TString a, TString b -> compare a b
-			| TBool a, TBool b -> compare a b
-			| TString a, TFloat b -> compare (float_of_string a) b
-			| TFloat a, TString b -> compare a (float_of_string b)
-			| _ -> raise Exit (* always false *)
-		in
-		let rec loop (e,p) =
-			match e with
-			| EConst (Ident i) ->
-				(try TString (Common.raw_defined_value ctx i) with Not_found -> TNull)
-			| EConst (String s) -> TString s
-			| EConst (Int i) -> TFloat (float_of_string i)
-			| EConst (Float f) -> TFloat (float_of_string f)
-			| EBinop (OpBoolAnd, e1, e2) -> TBool (is_true (loop e1) && is_true (loop e2))
-			| EBinop (OpBoolOr, e1, e2) -> TBool (is_true (loop e1) || is_true(loop e2))
-			| EUnop (Not, _, e) -> TBool (not (is_true (loop e)))
-			| EParenthesis e -> loop e
-			| EBinop (op, e1, e2) ->
-				let v1 = loop e1 in
-				let v2 = loop e2 in
-				let compare op =
-					TBool (try op (cmp v1 v2) 0 with _ -> false)
-				in
-				(match op with
-				| OpEq -> compare (=)
-				| OpNotEq -> compare (<>)
-				| OpGt -> compare (>)
-				| OpGte -> compare (>=)
-				| OpLt -> compare (<)
-				| OpLte -> compare (<=)
-				| _ -> error (Custom "Unsupported operation") p)
-			| _ ->
-				error Unclosed_macro p
-		in
 		let tk, e = parse_macro_cond false sraw in
 		let tk = (match tk with None -> Lexer.token code | Some tk -> tk) in
-		if is_true (loop e) || (match fst e with EConst (Ident "macro") when Common.unique_full_path p.pfile = (!resume_display).pfile -> true | _ -> false) then begin
+		if is_true (eval ctx e) || (match fst e with EConst (Ident "macro") when Common.unique_full_path p.pfile = (!resume_display).pfile -> true | _ -> false) then begin
 			mstack := p :: !mstack;
 			tk
 		end else

+ 96 - 80
std/Array.hx

@@ -21,13 +21,13 @@
  */
 /**
 	An Array is a storage for values. You can access it using indexes or
-	with its API. On the server side, it's often better to use a [List] which
+	with its API. On the server side, it's often better to use a `List` which
 	is less memory and CPU consuming, unless you really need indexed access.
 **/
 extern class Array<T> {
 
 	/**
-		The length of [this] Array.
+		The length of `this` Array.
 	**/
 	var length(default,null) : Int;
 
@@ -37,140 +37,140 @@ extern class Array<T> {
 	function new() : Void;
 
 	/**
-		Returns a new Array by appending the elements of [a] to the elements of
-		[this] Array.
+		Returns a new Array by appending the elements of `a` to the elements of
+		`this` Array.
 		
-		This operation does not modify [this] Array.
+		This operation does not modify `this` Array.
 		
-		If [a] is the empty Array [], a copy of [this] Array is returned.
+		If `a` is the empty Array `[]`, a copy of `this` Array is returned.
 		
-		The length of the returned Array is equal to the sum of [this].length
-		and [a].length.
+		The length of the returned Array is equal to the sum of `this.length` 
+		and `a.length`.
 		
-		If [a] is null, the result is unspecified.
+		If `a` is `null`, the result is unspecified.
 	**/
 	function concat( a : Array<T> ) : Array<T>;
 
 	/**
-		Returns a string representation of [this] Array, with [sep] separating
+		Returns a string representation of `this` Array, with `sep` separating
 		each element.
 		
-		The result of this operation is equal to Std.string(this[0]) + sep +
-		Std.string(this[1]) + sep + ... + sep + Std.string(this[this.length-1]).
+		The result of this operation is equal to `Std.string(this[0]) + sep +
+		Std.string(this[1]) + sep + ... + sep + Std.string(this[this.length-1])`
 		
-		If [this] is the empty Array [], the result is the empty String "". If
-		[this] has exactly one element, the result is equal to a call to
-		Std.string(this[0]).
+		If `this` is the empty Array `[]`, the result is the empty String `""`. 
+		If `this` has exactly one element, the result is equal to a call to
+		`Std.string(this[0])`.
 		
-		If [sep] is null, the result is unspecified.
+		If `sep` is null, the result is unspecified.
 	**/
 	function join( sep : String ) : String;
 
 	/**
-		Removes the last element of [this] Array and returns it.
+		Removes the last element of `this` Array and returns it.
 		
-		This operation modifies [this] Array in place.
+		This operation modifies `this` Array in place.
 		
-		If [this] has at least one element, [this].length will decrease by 1.
+		If `this` has at least one element, `this.length` will decrease by 1.
 		
-		If [this] is the empty Array [], null is returned and the length remains
-		0.
+		If `this` is the empty Array `[]`, null is returned and the length 
+		remains 0.
 	**/
 	function pop() : Null<T>;
 
 	/**
-		Adds the element [x] at the end of [this] Array and returns the offset
+		Adds the element `x` at the end of `this` Array and returns the offset
 		it was added at.
 		
-		This operation modifies [this] Array in place.
+		This operation modifies `this` Array in place.
 		
-		[this].length increases by 1.
+		`this.length` increases by 1.
 	**/
 	function push(x : T) : Int;
 
 	/**
-		Reverse the order of elements of [this] Array.
+		Reverse the order of elements of `this` Array.
 		
-		This operation modifies [this] Array in place.
+		This operation modifies `this` Array in place.
 		
-		If [this].length < 2, [this] remains unchanged.
+		If `this.length < 2`, `this` remains unchanged.
 	**/
 	function reverse() : Void;
 
 	/**
-		Removes the first element of [this] Array and returns it.
+		Removes the first element of `this` Array and returns it.
 		
-		This operation modifies [this] Array in place.
+		This operation modifies `this` Array in place.
 		
-		If [this] has at least one element, [this].length and the index of each
+		If `this` has at least one element, `this`.length and the index of each
 		remaining element is decreased by 1.
 		
-		If [this] is the empty Array [], null is returned and the length remains
-		0.
+		If `this` is the empty Array `[]`, `null` is returned and the length 
+		remains 0.
 	**/
 	function shift() : Null<T>;
 
 	/**
-		Creates a shallow copy of the range of [this] Array, starting at and
-		including [pos], up to but not including [end].
+		Creates a shallow copy of the range of `this` Array, starting at and
+		including `pos`, up to but not including `end`.
 		
-		This operation does not modify [this] Array.
+		This operation does not modify `this` Array.
 		
 		The elements are not copied and retain their identity.
 		
-		If [end] is omitted or exceeds [this].length, it defaults to the end of
-		[this] Array.
+		If `end` is omitted or exceeds `this.length`, it defaults to the end of
+		`this` Array.
 		
-		If [pos] or [end] are negative, their offsets are calculated from the
-		end	of [this] Array by [this].length + [pos] and [this].length + [end]
+		If `pos` or `end` are negative, their offsets are calculated from the
+		end	of `this` Array by `this.length + pos` and `this.length + end`
 		respectively. If this yields a negative value, 0 is used instead.
 		
-		If [pos] exceeds [this].length or if [end} exceeds or equals [pos],
-		the result is [].
+		If `pos` exceeds `this.length` or if `end` exceeds or equals `pos`,
+		the result is `[]`.
 	**/
 	function slice( pos : Int, ?end : Int ) : Array<T>;
 
 	/**
-		Sorts [this] Array according to the comparison function [f], where
-		[f(x,y)] returns 0 if x == y, a positive Int if x > y and a
+		Sorts `this` Array according to the comparison function `f`, where
+		`f(x,y)` returns 0 if x == y, a positive Int if x > y and a
 		negative Int if x < y.
 		
-		This operation modifies [this] Array in place.
+		This operation modifies `this` Array in place.
 		
 		The sort operation is not guaranteed to be stable, which means that the
 		order of equal elements may not be retained. For a stable Array sorting
-		algorithm, haxe.ds.sort.MergeSort.sort() can be used instead.
+		algorithm, `haxe.ds.sort.MergeSort.sort()` can be used instead.
 		
-		If [f] is null, the result is unspecified.
+		If `f` is null, the result is unspecified.
 	**/
 	function sort( f : T -> T -> Int ) : Void;
 
 	/**
-		Removes [len] elements from [this] Array, starting at and including
-		[pos], an returns them.
+		Removes `len` elements from `this` Array, starting at and including
+		`pos`, an returns them.
 		
-		This operation modifies [this] Array in place.
+		This operation modifies `this` Array in place.
 		
-		If [len] is < 0 or [pos] exceeds [this].length, the result is the empty
+		If `len` is < 0 or `pos` exceeds `this`.length, the result is the empty
 		Array [].
 		
-		If [pos] is negative, its value is calculated from the end	of [this]
-		Array by [this].length + [pos]. If this yields a negative value, 0 is
+		If `pos` is negative, its value is calculated from the end	of `this`
+		Array by `this.length + pos`. If this yields a negative value, 0 is
 		used instead.
 		
-		If the sum of the resulting values for [len] and [pos] exceed
-		[this].length, this operation will affect the elements from [pos] to the
-		end of [this] Array.
+		If the sum of the resulting values for `len` and `pos` exceed
+		`this.length`, this operation will affect the elements from `pos` to the
+		end of `this` Array.
 		
-		The length of the returned Array is equal to the new length of [this]
-		Array subtracted from the original length of [this] Array. In other
-		words, each element of the original [this] Array either remains in
-		[this] Array or becomes an element of the returned Array.
+		The length of the returned Array is equal to the new length of `this`
+		Array subtracted from the original length of `this` Array. In other
+		words, each element of the original `this` Array either remains in
+		`this` Array or becomes an element of the returned Array.
 	**/
 	function splice( pos : Int, len : Int ) : Array<T>;
 
 	/**
-		Returns a string representation of [this] Array.
+		Returns a string representation of `this` Array.
 		
 		The result will include the individual elements' String representations
 		separated by comma. The enclosing [ ] may be missing on some platforms,
@@ -180,53 +180,53 @@ extern class Array<T> {
 	function toString() : String;
 
 	/**
-		Adds the element [x] at the start of [this] Array.
+		Adds the element `x` at the start of `this` Array.
 		
-		This operation modifies [this] Array in place.
+		This operation modifies `this` Array in place.
 		
-		[this].length and the index of each Array element increases by 1.
+		`this.length` and the index of each Array element increases by 1.
 	**/
 	function unshift( x : T ) : Void;
 
 	/**
-		Inserts the element [x] at the position [pos].
+		Inserts the element `x` at the position `pos`.
 		
-		This operation modifies [this] Array in place.
+		This operation modifies `this` Array in place.
 		
 		The offset is calculated like so:
 			
-		- If [pos] exceeds [this].length, the offset is [this].length.
-		- If [pos] is negative, the offset is calculated from the end of [this]
-		Array, i.e. [this].length + [pos]. If this yields a negative value,
-		the offset is 0.
-		- Otherwise, the offset is [pos].
-		
-		If the resulting offset does not exceed [this].length, all elements from
-		and including that offset to the end of [this] Array are moved one index
+		- If `pos` exceeds `this.length`, the offset is `this.length`.
+		- If `pos` is negative, the offset is calculated from the end of `this` 
+		  Array, i.e. `this.length + pos`. If this yields a negative value, the 
+		  offset is 0.
+		- Otherwise, the offset is `pos`.
+		
+		If the resulting offset does not exceed `this.length`, all elements from
+		and including that offset to the end of `this` Array are moved one index
 		ahead.
 	**/
 	function insert( pos : Int, x : T ) : Void;
 
 	/**
-		Removes the first occurence of [x] in [this] Array.
+		Removes the first occurence of `x` in `this` Array.
 		
-		This operation modifies [this] Array in place.
+		This operation modifies `this` Array in place.
 		
-		If [x] is found by checking standard equality, it is removed from [this]
+		If `x` is found by checking standard equality, it is removed from `this`
 		Array and all following elements are reindexed acoordingly. The function
 		then returns true.
 		
-		If [x] is not found, [this] Array is not changed and the function
+		If `x` is not found, `this` Array is not changed and the function
 		returns false.
 	**/
 	function remove( x : T ) : Bool;
 
 	/**
-		Returns a shallow copy of [this] Array.
+		Returns a shallow copy of `this` Array.
 		
 		The elements are not copied and retain their identity, so
-		a[i] == a.copy()[i] is true for any valid i. However, a == a.copy() is
-		always false.
+		`a[i] == a.copy()[i]` is true for any valid `i`. However, 
+		`a == a.copy()` is always false.
 	**/
 	function copy() : Array<T>;
 
@@ -235,6 +235,22 @@ extern class Array<T> {
 	**/
 	function iterator() : Iterator<T>;
 
+	/**
+		Creates a new Array by applying function `f` to all elements of `this`.
+		
+		The order of elements is preserved.
+		
+		If `f` is null, the result is unspecified.
+	**/	
 	function map<S>( f : T -> S ) : Array<S>;
+	
+	/**
+		Returns an Array containing those elements of `this` for which `f`
+		returned true.
+
+		The individual elements are not duplicated and retain their identity.
+		
+		If `f` is null, the result is unspecified.
+	**/	
 	function filter( f : T -> Bool ) : Array<T>;
 }

+ 1 - 1
std/Class.hx

@@ -22,7 +22,7 @@
 /**
 	An abstract type that represents a Class.
 	
-	See [Type] for the haXe Reflection API.
+	See `Type` for the Haxe Reflection API.
 **/
 @:coreType @:runtimeValue abstract Class<T> {
 }

+ 28 - 25
std/Date.hx

@@ -23,12 +23,13 @@
  /**
 	The Date class provides a basic structure for date and time related
 	information. Date instances can be created by
-		- new Date() for a specific date,
-		- Date.now() to obtain information about the current time,
-		- Date.fromTime() with a given timestamp or
-		- Date.fromString() by parsing from a String.
 	
-	There is some extra functions available in the [DateTools] class.
+	- `new Date()` for a specific date,
+	- `Date.now()` to obtain information about the current time,
+	- `Date.fromTime()` with a given timestamp or
+	- `Date.fromString()` by parsing from a String.
+	
+	There is some extra functions available in the `DateTools` class.
 	
 	In the context of haxe dates, a timestamp is defined as the number of
 	milliseconds elapsed since 1st January 1970.
@@ -40,11 +41,12 @@ extern class Date
 		
 		The behaviour of a Date instance is only consistent across platforms if
 		the the arguments describe a valid date.
-			- month: 0 to 11
-			- day: 1 to 31
-			- hour: 0 to 23
-			- min: 0 to 59
-			- sec: 0 to 59
+		
+		- month: 0 to 11
+		- day: 1 to 31
+		- hour: 0 to 23
+		- min: 0 to 59
+		- sec: 0 to 59
 	**/
 	function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void;
 
@@ -55,43 +57,43 @@ extern class Date
 	function getTime() : Float;
 
 	/**
-		Returns the hours of [this] Date (0-23 range).
+		Returns the hours of `this` Date (0-23 range).
 	**/
 	function getHours() : Int;
 
 	/**
-		Returns the minutes of [this] Date (0-59 range).
+		Returns the minutes of `this` Date (0-59 range).
 	**/
 	function getMinutes() : Int;
 
 	/**
-		Returns the seconds of the [this] Date (0-59 range).
+		Returns the seconds of the `this` Date (0-59 range).
 	**/
 	function getSeconds() : Int;
 
 	/**
-		Returns the full year of [this] Date (4-digits).
+		Returns the full year of `this` Date (4-digits).
 	**/
 	function getFullYear() : Int;
 
 	/**
-		Returns the month of [this] Date (0-11 range).
+		Returns the month of `this` Date (0-11 range).
 	**/
 	function getMonth() : Int;
 
 	/**
-		Returns the day of [this] Date (1-31 range).
+		Returns the day of `this` Date (1-31 range).
 	**/
 	function getDate() : Int;
 
 	/**
-		Returns the day of the week of [this] Date (0-6 range).
+		Returns the day of the week of `this` Date (0-6 range).
 	**/
 	function getDay() : Int;
 
 	/**
-		Returns a string representation of [this] Date, by using the
-		standard format [YYYY-MM-DD HH:MM:SS]. See [DateTools.format] for
+		Returns a string representation of `this` Date, by using the
+		standard format [YYYY-MM-DD HH:MM:SS]. See `DateTools.format` for
 		other formating rules.
 	**/
 	function toString():String;
@@ -102,16 +104,18 @@ extern class Date
 	static function now() : Date;
 
 	/**
-		Returns a Date from timestamp [t].
+		Returns a Date from timestamp `t`.
 	**/
 	static function fromTime( t : Float ) : Date;
 
 	/**
-		Returns a Date from a formated string [s], with the following accepted
+		Returns a Date from a formated string `s`, with the following accepted
 		formats:
-			- [YYYY-MM-DD hh:mm:ss]
-			- [YYYY-MM-DD]
-			- [hh:mm:ss]
+		
+		- `"YYYY-MM-DD hh:mm:ss"`
+		- `"YYYY-MM-DD"`
+		- `"hh:mm:ss"`
+		
 		The first two formats are expressed in local time, the third in UTC
 		Epoch.
 	**/
@@ -184,4 +188,3 @@ extern class Date
 	}
 #end
 }
-

+ 7 - 7
std/DateTools.hx

@@ -21,7 +21,7 @@
  */
 
 /**
-	The DateTools class contains some extra functionalities for handling [Date]
+	The DateTools class contains some extra functionalities for handling `Date`
 	instances and timestamps.
 	
 	In the context of haxe dates, a timestamp is defined as the number of
@@ -105,10 +105,10 @@ class DateTools {
 	#end
 
 	/**
-		Format the date [d] according to the format [f]. The format is
-		compatible with the [strftime] standard format, except that there is no
+		Format the date `d` according to the format `f`. The format is
+		compatible with the `strftime` standard format, except that there is no
 		support in Flash and JS for day and months names (due to lack of proper
-		internationalization API). On haXe/Neko/Windows, some formats are not
+		internationalization API). On Haxe/Neko/Windows, some formats are not
 		supported.
 	**/
 	public static function format( d : Date, f : String ) : String {
@@ -122,10 +122,10 @@ class DateTools {
 	}
 
 	/**
-		Returns the result of adding timestamp [t] to Date [d].
+		Returns the result of adding timestamp `t` to Date `d`.
 		
 		This is a convenience function for calling
-		Date.fromTime(d.getTime() + t).
+		`Date.fromTime(d.getTime() + t)`.
 	**/
 	public static inline function delta( d : Date, t : Float ) : Date {
 		return Date.fromTime( d.getTime() + t );
@@ -134,7 +134,7 @@ class DateTools {
 	static var DAYS_OF_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
 
 	/**
-		Returns the number of days in the month of Date [d].
+		Returns the number of days in the month of Date `d`.
 		
 		This method handles leap years.
 	**/

+ 34 - 34
std/EReg.hx

@@ -39,37 +39,37 @@
 class EReg {
 
 	/**
-		Creates a new regular expression with pattern [r] and modifiers [opt].
+		Creates a new regular expression with pattern `r` and modifiers `opt`.
 		
-		This is equivalent to the shorthand syntax ~/r/opt
+		This is equivalent to the shorthand syntax `~/r/opt`
 		
-		If [r] or [opt] are null, the result is unspecified.
+		If `r` or `opt` are null, the result is unspecified.
 	**/
 	public function new( r : String, opt : String ) {
 		throw "Regular expressions are not implemented for this platform";
 	}
 
 	/**
-		Tells if [this] regular expression matches String [s].
+		Tells if `this` regular expression matches String `s`.
 		
 		This method modifies the internal state.
 		
-		If [s] is null, the result is unspecified.
+		If `s` is `null`, the result is unspecified.
 	**/
 	public function match( s : String ) : Bool {
 		return false;
 	}
 
 	/**
-		Returns the matched sub-group [n] of [this] EReg.
+		Returns the matched sub-group `n` of `this` EReg.
 		
-		This method should only be called after [this].match() or
-		[this].matchSub(), and then operates on the String of that operation.
+		This method should only be called after `this.match` or
+		`this.matchSub`, and then operates on the String of that operation.
 		
-		The index [n] corresponds to the n-th set of parentheses in the pattern
-		of [this] EReg. If no such sub-group exists, an exception is thrown.
+		The index `n` corresponds to the n-th set of parentheses in the pattern
+		of `this` EReg. If no such sub-group exists, an exception is thrown.
 		
-		If [n] equals 0, the whole matched substring is returned.
+		If `n` equals 0, the whole matched substring is returned.
 	**/
 	public function matched( n : Int ) : String {
 		return null;
@@ -78,7 +78,7 @@ class EReg {
 	/**
 		Returns the part to the left of the last matched substring.
 		
-		If the most recent call to [this].match() or [this].matchSub() did not
+		If the most recent call to `this.match` or `this.matchSub` did not
 		match anything, the result is unspecified.
 		
 		If the global g modifier was in place for the matching, only the
@@ -93,7 +93,7 @@ class EReg {
 	/**
 		Returns the part to the right of the last matched substring.
 		
-		If the most recent call to [this].match() or [this].matchSub() did not
+		If the most recent call to `this.match` or `this.matchSub` did not
 		match anything, the result is unspecified.
 		
 		If the global g modifier was in place for the matching, only the
@@ -107,10 +107,10 @@ class EReg {
 
 	/**
 		Returns the position and length of the last matched substring, within
-		the String which was last used as argument to [this].match() or
-		[this].matchSub().
+		the String which was last used as argument to `this.match` or
+		`this.matchSub`.
 		
-		If the most recent call to [this].match() or [this].matchSub() did not
+		If the most recent call to `this.match` or `this.matchSub` did not
 		match anything, the result is unspecified.
 		
 		If the global g modifier was in place for the matching, the position and
@@ -121,64 +121,64 @@ class EReg {
 	}
 
 	/**
-		Tells if [this] regular expression matches a substring of String [s].
+		Tells if `this` regular expression matches a substring of String `s`.
 		
-		This function expects [pos] and [len] to describe a valid substring of
-		[s], or else the result is unspecified. To get more robust behavior,
-		[this].matchSub(s.substr(pos,len)) can be used instead.
+		This function expects `pos` and `len` to describe a valid substring of
+		`s`, or else the result is unspecified. To get more robust behavior,
+		`this.matchSub(s.substr(pos,len))` can be used instead.
 		
 		This method modifies the internal state.
 		
-		If [s] is null, the result is unspecified.
+		If `s` is null, the result is unspecified.
 	**/
 	public function matchSub( s : String, pos : Int, len : Int = 0):Bool {
 		return false;
 	}
 
 	/**
-		Splits String [s] at all substrings [this] EReg matches.
+		Splits String `s` at all substrings `this` EReg matches.
 		
-		If a match is found at the start of [s], the result contains a leading
+		If a match is found at the start of `s`, the result contains a leading
 		empty String "" entry.
 		
-		If a match is found at the end of [s], the result contains a trailing
+		If a match is found at the end of `s`, the result contains a trailing
 		empty String "" entry.
 		
 		If two matching substrings appear next to each other, the result
 		contains the empty String "" between them.
 		
-		By default, this method splits [s] into two parts at the first matched
-		substring. If the global g modifier is in place, [s] is split at each
+		By default, this method splits `s` into two parts at the first matched
+		substring. If the global g modifier is in place, `s` is split at each
 		matched substring.
 		
-		If [s] is null, the result is unspecified.
+		If `s` is null, the result is unspecified.
 	**/
 	public function split( s : String ) : Array<String> {
 		return null;
 	}
 
 	/**
-		Replaces the first substring of [s] which [this] EReg matches with [by].
+		Replaces the first substring of `s` which `this` EReg matches with `by`.
 		
-		If [this] EReg does not match any substring, the result is [s].
+		If `this` EReg does not match any substring, the result is `s`.
 		
 		By default, this method replaces only the first matched substring. If
 		the global g modifier is in place, all matched substrings are replaced.
 		
-		If [by] contains [$1] to [$9], the digit corresponds to number of a
+		If `by` contains `$1` to `$9`, the digit corresponds to number of a
 		matched sub-group and its value is used instead. If no such sub-group
-		exists, the replacement is unspecified. The string [$$] becomes [$].
+		exists, the replacement is unspecified. The string `$$` becomes `$`.
 		
-		If [s] or [by] are null, the result is unspecified.
+		If `s` or `by` are null, the result is unspecified.
 	**/
 	public function replace( s : String, by : String ) : String {
 		return null;
 	}
 
 	/**
-		For each occurence of the pattern in the string [s], the function [f] is called and
+		For each occurence of the pattern in the string `s`, the function `f` is called and
 		can return the string that needs to be replaced. All occurences are matched anyway,
-		and setting the [g] flag might cause some incorrect behavior on some platforms.
+		and setting the `g` flag might cause some incorrect behavior on some platforms.
 	**/
 	public function map( s : String, f : EReg -> String ) : String {
 		var buf = new StringBuf();

+ 2 - 2
std/Enum.hx

@@ -23,9 +23,9 @@
 /**
 	An abstract type that represents an Enum type.
 	
-	The corresponding enum instance type is EnumValue.
+	The corresponding enum instance type is `EnumValue`.
 	
-	See [Type] for the haXe Reflection API.
+	See `Type` for the Haxe Reflection API.
 **/
 @:coreType @:runtimeValue abstract Enum<T> {
 }

+ 1 - 1
std/EnumValue.hx

@@ -22,7 +22,7 @@
 
 /**
 	An abstract type that represents any enum value.
-	See [Type] for the haXe Reflection API.
+	See `Type` for the Haxe Reflection API.
 **/
 @:coreType abstract EnumValue {
 }

+ 3 - 3
std/IntIterator.hx

@@ -24,7 +24,7 @@
 	IntIterator is used for implementing interval iterations.
 	
 	It is usually not used explicitly, but through it's special syntax:
-		min...max
+	`min...max`
 		
 	While it is possible to assign an instance of IntIterator to a variable or
 	field, it is worth noting that IntIterator does not reset after being used
@@ -37,9 +37,9 @@ class IntIterator {
 	var max : Int;
 
 	/**
-		Iterates from [min] (inclusive) to [max] (exclusive).
+		Iterates from `min` (inclusive) to `max` (exclusive).
 		
-		If [max <= min], the iterator will not act as a countdown.
+		If `max <= min`, the iterator will not act as a countdown.
 	**/
 	public function new( min : Int, max : Int ) {
 		this.min = min;

+ 39 - 39
std/Lambda.hx

@@ -21,7 +21,7 @@
  */
 
 /**
-	The [Lambda] class is a collection of methods to support functional
+	The `Lambda` class is a collection of methods to support functional
 	programming. It is ideally used with 'using Lambda' and then acts as an
 	extension to Iterable types.
 	
@@ -35,9 +35,9 @@
 class Lambda {
 
 	/**
-		Creates an Array from Iterable [it].
+		Creates an Array from Iterable `it`.
 		
-		If [it] is an Array, this function returns a copy of it.
+		If `it` is an Array, this function returns a copy of it.
 	**/
 	public static function array<A>( it : Iterable<A> ) : Array<A> {
 		var a = new Array<A>();
@@ -47,9 +47,9 @@ class Lambda {
 	}
 
 	/**
-		Creates a List form Iterable [it].
+		Creates a List form Iterable `it`.
 		
-		If [it] is a List, this function returns a copy of it.
+		If `it` is a List, this function returns a copy of it.
 	**/
 	public static function list<A>( it : Iterable<A> ) : List<A> {
 		var l = new List<A>();
@@ -59,11 +59,11 @@ class Lambda {
 	}
 
 	/**
-		Creates a new List by applying function [f] to all elements of [it].
+		Creates a new List by applying function `f` to all elements of `it`.
 		
 		The order of elements is preserved.
 		
-		If [f] is null, the result is unspecified.
+		If `f` is null, the result is unspecified.
 	**/
 	public static function map<A,B>( it : Iterable<A>, f : A -> B ) : List<B> {
 		var l = new List<B>();
@@ -73,11 +73,11 @@ class Lambda {
 	}
 
 	/**
-		Similar to map, but also passes the index of each element to [f].
+		Similar to map, but also passes the index of each element to `f`.
 		
 		The order of elements is preserved.
 		
-		If [f] is null, the result is unspecified.
+		If `f` is null, the result is unspecified.
 	**/
 	public static function mapi<A,B>( it : Iterable<A>, f : Int -> A -> B ) : List<B> {
 		var l = new List<B>();
@@ -88,10 +88,10 @@ class Lambda {
 	}
 
 	/**
-		Tells if [it] contains [elt].
+		Tells if `it` contains `elt`.
 		
 		This function returns true as soon as an element is found which is equal
-		to [elt] according to the [==] operator.
+		to `elt` according to the `==` operator.
 		
 		If no such element is found, the result is false.
 	**/
@@ -103,14 +103,14 @@ class Lambda {
 	}
 
 	/**
-		Tells if [it] contains an element for which [f] is true.
+		Tells if `it` contains an element for which `f` is true.
 		
 		This function returns true as soon as an element is found for which a
-		call to [f] returns true.
+		call to `f` returns true.
 		
 		If no such element is found, the result is false.
 		
-		If [f] is null, the result is unspecified.
+		If `f` is null, the result is unspecified.
 	**/
 	public static function exists<A>( it : Iterable<A>, f : A -> Bool ) {
 		for( x in it )
@@ -120,16 +120,16 @@ class Lambda {
 	}
 
 	/**
-		Tells if [f] is true for all elements of [it].
+		Tells if `f` is true for all elements of `it`.
 		
 		This function returns false as soon as an element is found for which a
-		call to [f] returns false.
+		call to `f` returns false.
 		
 		If no such element is found, the result is true.
 		
-		In particular, this function always returns true if [it] is empty.
+		In particular, this function always returns true if `it` is empty.
 		
-		If [f] is null, the result is unspecified.
+		If `f` is null, the result is unspecified.
 	**/
 	public static function foreach<A>( it : Iterable<A>, f : A -> Bool ) {
 		for( x in it )
@@ -139,9 +139,9 @@ class Lambda {
 	}
 
 	/**
-		Calls [f] on all elements of [it], in order.
+		Calls `f` on all elements of `it`, in order.
 		
-		If [f] is null, the result is unspecified.
+		If `f` is null, the result is unspecified.
 	**/
 	public static function iter<A>( it : Iterable<A>, f : A -> Void ) {
 		for( x in it )
@@ -149,12 +149,12 @@ class Lambda {
 	}
 
 	/**
-		Returns a List containing those elements of [it] for which [f] returned
+		Returns a List containing those elements of `it` for which `f` returned
 		true.
 		
-		If [it] is empty, the result is the empty List even if [f] is null.
+		If `it` is empty, the result is the empty List even if `f` is null.
 		
-		Otherwise if [f] is null, the result is unspecified.
+		Otherwise if `f` is null, the result is unspecified.
 	**/
 	public static function filter<A>( it : Iterable<A>, f : A -> Bool ) {
 		var l = new List<A>();
@@ -165,16 +165,16 @@ class Lambda {
 	}
 
 	/**
-		Functional fold on Iterable [it], using function [f] with start argument
-		[first].
+		Functional fold on Iterable `it`, using function `f` with start argument
+		`first`.
 		
-		If [it] has no elements, the result is [first].
+		If `it` has no elements, the result is `first`.
 		
-		Otherwise the first element of [it] is passed to [f] alongside [first].
-		The result of that call is then passed to [f] with the next element of
-		[it], and so on until [it] has no more elements.
+		Otherwise the first element of `it` is passed to `f` alongside `first`.
+		The result of that call is then passed to `f` with the next element of
+		`it`, and so on until `it` has no more elements.
 		
-		If [it] or [f] are null, the result is unspecified.
+		If `it` or `f` are null, the result is unspecified.
 	**/
 	public static function fold<A,B>( it : Iterable<A>, f : A -> B -> B, first : B ) : B {
 		for( x in it )
@@ -183,8 +183,8 @@ class Lambda {
 	}
 
 	/**
-		Returns the number of elements in [it] for which [pred] is true, or the
-		total number of elements in [it] if [pred] is null.
+		Returns the number of elements in `it` for which `pred` is true, or the
+		total number of elements in `it` if `pred` is null.
 		
 		This function traverses all elements.
 	**/
@@ -201,18 +201,18 @@ class Lambda {
 	}
 
 	/**
-		Tells if Iterable [it] does not contain any element.
+		Tells if Iterable `it` does not contain any element.
 	**/
 	public static function empty<T>( it : Iterable<T> ) : Bool {
 		return !it.iterator().hasNext();
 	}
 
 	/**
-		Returns the index of the first element [v] within Iterable [it].
+		Returns the index of the first element `v` within Iterable `it`.
 		
-		This function uses operator [==] to check for equality.
+		This function uses operator `==` to check for equality.
 		
-		If [v] does not exist in [it], the result is -1.
+		If `v` does not exist in `it`, the result is -1.
 	**/
 	public static function indexOf<T>( it : Iterable<T>, v : T ) : Int {
 		var i = 0;
@@ -225,10 +225,10 @@ class Lambda {
 	}
 
 	/**
-		Returns a new List containing all elements of Iterable [a] followed by
-		all elements of Iterable [b].
+		Returns a new List containing all elements of Iterable `a` followed by
+		all elements of Iterable `b`.
 		
-		If [a] or [b] are null, the result is unspecified.
+		If `a` or `b` are null, the result is unspecified.
 	**/
 	public static function concat<T>( a : Iterable<T>, b : Iterable<T> ) : List<T> {
 		var l = new List();

+ 21 - 21
std/List.hx

@@ -30,7 +30,7 @@ class List<T> {
 	private var q : Array<Dynamic>;
 
 	/**
-		The length of [this] List.
+		The length of `this` List.
 	**/
 	public var length(default,null) : Int;
 
@@ -42,9 +42,9 @@ class List<T> {
 	}
 
 	/**
-		Adds element [item] at the end of [this] List.
+		Adds element `item` at the end of `this` List.
 		
-		[this].length increases by 1.
+		`this.length` increases by 1.
 	**/
 	public function add( item : T ) {
 		var x:Array<Dynamic> = #if neko untyped __dollar__array(item,null) #else [item] #end;
@@ -57,9 +57,9 @@ class List<T> {
 	}
 
 	/**
-		Adds element [item] at the beginning of [this] List.
+		Adds element `item` at the beginning of `this` List.
 		
-		[this].length increases by 1.
+		`this.length` increases by 1.
 	**/
 	public function push( item : T ) {
 		var x : Array<Dynamic> = #if neko
@@ -74,18 +74,18 @@ class List<T> {
 	}
 
 	/**
-		Returns the first element of [this] List, or null if no elements exist.
+		Returns the first element of `this` List, or null if no elements exist.
 		
-		This function does not modify [this] List.
+		This function does not modify `this` List.
 	**/
 	public function first() : Null<T> {
 		return if( h == null ) null else h[0];
 	}
 
 	/**
-		Returns the last element of [this] List, or null if no elements exist.
+		Returns the last element of `this` List, or null if no elements exist.
 		
-		This function does not modify [this] List.
+		This function does not modify `this` List.
 	**/
 	public function last() : Null<T> {
 		return if( q == null ) null else q[0];
@@ -93,9 +93,9 @@ class List<T> {
 
 
 	/**
-		Returns the first element of [this] List, or null if no elements exist.
+		Returns the first element of `this` List, or null if no elements exist.
 		
-		The element is removed from [this] List.
+		The element is removed from `this` List.
 	**/
 	public function pop() : Null<T> {
 		if( h == null )
@@ -109,17 +109,17 @@ class List<T> {
 	}
 
 	/**
-		Tells if [this] List is empty.
+		Tells if `this` List is empty.
 	**/
 	public function isEmpty() : Bool {
 		return (h == null);
 	}
 
 	/**
-		Empties [this] List.
+		Empties `this` List.
 		
 		This function does not traverse the elements, but simply sets the
-		internal references to null and [this].length to 0.
+		internal references to null and `this.length` to 0.
 	**/
 	public function clear() : Void {
 		h = null;
@@ -128,9 +128,9 @@ class List<T> {
 	}
 
 	/**
-		Removes the first occurence of [v] in [this] List.
+		Removes the first occurence of `v` in `this` List.
 		
-		If [v] is found by checking standard equality, it is removed from [this]
+		If `v` is found by checking standard equality, it is removed from `this`
 		List and the function returns true.
 		
 		Otherwise, false is returned.
@@ -195,7 +195,7 @@ class List<T> {
 	}
 
 	/**
-		Returns a string representation of [this] List.
+		Returns a string representation of `this` List.
 		
 		The result is enclosed in { } with the individual elements being
 		separated by a comma.
@@ -218,7 +218,7 @@ class List<T> {
 	}
 
 	/**
-		Returns a string representation of [this] List, with [sep] separating
+		Returns a string representation of `this` List, with `sep` separating
 		each element.
 	**/
 	public function join(sep : String) {
@@ -237,8 +237,8 @@ class List<T> {
 	}
 
 	/**
-		Returns a list filtered with [f]. The returned list will contain all
-		elements for which [f(x) = true].
+		Returns a list filtered with `f`. The returned list will contain all
+		elements for which `f(x) == true`.
 	**/
 	public function filter( f : T -> Bool ) {
 		var l2 = new List();
@@ -254,7 +254,7 @@ class List<T> {
 
 	/**
 		Returns a new list where all elements have been converted by the
-		function [f].
+		function `f`.
 	**/
 	public function map<X>(f : T -> X) : List<X> {
 		var b = new List();

+ 23 - 22
std/Map.hx

@@ -37,7 +37,7 @@ import haxe.ds.EnumValueMap;
 	A Map can be instantiated without explicit type parameters. Type inference
 	will then determine the type parameters from the usage.
 	
-	Maps can also be created with [key1 => value1, key2 => value2] syntax.
+	Maps can also be created with `key1 => value1, key2 => value2` syntax.
 	
 	Map is an abstract type, it is not available at runtime.
 **/
@@ -50,10 +50,10 @@ abstract Map<K,V>(IMap<K,V> ) {
 		This becomes a constructor call to one of the specialization types in
 		the output. The rules for that are as follows:
 		
-		1. if K is a String, haxe.ds.StringMap is used
-		2. if K is an Int, haxe.ds.IntMap is used
-		3. if K is an enum, haxe.ds.EnumValueMap is used
-		4. if K is any other class or structure, haxe.ds.ObjectMap is used
+		1. if K is a `String`, `haxe.ds.StringMap` is used
+		2. if K is an `Int`, `haxe.ds.IntMap` is used
+		3. if K is an `EnumValue`, `haxe.ds.EnumValueMap` is used
+		4. if K is any other class or structure, `haxe.ds.ObjectMap` is used
 		5. if K is any other type, it causes a compile-time error
 			
 		(Cpp) Map does not use weak keys on ObjectMap by default.
@@ -61,47 +61,48 @@ abstract Map<K,V>(IMap<K,V> ) {
 	public function new();
 
 	/**
-		Maps [key] to [value].
+		Maps `key` to `value`.
 		
-		If [key] already has a mapping, the previous value disappears.
+		If `key` already has a mapping, the previous value disappears.
 		
-		If [key] is null, the result is unspecified.
+		If `key` is null, the result is unspecified.
 	**/
 	public inline function set(key:K, value:V) this.set(key, value);
 	
 	/**
-		Returns the current mapping of [key].
+		Returns the current mapping of `key`.
 		
 		If no such mapping exists, null is returned.
 		
-		Note that a check like map.get(key) == null can hold for two reasons:
+		Note that a check like `map.get(key) == null` can hold for two reasons:
 		
-		1. the map has no mapping for [key]
-		2. the map has a mapping with a value of null
+		1. the map has no mapping for `key`
+		2. the map has a mapping with a value of `null`
 		
-		If it is important to distinguish these cases, exists() should be used.
+		If it is important to distinguish these cases, `exists()` should be 
+		used.
 		
-		If [key] is null, the result is unspecified.
+		If `key` is null, the result is unspecified.
 	**/
 	@:arrayAccess public inline function get(key:K) return this.get(key);
 	
 	/**
-		Returns true if [key] has a mapping, false otherwise.
+		Returns true if `key` has a mapping, false otherwise.
 		
-		If [key] is null, the result is unspecified.
+		If `key` is null, the result is unspecified.
 	**/
 	public inline function exists(key:K) return this.exists(key);
 	
 	/**
-		Removes the mapping of [key] and returns true if such a mapping existed,
+		Removes the mapping of `key` and returns true if such a mapping existed,
 		false otherwise.
 		
-		If [key] is null, the result is unspecified.
+		If `key` is null, the result is unspecified.
 	**/
 	public inline function remove(key:K) return this.remove(key);
 	
 	/**
-		Returns an Iterator over the keys of [this] Map.
+		Returns an Iterator over the keys of `this` Map.
 		
 		The order of keys is undefined.
 	**/
@@ -110,7 +111,7 @@ abstract Map<K,V>(IMap<K,V> ) {
 	}
 	
 	/**
-		Returns an Iterator over the values of [this] Map.
+		Returns an Iterator over the values of `this` Map.
 		
 		The order of values is undefined.
 	**/
@@ -119,7 +120,7 @@ abstract Map<K,V>(IMap<K,V> ) {
 	}
 	
 	/**
-		Returns a String representation of [this] Map.
+		Returns a String representation of `this` Map.
 		
 		The exact representation depends on the platform and key-type.
 	**/
@@ -173,4 +174,4 @@ interface IMap<K,V> {
 
 private typedef Hashable = {
 	function hashCode():Int;
-}
+}

+ 38 - 38
std/Math.hx

@@ -76,55 +76,55 @@ extern class Math
 	static var NaN(default, null) : Float;
 
 	/**
-		Returns the absolute value of [v].
+		Returns the absolute value of `v`.
 		
-		If [v] is positive or 0, the result is unchanged. Otherwise the result
-		is -[v].
+		If `v` is positive or 0, the result is unchanged. Otherwise the result
+		is -`v`.
 		
-		If [v] is NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is
+		If `v` is NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is
 		POSITIVE_INFINITY.
 		
-		If [v] is NaN, the result is NaN.
+		If `v` is NaN, the result is NaN.
 	**/
 	static function abs(v:Float):Float;
 	
 	/**
-		Returns the smaller of values [a] and [b].
+		Returns the smaller of values `a` and `b`.
 		
-		If [a] or [b] are NaN, the result is NaN.
+		If `a` or `b` are NaN, the result is NaN.
 		
-		If [a] or [b] are NEGATIVE_INFINITY, the result is NEGATIVE_INFINITY.
+		If `a` or `b` are NEGATIVE_INFINITY, the result is NEGATIVE_INFINITY.
 		
-		If [a] and [b] are POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
+		If `a` and `b` are POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
 	**/
 	static function min(a:Float, b:Float):Float;
 	
 	/**
-		Returns the greater of values [a] and [b].
+		Returns the greater of values `a` and `b`.
 		
-		If [a] or [b] are NaN, the result is NaN.
+		If `a` or `b` are NaN, the result is NaN.
 		
-		If [a] or [b] are POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
+		If `a` or `b` are POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
 		
-		If [a] and [b] are NEGATIVE_INFINITY, the result is NEGATIVE_INFINITY.
+		If `a` and `b` are NEGATIVE_INFINITY, the result is NEGATIVE_INFINITY.
 	**/
 	static function max(a:Float, b:Float):Float;
 	
 	/**
-		Returns the trigonometric sine of [v].
+		Returns the trigonometric sine of `v`.
 		
-		The unit of [v] is radians.
+		The unit of `v` is radians.
 		
-		If [v] is NaN or infinite, the result is NaN.
+		If `v` is NaN or infinite, the result is NaN.
 	**/
 	static function sin(v:Float):Float;
 	
 	/**
-		Returns the trigonometric cosine of [v].
+		Returns the trigonometric cosine of `v`.
 		
-		The unit of [v] is radians.
+		The unit of `v` is radians.
 		
-		If [v] is NaN or infinite, the result is NaN.
+		If `v` is NaN or infinite, the result is NaN.
 	**/
 	static function cos(v:Float):Float;
 	
@@ -136,27 +136,27 @@ extern class Math
 	static function atan2(y:Float, x:Float):Float;
 	
 	/**
-		Returns Euler's number, raised to the power of [v].
+		Returns Euler's number, raised to the power of `v`.
 		
 		exp(1.0) is approximately 2.718281828459.
 		
-		If [v] is POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
+		If `v` is POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
 		
-		If [v] is NEGATIVE_INFINITY, the result is 0.0.
+		If `v` is NEGATIVE_INFINITY, the result is 0.0.
 		
-		If [v] is NaN, the result is NaN.
+		If `v` is NaN, the result is NaN.
 	**/
 	static function exp(v:Float):Float;
 	
 	/**
-		Returns the natural logarithm of [v].
+		Returns the natural logarithm of `v`.
 		
-		If [v] is negative (including NEGATIVE_INFINITY) or NaN, the result is
+		If `v` is negative (including NEGATIVE_INFINITY) or NaN, the result is
 		NaN.
 		
-		If [v] is POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
+		If `v` is POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
 		
-		If [v] is 0.0, the result is NEGATIVE_INFINITY.
+		If `v` is 0.0, the result is NEGATIVE_INFINITY.
 		
 		This is the inverse operation of exp, i.e. log(exp(v)) == v always
 		holds.
@@ -168,19 +168,19 @@ extern class Math
 	static function pow(v:Float, exp:Float):Float;
 	
 	/**
-		Returns the square root of [v].
+		Returns the square root of `v`.
 		
-		If [v] is negative (including NEGATIVE_INFINITY) or NaN, the result is
+		If `v` is negative (including NEGATIVE_INFINITY) or NaN, the result is
 		NaN.
 		
-		If [v] is POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
+		If `v` is POSITIVE_INFINITY, the result is POSITIVE_INFINITY.
 		
-		If [v] is 0.0, the result is 0.0.
+		If `v` is 0.0, the result is 0.0.
 	**/
 	static function sqrt(v:Float):Float;
 	
 	/**
-		Rounds [v] to the nearest Int value.
+		Rounds `v` to the nearest Int value.
 
 		If v is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is unspecified.
 		
@@ -189,7 +189,7 @@ extern class Math
 	static function round(v:Float):Int;
 	
 	/**
-		Returns the largest Int value that is not greater than [v].
+		Returns the largest Int value that is not greater than `v`.
 		
 		If v is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is unspecified.		
 		
@@ -198,7 +198,7 @@ extern class Math
 	static function floor(v:Float):Int;
 	
 	/**
-		Returns the smallest Int value that is not less than [v].
+		Returns the smallest Int value that is not less than `v`.
 
 		If v is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is unspecified.
 		
@@ -236,9 +236,9 @@ extern class Math
 	
 
 	/**
-		Tells if [f] is a finite number.
+		Tells if `f` is a finite number.
 		
-		If [f] is POSITIVE_INFINITY, NEGATIVE_INFINITY or NaN, the result is
+		If `f` is POSITIVE_INFINITY, NEGATIVE_INFINITY or NaN, the result is
 		false.
 		
 		Otherwise the result is true.
@@ -246,9 +246,9 @@ extern class Math
 	static function isFinite( f : Float ) : Bool;
 	
 	/**
-		Tells if [f] is not a valid number.
+		Tells if `f` is not a valid number.
 		
-		If [f] is NaN, the result is true.
+		If `f` is NaN, the result is true.
 		
 		Otherwise the result is false. In particular, both POSITIVE_INFINITY and
 		NEGATIVE_INFINITY are not considered NaN.

+ 50 - 48
std/Reflect.hx

@@ -26,25 +26,25 @@
 extern class Reflect {
 
 	/**
-		Tells if structure [o] has a field named [field].
+		Tells if structure `o` has a field named `field`.
 		
 		This is only guaranteed to work for anonymous structures. Refer to
-		[Type.getInstanceFields] for a function supporting class instances.
+		`Type.getInstanceFields` for a function supporting class instances.
 		
-		If [o] or [field] are null, the result is unspecified.
+		If `o` or `field` are null, the result is unspecified.
 	**/
 	public static function hasField( o : Dynamic, field : String ) : Bool;
 
 	/**
-		Returns the value of the field named [field] on object [o].
+		Returns the value of the field named `field` on object `o`.
 		
-		If [o] is not an object or has no field named [field], the result is
+		If `o` is not an object or has no field named `field`, the result is
 		null.
 		
 		If the field is defined as a property, its accessors are ignored. Refer
-		to [Reflect.getProperty] for a function supporting property accessors.
+		to `Reflect.getProperty` for a function supporting property accessors.
 		
-		If [field] is null, the result is unspecified.
+		If `field` is null, the result is unspecified.
 		
 		(As3) If used on a property field, the getter will be invoked. It is
 		not possible to obtain the value directly.
@@ -52,12 +52,12 @@ extern class Reflect {
 	public static function field( o : Dynamic, field : String ) : Dynamic;
 
 	/**
-		Sets the field named [field] of object [o] to value [value].
+		Sets the field named `field` of object `o` to value `value`.
 		
-		If [o] has no field named [field], this function is only guaranteed to
+		If `o` has no field named `field`, this function is only guaranteed to
 		work for anonymous structures.
 		
-		If [o] or [field] are null, the result is unspecified.
+		If `o` or `field` are null, the result is unspecified.
 		
 		(As3) If used on a property field, the setter will be invoked. It is
 		not possible to set the value directly.		
@@ -65,24 +65,24 @@ extern class Reflect {
 	public static function setField( o : Dynamic, field : String, value : Dynamic ) : Void;
 
 	/**
-		Returns the value of the field named [field] on object [o], taking
+		Returns the value of the field named `field` on object `o`, taking
 		property getter functions into account.
 		
 		If the field is not a property, this function behaves like
-		[Reflect.field], but might be slower.
+		`Reflect.field`, but might be slower.
 		
-		If [o] or [field] are null, the result is unspecified.
+		If `o` or `field` are null, the result is unspecified.
 	**/
 	public static function getProperty( o : Dynamic, field : String ) : Dynamic;
 
 	/**
-		Sets the field named [field] of object [o] to value [value], taking
+		Sets the field named `field` of object `o` to value `value`, taking
 		property setter functions into account.
 		
 		If the field is not a property, this function behaves like
-		[Reflect.setField], but might be slower.
+		`Reflect.setField`, but might be slower.
 		
-		If [field] is null, the result is unspecified.
+		If `field` is null, the result is unspecified.
 	**/
 	public static function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void;
 
@@ -92,92 +92,94 @@ extern class Reflect {
 	public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic;
 
 	/**
-		Returns the fields of structure [o].
+		Returns the fields of structure `o`.
 		
 		This method is only guaranteed to work on anonymous structures. Refer to
-		[Type.getInstanceFields()] for a function supporting class instances.
+		`Type.getInstanceFields` for a function supporting class instances.
 		
-		If [o] is null, the result is unspecified.
+		If `o` is null, the result is unspecified.
 	**/
 	public static function fields( o : Dynamic ) : Array<String>;
 
 	/**
-		Returns true if [f] is a function, false otherwise.
+		Returns true if `f` is a function, false otherwise.
 		
-		If [f] is null, the result is false.
+		If `f` is null, the result is false.
 	**/
 	public static function isFunction( f : Dynamic ) : Bool;
 
 	/**
-		Compares [a] and [b].
+		Compares `a` and `b`.
 		
-		If [a] is less than [b], the result is negative. If [b] is less than
-		[a], the result is positive. If [a] and [b] are equal, the result is 0.
+		If `a` is less than `b`, the result is negative. If `b` is less than
+		`a`, the result is positive. If `a` and `b` are equal, the result is 0.
 		
-		This function is only defined if [a] and [b] are of the same type.
+		This function is only defined if `a` and `b` are of the same type.
 		
 		If that type is a function, the result is unspecified and
-		[Reflect.compareMethods] should be used instead.
+		`Reflect.compareMethods` should be used instead.
 		
-		For all other types, the result is 0 if [a] and [b] are equal. If they
+		For all other types, the result is 0 if `a` and `b` are equal. If they
 		are not equal, the result depends on the type and is negative if:
-			Numeric types: a is less than b
-			String: a is lexicographically less than b
-			Other: unspecified
 		
-		If [a] and [b] are null, the result is 0. If only one of them is null,
+		- Numeric types: a is less than b
+		- String: a is lexicographically less than b
+		- Other: unspecified
+		
+		If `a` and `b` are null, the result is 0. If only one of them is null,
 		the result is unspecified.
 	**/
 	public static function compare<T>( a : T, b : T ) : Int;
 
 	/**
-		Compares the functions [f1] and [f2].
+		Compares the functions `f1` and `f2`.
 		
-		If [f1] or [f2] are not functions, the result is unspecified.
+		If `f1` or `f2` are not functions, the result is unspecified.
 		
-		Otherwise the result is true if [f1] and the [f2] are physically equal,
+		Otherwise the result is true if `f1` and the `f2` are physically equal,
 		false otherwise.
 	**/
 	public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool;
 
 	/**
-		Tells if [v] is an object.
+		Tells if `v` is an object.
 		
-		The result is true if [v] is one of the following:
-			- class instance
-			- structure
-			- Class<T>
-			- Enum<T>
+		The result is true if `v` is one of the following:
+			
+		- class instance
+		- structure
+		- Class<T>
+		- Enum<T>
 			
-		Otherwise, including if [v] is null, the result is false.
+		Otherwise, including if `v` is null, the result is false.
 	**/
 	public static function isObject( v : Dynamic ) : Bool;
 
 	/**
-		Tells if [v] is an enum value.
+		Tells if `v` is an enum value.
 		
-		The result is true if [v] is of type EnumValue, i.e. an enum
+		The result is true if `v` is of type EnumValue, i.e. an enum
 		constructor.
 		
-		Otherwise, including if [v] is null, the result is false.
+		Otherwise, including if `v` is null, the result is false.
 	**/
 	public static function isEnumValue( v : Dynamic ) : Bool;
 	
 	/**
-		Removes the field named [field] from structure [o].
+		Removes the field named `field` from structure `o`.
 		
 		This method is only guaranteed to work on anonymous structures.
 		
-		If [o] or [field] are null, the result is unspecified.
+		If `o` or `field` are null, the result is unspecified.
 	**/
 	public static function deleteField( o : Dynamic, field : String ) : Bool;
 
 	/**
-		Copies the fields of structure [o].
+		Copies the fields of structure `o`.
 		
 		This is only guaranteed to work on anonymous structures.
 		
-		If [o] is null, the result is unspecified.
+		If `o` is null, the result is unspecified.
 	**/
 	public static function copy<T>( o : T ) : T;
 

+ 15 - 15
std/Std.hx

@@ -36,17 +36,17 @@ extern class Std {
 	/**
 		Converts any value to a String.
 
-		If s is of String, Int, Float or Bool, its value is returned.
+		If `s` is of `String`, `Int`, `Float` or `Bool`, its value is returned.
 
-		If s is an instance of a class and that class or one of its parent classes has
-		a toString() method, that method is called. If no such method is present, the result
+		If `s` is an instance of a class and that class or one of its parent classes has
+		a `toString` method, that method is called. If no such method is present, the result
 		is unspecified.
 
-		If s is an enum constructor without argument, the constructor's name is returned. If
+		If `s` is an enum constructor without argument, the constructor's name is returned. If
 		arguments exists, the constructor's name followed by the String representations of
 		the arguments is returned.
 
-		If s is a structure, the field names along with their values are returned. The field order
+		If `s` is a structure, the field names along with their values are returned. The field order
 		and the operator separating field names and values are unspecified.
 
 		If s is null, "null" is returned.
@@ -54,21 +54,21 @@ extern class Std {
 	public static function string( s : Dynamic ) : String;
 
 	/**
-		Converts a Float to an Int, rounded towards 0.
+		Converts a `Float` to an `Int`, rounded towards 0.
 
-		If x is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is unspecified.
+		If `x` is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is unspecified.
 	**/
 	public static function int( x : Float ) : Int;
 
 	/**
-		Converts a String to an Int.
+		Converts a `String` to an `Int`.
 
 		Leading whitespaces are ignored.
 
-		If x starts with 0x or 0X, hexadecimal notation is recognized where the following digits may
+		If `x` starts with 0x or 0X, hexadecimal notation is recognized where the following digits may
 		contain 0-9 and A-F.
 
-		Otherwise x is read as decimal number with 0-9 being allowed characters. x may also start with
+		Otherwise `x` is read as decimal number with 0-9 being allowed characters. `x` may also start with
 		a - to denote a negative value.
 
 		In decimal mode, parsing continues until an invalid character is detected, in which case the
@@ -83,19 +83,19 @@ extern class Std {
 	public static function parseInt( x : String ) : Null<Int>;
 
 	/**
-		Converts a String to a Float.
+		Converts a `String` to a `Float`.
 
-		The parsing rules for parseInt() apply here as well, with the exception of invalid input
+		The parsing rules for `parseInt` apply here as well, with the exception of invalid input
 		resulting in a NaN value instead of null.
 
-		Additionally, decimal notation may contain a single . to denote the start of the fractions.
+		Additionally, decimal notation may contain a single `.` to denote the start of the fractions.
 	**/
 	public static function parseFloat( x : String ) : Float;
 
 	/**
-		Return a random integer between 0 included and x excluded.
+		Return a random integer between 0 included and `x` excluded.
 
-		If x is <= 1, the result is always 0.
+		If `x <= 1`, the result is always 0.
 	**/
 	public static function random( x : Int ) : Int;
 }

+ 19 - 8
std/StdTypes.hx

@@ -19,20 +19,26 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-// standard haXe types
+// standard Haxe types
 
 /**
-	The standard Void type. Only [null] values can be of the type [Void].
+	The standard Void type. Only `null` values can be of the type `Void`.
 **/
 @:coreType abstract Void { }
 
 /**
 	The standard Float type, this is a double-precision IEEE 64bit float.
+	
+	On static targets, null cannot be assigned to Float. If this is necessary,
+	`Null<Float>` can be used instead.	
 **/
 @:coreType @:notNull @:runtimeValue abstract Float { }
 
 /**
 	The standard Int type. Its precision depends on the platform.
+	
+	On static targets, null cannot be assigned to Int. If this is necessary,
+	`Null<Int>` can be used instead.
 **/
 @:coreType @:notNull @:runtimeValue abstract Int to Float { }
 
@@ -49,22 +55,27 @@
 #end
 
 /**
-	[Null] can be useful in two cases. In order to document some methods
-	that accepts or can return a [null] value, or for the Flash9 compiler and AS3
+	`Null` can be useful in two cases. In order to document some methods
+	that accepts or can return a `null` value, or for the Flash9 compiler and AS3
 	generator to distinguish between base values that can be null and others that
 	can't.
 **/
 typedef Null<T> = T
 
 /**
-	The standard Boolean type is represented as an enum with two choices.
+	The standard Boolean type, which can either be true or false.
+	
+	On static targets, null cannot be assigned to Bool. If this is necessary,
+	`Null<Bool>` can be used instead.
 **/
 @:coreType @:notNull @:runtimeValue abstract Bool {
 }
 
 /**
-	Dynamic is an internal compiler type which has special behavior.
-	See the haXe language reference for more informations.
+	Dynamic is a special type which is compatible with all other types.
+	
+	Use of Dynamic should be minimized as it prevents several compiler
+	checks and optimizations.
 **/
 @:coreType @:runtimeValue abstract Dynamic<T> {
 }
@@ -100,7 +111,7 @@ typedef Iterator<T> = {
 
 /**
 	An Iterable is a data structure which has an iterator() method.
-	See [Lambda] for generic functions on iterable structures.
+	See `Lambda` for generic functions on iterable structures.
 **/
 typedef Iterable<T> = {
 	function iterator() : Iterator<T>;

+ 47 - 47
std/String.hx

@@ -23,7 +23,7 @@
 	The basic String class.
 	
 	A haxe String is immutable, it is not possible to modify individual
-	characters. No method of this class changes the state of [this] String.
+	characters. No method of this class changes the state of `this` String.
 	
 	Strings can be constructed using the string literal syntax "string value".
 	
@@ -33,7 +33,7 @@
 extern class String {
 
 	/**
-		The number of characters in [this] String.
+		The number of characters in `this` String.
 	**/
 	var length(default,null) : Int;
 
@@ -43,31 +43,31 @@ extern class String {
 	function new(string:String) : Void;
 
 	/**
-		Returns a String where all characters of [this] String are upper case.
+		Returns a String where all characters of `this` String are upper case.
 		
-		Affects the characters [a-z]. Other characters remain unchanged.
+		Affects the characters `a-z`. Other characters remain unchanged.
 	**/
 	function toUpperCase() : String;
 
 	/**
-		Returns a String where all characters of [this] String are lower case.
+		Returns a String where all characters of `this` String are lower case.
 		
-		Affects the characters [A-Z]. Other characters remain unchanged.
+		Affects the characters `A-Z`. Other characters remain unchanged.
 	**/
 	function toLowerCase() : String;
 
 	/**
-		Returns the character at position [index] of [this] String.
+		Returns the character at position `index` of `this` String.
 		
-		If [index] is negative or exceeds [this].length, the empty String ""
+		If `index` is negative or exceeds `this.length`, the empty String ""
 		is returned.
 	**/
 	function charAt(index : Int) : String;
 
 	/**
-		Returns the character code at position [index] of [this] String.
+		Returns the character code at position `index` of `this` String.
 		
-		If [index] is negative or exceeds [this].length, null is returned.
+		If `index` is negative or exceeds `this.length`, null is returned.
 		
 		To obtain the character code of a single character, "x".code can be used
 		instead to inline the character code at compile time. Note that this
@@ -76,78 +76,78 @@ extern class String {
 	function charCodeAt( index : Int) : Null<Int>;
 
 	/**
-		Returns the position of the leftmost occurence of [str] within [this]
+		Returns the position of the leftmost occurence of `str` within `this`
 		String.
 		
-		If [startIndex] is given, the search is performed within the substring
-		of [this] String starting from [startIndex]. Otherwise the search is
-		performed within [this] String. In either case, the returned position
-		is relative to the beginning of [this] String.
+		If `startIndex` is given, the search is performed within the substring
+		of `this` String starting from `startIndex`. Otherwise the search is
+		performed within `this` String. In either case, the returned position
+		is relative to the beginning of `this` String.
 		
-		If [str] cannot be found, -1 is returned.
+		If `str` cannot be found, -1 is returned.
 	**/
 	function indexOf( str : String, ?startIndex : Int ) : Int;
 
 	/**
-		Returns the position of the rightmost occurence of [str] within [this]
+		Returns the position of the rightmost occurence of `str` within `this`
 		String.
 		
-		If [startIndex] is given, the search is performed within the substring
-		of [this] String from 0 to [startIndex]. Otherwise the search is
-		performed within [this] String. In either case, the returned position
-		is relative to the beginning of [this] String.
+		If `startIndex` is given, the search is performed within the substring
+		of `this` String from 0 to `startIndex`. Otherwise the search is
+		performed within `this` String. In either case, the returned position
+		is relative to the beginning of `this` String.
 		
-		If [str] cannot be found, -1 is returned.
+		If `str` cannot be found, -1 is returned.
 	**/
 	function lastIndexOf( str : String, ?startIndex : Int ) : Int;
 
 	/**
-		Splits [this] String at each occurence of [delimiter].
+		Splits `this` String at each occurence of `delimiter`.
 		
-		If [delimiter] is the empty String "", [this] String is split into an
-		Array of [this].length elements, where the elements correspond to the
-		characters of [this] String.
+		If `delimiter` is the empty String "", `this` String is split into an
+		Array of `this.length` elements, where the elements correspond to the
+		characters of `this` String.
 		
-		If [delimiter] is not found within [this] String, the result is an Array
-		with one element, which equals [this] String.
+		If `delimiter` is not found within `this` String, the result is an Array
+		with one element, which equals `this` String.
 		
-		If [delimiter] is null, the result is unspecified.
+		If `delimiter` is null, the result is unspecified.
 		
-		Otherwise, [this] String is split into parts at each occurence of
-		[delimiter]. If [this] String starts (or ends) with [delimiter}, the
+		Otherwise, `this` String is split into parts at each occurence of
+		`delimiter`. If `this` String starts (or ends) with [delimiter}, the
 		result Array contains a leading (or trailing) empty String "" element.
 		Two subsequent delimiters also result in an empty String "" element.
 	**/
 	function split( delimiter : String ) : Array<String>;
 
 	/**
-		Returns [len] characters of [this] String, starting at position [pos].
+		Returns `len` characters of `this` String, starting at position `pos`.
 		
-		If [len] is omitted, all characters from position [pos] to the end of
-		[this] String are included.
+		If `len` is omitted, all characters from position `pos` to the end of
+		`this` String are included.
 		
-		If [pos] is negative, its value is calculated from the end of [this]
-		String by [this].length + [pos]. If this yields a negative value, 0 is
+		If `pos` is negative, its value is calculated from the end of `this`
+		String by `this.length + pos`. If this yields a negative value, 0 is
 		used instead.
 		
-		If the calculated position + [len] exceeds [this].length, the characters
-		from that position to the end of [this] String are returned.
+		If the calculated position + `len` exceeds `this.length`, the characters
+		from that position to the end of `this` String are returned.
 		
-		If [len] is negative, the result is unspecified.
+		If `len` is negative, the result is unspecified.
 	**/
 	function substr( pos : Int, ?len : Int ) : String;
 
 	/**
-		Returns the part of [this] String from [startIndex] to [endIndex].
+		Returns the part of `this` String from `startIndex` to `endIndex`.
 		
-		If [startIndex] or [endIndex] are negative, 0 is used instead.
+		If `startIndex` or `endIndex` are negative, 0 is used instead.
 		
-		If [startIndex] exceeds [endIndex], they are swapped.
+		If `startIndex` exceeds `endIndex`, they are swapped.
 		
-		If the (possibly swapped) [endIndex] is omitted or exceeds
-		[this].length, [this].length is used instead.
+		If the (possibly swapped) `endIndex` is omitted or exceeds
+		`this.length`, `this.length` is used instead.
 		
-		If the (possibly swapped) [startIndex] exceeds [this].length, the empty
+		If the (possibly swapped) `startIndex` exceeds `this.length`, the empty
 		String "" is returned.
 	**/
 	function substring( startIndex : Int, ?endIndex : Int ) : String;
@@ -158,9 +158,9 @@ extern class String {
 	function toString() : String;
 
 	/**
-		Returns the String corresponding to the character code [code].
+		Returns the String corresponding to the character code `code`.
 		
-		If [code] is negative or has another invalid value, the result is
+		If `code` is negative or has another invalid value, the result is
 		unspecified.
 	**/
 	static function fromCharCode( code : Int ) : String;

+ 22 - 13
std/StringBuf.hx

@@ -34,6 +34,11 @@ class StringBuf {
 
 	var b:String = "";
 	
+	/**
+		The length of `this` StringBuf in characters.
+	**/
+	public var length(get,never) : Int;
+
 	/**
 		Creates a new StringBuf instance.
 		
@@ -41,23 +46,27 @@ class StringBuf {
 	**/
 	public function new() {}
 
+	inline function get_length() : Int {
+		return b.length;
+	}
+
 	/**
-		Appends the representation of [x] to [this] StringBuf.
+		Appends the representation of `x` to `this` StringBuf.
 		
-		The exact representation of [x] may vary per platform. To get more
+		The exact representation of `x` may vary per platform. To get more
 		consistent behavior, this function should be called with
 		Std.string(x).
 		
-		If [x] is null, the String "null" is appended.
+		If `x` is null, the String "null" is appended.
 	**/
 	public inline function add( x : Dynamic ) : Void {
 		b += x;
 	}
 
 	/**
-		Appends the character identified by [c] to [this] StringBuf.
+		Appends the character identified by `c` to `this` StringBuf.
 		
-		If [c] is negative or has another invalid value, the result is
+		If `c` is negative or has another invalid value, the result is
 		unspecified.
 	**/
 	public inline function addChar( c : Int ) : Void {
@@ -65,23 +74,23 @@ class StringBuf {
 	}
 
 	/**
-		Appends a substring of [s] to [this] StringBuf.
+		Appends a substring of `s` to `this` StringBuf.
 		
-		This function expects [pos] and [len] to describe a valid substring of
-		[s], or else the result is unspecified. To get more robust behavior,
-		[this].add(s.substr(pos,len)) can be used instead.
+		This function expects `pos` and `len` to describe a valid substring of
+		`s`, or else the result is unspecified. To get more robust behavior,
+		`this.add(s.substr(pos,len))` can be used instead.
 		
-		If [s] or [pos] are null, the result is unspecified.
+		If `s` or `pos` are null, the result is unspecified.
 		
-		If [len] is omitted or null, the substring ranges from [pos] to the end
-		of [s].
+		If `len` is omitted or null, the substring ranges from `pos` to the end
+		of `s`.
 	**/
 	public inline function addSub( s : String, pos : Int, ?len : Int) : Void {
 		b += (len == null ? s.substr(pos) : s.substr(pos, len));
 	}
 
 	/**
-		Returns the content of [this] StringBuf as String.
+		Returns the content of `this` StringBuf as String.
 		
 		The buffer is not emptied by this operation.
 	**/

+ 56 - 52
std/StringTools.hx

@@ -82,15 +82,18 @@ class StringTools {
 	}
 
 	/**
-		Escapes HTML special characters of the string [s].
+		Escapes HTML special characters of the string `s`.
 
 		The following replacements are made:
-			- & becomes &amp;
-			- < becomes &lt;
-			- > becomes &gt;
-		If [quotes] is true, the following characters are also replaced:
-			- " becomes &quot;
-			- ' becomes &#039;
+			
+		- `&` becomes `&amp`;
+		- `<` becomes `&lt`;
+		- `>` becomes `&gt`;
+		
+		If `quotes` is true, the following characters are also replaced:
+		
+		- `"` becomes `&quot`;
+		- `'` becomes `&#039`;
 	**/
 	public static function htmlEscape( s : String, ?quotes : Bool ) : String {
 		s = s.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
@@ -98,28 +101,29 @@ class StringTools {
 	}
 
 	/**
-		Unescapes HTML special characters of the string [s].
+		Unescapes HTML special characters of the string `s`.
 
 		This is the inverse operation to htmlEscape, i.e. the following always
 		holds: htmlUnescape(htmlEscape(s)) == s
 
 		The replacements follow:
-			- &amp; becomes &
-			- &lt; becomes <
-			- &gt; becomes >
-			- &quot; becomes "
-			- &#039; becomes '
+			
+		- `&amp;` becomes `&`
+		- `&lt;` becomes `<`
+		- `&gt;` becomes `>`
+		- `&quot;` becomes `"`
+		- `&#039;` becomes `'`
 	**/
 	public static function htmlUnescape( s : String ) : String {
 		return s.split("&gt;").join(">").split("&lt;").join("<").split("&quot;").join('"').split("&#039;").join("'").split("&amp;").join("&");
 	}
 
 	/**
-		Tells if the string [s] starts with the string [start].
+		Tells if the string `s` starts with the string `start`.
 
-		If [start] is null, the result is unspecified.
+		If `start` is null, the result is unspecified.
 
-		If [start] is the empty String "", the result is true.
+		If `start` is the empty String "", the result is true.
 	**/
 	public static #if (cs || java) inline #end function startsWith( s : String, start : String ) : Bool {
 		#if java
@@ -132,11 +136,11 @@ class StringTools {
 	}
 
 	/**
-		Tells if the string [s] ends with the string [end].
+		Tells if the string `s` ends with the string `end`.
 
-		If [end] is null, the result is unspecified.
+		If `end` is null, the result is unspecified.
 
-		If [end] is the empty String "", the result is true.
+		If `end` is the empty String "", the result is true.
 	**/
 	public static #if (cs || java) inline #end function endsWith( s : String, end : String ) : Bool {
 		#if java
@@ -151,13 +155,13 @@ class StringTools {
 	}
 
 	/**
-		Tells if the character in the string [s] at position [pos] is a space.
+		Tells if the character in the string `s` at position `pos` is a space.
 
 		A character is considered to be a space character if its character code
 		is 9,10,11,12,13 or 32.
 
-		If [s] is the empty String "", or if pos is not a valid position within
-		[s], the result is false.
+		If `s` is the empty String "", or if pos is not a valid position within
+		`s`, the result is false.
 	**/
 	public static function isSpace( s : String, pos : Int ) : Bool {
 		var c = s.charCodeAt( pos );
@@ -165,12 +169,12 @@ class StringTools {
 	}
 
 	/**
-		Removes leading space characters of [s].
+		Removes leading space characters of `s`.
 
 		This function internally calls isSpace() to decide which characters to
 		remove.
 
-		If [s] is the empty String "" or consists only of space characters, the
+		If `s` is the empty String "" or consists only of space characters, the
 		result is the empty String "".
 	**/
 	public #if cs inline #end static function ltrim( s : String ) : String {
@@ -190,12 +194,12 @@ class StringTools {
 	}
 
 	/**
-		Removes trailing space characters of [s].
+		Removes trailing space characters of `s`.
 
 		This function internally calls isSpace() to decide which characters to
 		remove.
 
-		If [s] is the empty String "" or consists only of space characters, the
+		If `s` is the empty String "" or consists only of space characters, the
 		result is the empty String "".
 	**/
 	public #if cs inline #end static function rtrim( s : String ) : String {
@@ -216,7 +220,7 @@ class StringTools {
 	}
 
 	/**
-		Removes leading and trailing space characters of [s].
+		Removes leading and trailing space characters of `s`.
 
 		This is a convenience function for ltrim(rtrim(s)).
 	**/
@@ -231,16 +235,16 @@ class StringTools {
 	}
 
 	/**
-		Concatenates [c] to [s] until [s].length is at least [l].
+		Concatenates `c` to `s` until `s.length` is at least `l`.
 
-		If [c] is the empty String "" or if [l] does not exceed [s].length,
-		[s] is returned unchanged.
+		If `c` is the empty String "" or if `l` does not exceed `s.length`,
+		`s` is returned unchanged.
 
-		If [c].length is 1, the resulting String length is exactly [l].
+		If `c.length` is 1, the resulting String length is exactly `l`.
 
-		Otherwise the length may exceed [l].
+		Otherwise the length may exceed `l`.
 
-		If [c] is null, the result is unspecified.
+		If `c` is null, the result is unspecified.
 	**/
 	public static function lpad( s : String, c : String, l : Int ) : String {
 		if (c.length <= 0)
@@ -253,16 +257,16 @@ class StringTools {
 	}
 
 	/**
-		Appends [c] to [s] until [s].length is at least [l].
+		Appends `c` to `s` until `s.length` is at least `l`.
 
-		If [c] is the empty String "" or if [l] does not exceed [s].length,
-		[s] is returned unchanged.
+		If `c` is the empty String "" or if `l` does not exceed `s.length`,
+		`s` is returned unchanged.
 
-		If [c].length is 1, the resulting String length is exactly [l].
+		If `c.length` is 1, the resulting String length is exactly `l`.
 
-		Otherwise the length may exceed [l].
+		Otherwise the length may exceed `l`.
 
-		If [c] is null, the result is unspecified.
+		If `c` is null, the result is unspecified.
 	**/
 	public static function rpad( s : String, c : String, l : Int ) : String {
 		if (c.length <= 0)
@@ -275,15 +279,15 @@ class StringTools {
 	}
 
 	/**
-		Replace all occurences of the String [sub] in the String [s] by the
-		String [by].
+		Replace all occurences of the String `sub` in the String `s` by the
+		String `by`.
 
-		If [sub] is the empty String "", [by] is inserted after each character
-		of [s]. If [by] is also the empty String "", [s] remains unchanged.
+		If `sub` is the empty String "", `by` is inserted after each character
+		of `s`. If `by` is also the empty String "", `s` remains unchanged.
 
-		This is a convenience function for [s].split([sub]).join([by]).
+		This is a convenience function for `s.split(sub).join(by)`.
 
-		If [sub] or [by] are null, the result is unspecified.
+		If `sub` or `by` are null, the result is unspecified.
 	**/
 	public static function replace( s : String, sub : String, by : String ) : String {
 		#if java
@@ -302,10 +306,10 @@ class StringTools {
 	}
 
 	/**
-		Encodes [n] into a hexadecimal representation.
+		Encodes `n` into a hexadecimal representation.
 
-		If [digits] is specified, the resulting String is padded with "0" until
-		its length equals [digits].
+		If `digits` is specified, the resulting String is padded with "0" until
+		its length equals `digits`.
 	**/
 	public static function hex( n : Int, ?digits : Int ) {
 		#if flash9
@@ -327,13 +331,13 @@ class StringTools {
 	}
 
 	/**
-		Returns the character code at position [index] of String [s].
+		Returns the character code at position `index` of String `s`.
 
 		This method is faster than String.charCodeAt() on most platforms.
 		However, unlike String.charCodeAt(), the result is unspecified if
-		[index] is negative or exceeds [s].length.
+		`index` is negative or exceeds `s.length`.
 
-		This operation is not guaranteed to work if [s] contains the \0
+		This operation is not guaranteed to work if `s` contains the \0
 		character.
 	**/
 	public static inline function fastCodeAt( s : String, index : Int ) : Int untyped {
@@ -361,7 +365,7 @@ class StringTools {
 	}
 
 	/*
-		Tells if [c] represents the end-of-file (EOF) character.
+		Tells if `c` represents the end-of-file (EOF) character.
 	*/
 	@:noUsing public static inline function isEof( c : Int ) : Bool {
 		#if (flash9 || cpp)

+ 62 - 63
std/Type.hx

@@ -21,7 +21,6 @@
  */
 /**
 	The diffent possible runtime types of a value.
-	See [Type] for the haXe Reflection API.
 **/
 enum ValueType {
 	TNull;
@@ -44,21 +43,21 @@ enum ValueType {
 extern class Type {
 
 	/**
-		Returns the class of [o], if [o] is a class instance.
+		Returns the class of `o`, if `o` is a class instance.
 		
-		If [o] is null or of a different type, null is returned.
+		If `o` is null or of a different type, null is returned.
 		
 		In general, type parameter information cannot be obtained at runtime.
 	**/
 	public static function getClass<T>( o : T ) : Class<T>;
 
 	/**
-		Returns the enum of enum instance [o].
+		Returns the enum of enum instance `o`.
 		
 		An enum instance is the result of using an enum constructor. Given an
-		enum Color { Red; }, getEnum(Red) returns Enum<Color>.
+		`enum Color { Red; }`, `getEnum(Red)` returns `Enum<Color>`.
 		
-		If [o] is null, null is returned.
+		If `o` is null, null is returned.
 		
 		In general, type parameter information cannot be obtained at runtime.
 	**/
@@ -66,11 +65,11 @@ extern class Type {
 
 
 	/**
-		Returns the super-class of class [c].
+		Returns the super-class of class `c`.
 		
-		If [c] has no super class, null is returned.
+		If `c` has no super class, null is returned.
 		
-		If [c] is null, the result is unspecified.
+		If `c` is null, the result is unspecified.
 		
 		In general, type parameter information cannot be obtained at runtime.
 	**/
@@ -78,34 +77,34 @@ extern class Type {
 
 
 	/**
-		Returns the name of class [c], including its path.
+		Returns the name of class `c`, including its path.
 		
-		If [c] is inside a package, the package structure is returned dot-
+		If `c` is inside a package, the package structure is returned dot-
 		separated, with another dot separating the class name:
-			pack1.pack2.(...).packN.ClassName
-		If [c] is a sub-type of a haxe module, that module is not part of the
+		`pack1.pack2.(...).packN.ClassName`
+		If `c` is a sub-type of a haxe module, that module is not part of the
 		package structure.
 			
-		If [c] has no package, the class name is returned.
+		If `c` has no package, the class name is returned.
 		
-		If [c] is null, the result is unspecified.
+		If `c` is null, the result is unspecified.
 		
 		The class name does not include any type parameters.
 	**/
 	public static function getClassName( c : Class<Dynamic> ) : String;
 
 	/**
-		Returns the name of enum [e], including its path.
+		Returns the name of enum `e`, including its path.
 		
-		If [e] is inside a package, the package structure is returned dot-
+		If `e` is inside a package, the package structure is returned dot-
 		separated, with another dot separating the enum name:
-			pack1.pack2.(...).packN.EnumName
-		If [e] is a sub-type of a haxe module, that module is not part of the
+		`pack1.pack2.(...).packN.EnumName`
+		If `e` is a sub-type of a haxe module, that module is not part of the
 		package structure.
 			
-		If [e] has no package, the enum name is returned.
+		If `e` has no package, the enum name is returned.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 		
 		The enum name does not include any type parameters.
 	**/
@@ -114,11 +113,11 @@ extern class Type {
 	/**
 		Resolves a class by name.
 		
-		If [name] is the path of an existing class, that class is returned.
+		If `name` is the path of an existing class, that class is returned.
 		
 		Otherwise null is returned.
 		
-		If [name] is null or the path to a different type, the result is
+		If `name` is null or the path to a different type, the result is
 		unspecified.
 		
 		The class name must not include any type parameters.
@@ -128,20 +127,20 @@ extern class Type {
 	/**
 		Resolves an enum by name.
 		
-		If [name] is the path of an existing enum, that enum is returned.
+		If `name` is the path of an existing enum, that enum is returned.
 		
 		Otherwise null is returned.
 		
-		If [name] is null the result is unspecified.
+		If `name` is null the result is unspecified.
 		
-		If [name] is the path to a different type, null is returned.
+		If `name` is the path to a different type, null is returned.
 		
 		The enum name must not include any type parameters.
 	**/
 	public static function resolveEnum( name : String ) : Enum<Dynamic>;
 
 	/**
-		Creates an instance of class [cl], using [args] as arguments to the
+		Creates an instance of class `cl`, using `args` as arguments to the
 		class constructor.
 		
 		This function guarantees that the class constructor is called.
@@ -149,9 +148,9 @@ extern class Type {
 		Default values of constructors arguments are not guaranteed to be
 		taken into account.
 		
-		If [cl] or [args] are null, or if the number of elements in [args] does
+		If `cl` or `args` are null, or if the number of elements in `args` does
 		not match the expected number of constructor arguments, or if any
-		argument has an invalid type,  or if [cl] has no own constructor, the
+		argument has an invalid type,  or if `cl` has no own constructor, the
 		result is unspecified.
 		
 		In particular, default values of constructor arguments are not
@@ -160,41 +159,41 @@ extern class Type {
 	public static function createInstance<T>( cl : Class<T>, args : Array<Dynamic> ) : T;
 	
 	/**
-		Creates an instance of class [cl].
+		Creates an instance of class `cl`.
 		
 		This function guarantees that the class constructor is not called.
 		
-		If [cl] is null, the result is unspecified.
+		If `cl` is null, the result is unspecified.
 	**/
 	public static function createEmptyInstance<T>( cl : Class<T> ) : T;
 
 	/**
-		Creates an instance of enum [e] by calling its constructor [constr] with
-		arguments [params].
+		Creates an instance of enum `e` by calling its constructor `constr` with
+		arguments `params`.
 		
-		If [e] or [constr] is null, or if enum [e] has no constructor named
-		[constr], or if the number of elements in [params] does not match the
+		If `e` or `constr` is null, or if enum `e` has no constructor named
+		`constr`, or if the number of elements in `params` does not match the
 		expected number of constructor arguments, or if any argument has an
 		invalid type, the result is unspecified.
 	**/
 	public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T;
 
 	/**
-		Creates an instance of enum [e] by calling its constructor number
-		[index] with arguments [params].
+		Creates an instance of enum `e` by calling its constructor number
+		`index` with arguments `params`.
 		
 		The constructor indices are preserved from haxe syntax, so the first
 		declared is index 0, the next index 1 etc.
 		
-		If [e] or [constr] is null, or if enum [e] has no constructor named
-		[constr], or if the number of elements in [params] does not match the
+		If `e` or `constr` is null, or if enum `e` has no constructor named
+		`constr`, or if the number of elements in `params` does not match the
 		expected number of constructor arguments, or if any argument has an
 		invalid type, the result is unspecified.
 	**/
 	public static function createEnumIndex<T>( e : Enum<T>, index : Int, ?params : Array<Dynamic> ) : T;
 
 	/**
-		Returns a list of the instance fields of class [c].
+		Returns a list of the instance fields of class `c`.
 		
 		This only includes fields which are known at compile-time. In
 		particular, using getInstanceFields(getClass(obj)) will not include
@@ -202,97 +201,97 @@ extern class Type {
 		
 		The order of the fields in the returned Array is unspecified.
 		
-		If [c] is null, the result is unspecified.
+		If `c` is null, the result is unspecified.
 		
 		(As3) This method only returns instance fields that are public.
 	**/
 	public static function getInstanceFields( c : Class<Dynamic> ) : Array<String>;
 
 	/**
-		Returns a list of static fields of class [c].
+		Returns a list of static fields of class `c`.
 		
 		This does not include static fields of parent classes.
 		
 		The order of the fields in the returned Array is unspecified.
 		
-		If [c] is null, the result is unspecified.
+		If `c` is null, the result is unspecified.
 		
 		(As3) This method only returns class fields that are public.
 	**/
 	public static function getClassFields( c : Class<Dynamic> ) : Array<String>;
 
 	/**
-		Returns a list of the names of all constructors of enum [e].
+		Returns a list of the names of all constructors of enum `e`.
 		
 		The order of the constructor names in the returned Array is preserved
 		from the original syntax.
 		
-		If [c] is null, the result is unspecified.
+		If `c` is null, the result is unspecified.
 	**/
 	public static function getEnumConstructs( e : Enum<Dynamic> ) : Array<String>;
 
 	/**
-		Returns the runtime type of value [v].
+		Returns the runtime type of value `v`.
 		
-		The result corresponds to the type [v] has at runtime, which may vary
+		The result corresponds to the type `v` has at runtime, which may vary
 		per platform. Assumptions regarding this should be minimized to avoid
 		surprises.
 	**/
 	public static function typeof( v : Dynamic ) : ValueType;
 
 	/**
-		Recursively compares two enum instances [a] and [b] by value.
+		Recursively compares two enum instances `a` and `b` by value.
 		
-		Unlike [a] == [b], this function performs a deep equality check on the
+		Unlike `a == b`, this function performs a deep equality check on the
 		arguments of the constructors, if exists.
 		
-		If [a] or [b] are null, the result is unspecified.
+		If `a` or `b` are null, the result is unspecified.
 	**/
 	public static function enumEq<T:EnumValue>( a : T, b : T ) : Bool;
 
 	/**
-		Returns the constructor name of enum instance [e].
+		Returns the constructor name of enum instance `e`.
 		
 		The result String does not contain any constructor arguments.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 	**/
 	public static function enumConstructor( e : EnumValue ) : String;
 
 	/**
-		Returns a list of the constructor arguments of enum instance [e].
+		Returns a list of the constructor arguments of enum instance `e`.
 		
-		If [e] has no arguments, the result is [].
+		If `e` has no arguments, the result is [].
 		
-		Otherwise the result are the values that were used as arguments to [e],
+		Otherwise the result are the values that were used as arguments to `e`,
 		in the order of their declaration.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 	**/
 	public static function enumParameters( e : EnumValue ) : Array<Dynamic>;
 
 	/**
-		Returns the index of enum instance [e].
+		Returns the index of enum instance `e`.
 		
-		This corresponds to the original syntactic position of [e]. The index of
+		This corresponds to the original syntactic position of `e`. The index of
 		the first declared constructor is 0, the next one is 1 etc.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 	**/
 	public static function enumIndex( e : EnumValue ) : Int;
 
 	/**
-		Returns a list of all constructors of enum [e] that require no
+		Returns a list of all constructors of enum `e` that require no
 		arguments.
 		
-		This may return the empty Array [] if all constructors of [e] require
+		This may return the empty Array [] if all constructors of `e` require
 		arguments.
 		
-		Otherwise an instance of [e] constructed through each of its non-
+		Otherwise an instance of `e` constructed through each of its non-
 		argument constructors is returned, in the order of the constructor
 		declaration.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 	**/
 	public static function allEnums<T>( e : Enum<T> ) : Array<T>;
 

+ 2 - 2
std/Xml.hx

@@ -21,8 +21,8 @@
  */
 /**
 	An abstract type representing the type of the Xml
-	Node. You can compare it to [Xml] statics and can
-	use [Std.string(t)] to get a string reprensation
+	Node. You can compare it to `Xml` statics and can
+	use `Std.string` to get a string reprensation
 	of the type.
 **/
 

+ 8 - 0
std/cpp/_std/StringBuf.hx

@@ -24,10 +24,18 @@ class StringBuf {
 
 	private var b : Array<String>;
 
+	public var length(get,never) : Int;
+
 	public function new() : Void {
 		b = new Array();
 	}
 
+	function get_length() : Int {
+		var len = 0;
+		for(s in b) len += s.length;
+		return len;
+	}
+
 	public function add( x : Dynamic ) : Void {
 		b.push(x);
 	}

+ 0 - 10
std/cpp/_std/haxe/ds/StringMap.hx

@@ -44,18 +44,12 @@ package haxe.ds;
 		return untyped __global__.__hxcpp_anon_remove(__Internal,key);
 	}
 
-	/**
-		Returns an iterator of all keys in the hashtable.
-	**/
 	public function keys() : Iterator<String> {
 		var a:Array<String> = [];
 		untyped __Internal.__GetFields(a);
 		return a.iterator();
 	}
 
-	/**
-		Returns an iterator of all values in the hashtable.
-	**/
 	public function iterator() : Iterator<T> {
 		var a:Array<String> = [];
 		untyped __Internal.__GetFields(a);
@@ -67,10 +61,6 @@ package haxe.ds;
 		};
 	}
 
-	/**
-		Returns an displayable representation of the hashtable content.
-	**/
-
 	public function toString() : String {
 		var s = new StringBuf();
 		s.add("{");

+ 5 - 5
std/cpp/_std/sys/FileSystem.hx

@@ -34,9 +34,9 @@ class FileSystem {
 		return sys_exists(path);
 	}
 
-	public static function rename( path : String, newpath : String ) : Void {
-		if (sys_rename(path,newpath)==null)
-         throw "Could not rename:" + path + " to " + newpath;
+	public static function rename( path : String, newPath : String ) : Void {
+		if (sys_rename(path,newPath)==null)
+         throw "Could not rename:" + path + " to " + newPath;
 	}
 
 	public static function stat( path : String ) : FileStat {
@@ -49,8 +49,8 @@ class FileSystem {
 		return s;
 	}
 
-	public static function fullPath( relpath : String ) : String {
-		return new String(file_full_path(relpath));
+	public static function fullPath( relPath : String ) : String {
+		return new String(file_full_path(relPath));
 	}
 
 	static function kind( path : String ) : FileKind {

+ 3 - 3
std/cpp/_std/sys/io/File.hx

@@ -58,9 +58,9 @@ class File {
 		return untyped new FileOutput(file_open(path,(if( binary ) "ab" else "a")));
 	}
 
-	public static function copy( src : String, dst : String ) : Void {
-		var s = read(src,true);
-		var d = write(dst,true);
+	public static function copy( srcPath : String, dstPath : String ) : Void {
+		var s = read(srcPath,true);
+		var d = write(dstPath,true);
 		d.writeInput(s);
 		s.close();
 		d.close();

+ 1 - 0
std/cs/StringBuilder.hx

@@ -25,6 +25,7 @@ package cs;
 //Once this bug is fixed, it will be moved back to the cs.system.text package
 @:native('System.Text.StringBuilder') extern class StringBuilder 
 {
+	var Length(default,never):Int;
 
 	function new():Void;
 	

+ 0 - 69
std/cs/_std/Array.hx

@@ -21,11 +21,6 @@
  */
 import cs.NativeArray;
 
-/**
-	An Array is a storage for values. You can access it using indexes or
-	with its API. On the server side, it's often better to use a [List] which
-	is less memory and CPU consuming, unless you really need indexed access.
-**/
 @:classCode('
 	public Array(T[] native)
 	{
@@ -35,9 +30,6 @@ import cs.NativeArray;
 ')
 @:final @:coreApi class Array<T> implements ArrayAccess<T> {
 
-	/**
-		The length of the Array
-	**/
 	public var length(default,null) : Int;
 
 	private var __a:NativeArray<T>;
@@ -58,18 +50,12 @@ import cs.NativeArray;
 		return null;
 	}
 
-	/**
-		Creates a new Array.
-	**/
 	public function new() : Void
 	{
 		this.length = 0;
 		this.__a = new NativeArray(0);
 	}
 
-	/**
-		Returns a new Array by appending [a] to [this].
-	**/
 	public function concat( a : Array<T> ) : Array<T>
 	{
 		var len = length + a.length;
@@ -98,9 +84,6 @@ import cs.NativeArray;
 		this.length = len;
 	}
 
-	/**
-		Returns a representation of an array with [sep] for separating each element.
-	**/
 	public function join( sep : String ) : String
 	{
 		var buf = new StringBuf();
@@ -120,9 +103,6 @@ import cs.NativeArray;
 		return buf.toString();
 	}
 
-	/**
-		Removes the last element of the array and returns it.
-	**/
 	public function pop() : Null<T>
 	{
 		var __a = __a;
@@ -139,9 +119,6 @@ import cs.NativeArray;
 		}
 	}
 
-	/**
-		Adds the element [x] at the end of the array.
-	**/
 	public function push(x : T) : Int
 	{
 		if (length >= __a.Length)
@@ -157,9 +134,6 @@ import cs.NativeArray;
 		return ++length;
 	}
 
-	/**
-		Reverse the order of elements of the Array.
-	**/
 	public function reverse() : Void
 	{
 		var i = 0;
@@ -176,9 +150,6 @@ import cs.NativeArray;
 		}
 	}
 
-	/**
-		Removes the first element and returns it.
-	**/
 	public function shift() : Null<T>
 	{
 		var l = this.length;
@@ -195,12 +166,6 @@ import cs.NativeArray;
 		return x;
 	}
 
-	/**
-		Copies the range of the array starting at [pos] up to,
-		but not including, [end]. Both [pos] and [end] can be
-		negative to count from the end: -1 is the last item in
-		the array.
-	**/
 	public function slice( pos : Int, ?end : Int ) : Array<T>
 	{
 		if( pos < 0 ){
@@ -223,11 +188,6 @@ import cs.NativeArray;
 		return ofNative(newarr);
 	}
 
-	/**
-		Sort the Array according to the comparison public function [f].
-		[f(x,y)] should return [0] if [x == y], [>0] if [x > y]
-		and [<0] if [x < y].
-	**/
 	public function sort( f : T -> T -> Int ) : Void
 	{
 		if (length == 0)
@@ -235,10 +195,6 @@ import cs.NativeArray;
 		quicksort(0, length - 1, f);
 	}
 
-	/**
-		quicksort author: tong disktree
-		http://blog.disktree.net/2008/10/26/array-sort-performance.html
-	 */
 	private function quicksort( lo : Int, hi : Int, f : T -> T -> Int ) : Void
 	{
         var buf = __a;
@@ -260,9 +216,6 @@ import cs.NativeArray;
         if( i < hi ) quicksort( i, hi, f );
 	}
 
-	/**
-		Removes [len] elements starting from [pos] an returns them.
-	**/
 	public function splice( pos : Int, len : Int ) : Array<T>
 	{
 		if( len < 0 ) return new Array();
@@ -314,9 +267,6 @@ import cs.NativeArray;
 			a[this.length + len] = null;
 	}
 
-	/**
-		Returns a displayable representation of the Array content.
-	**/
 	public function toString() : String
 	{
 		var ret = new StringBuf();
@@ -336,9 +286,6 @@ import cs.NativeArray;
 		return ret.toString();
 	}
 
-	/**
-		Adds the element [x] at the start of the array.
-	**/
 	public function unshift( x : T ) : Void
 	{
 		var __a = __a;
@@ -358,10 +305,6 @@ import cs.NativeArray;
 		++this.length;
 	}
 
-	/**
-		Inserts the element [x] at the position [pos].
-		All elements after [pos] are moved one index ahead.
-	**/
 	public function insert( pos : Int, x : T ) : Void
 	{
 		var l = this.length;
@@ -396,11 +339,6 @@ import cs.NativeArray;
 		}
 	}
 
-	/**
-		Removes the first occurence of [x].
-		Returns false if [x] was not present.
-		Elements are compared by using standard equality.
-	**/
 	public function remove( x : T ) : Bool
 	{
 		var __a = __a;
@@ -435,10 +373,6 @@ import cs.NativeArray;
 		return ret;
 	}
 
-	/**
-		Returns a copy of the Array. The values are not
-		copied, only the Array structure.
-	**/
 	public function copy() : Array<T>
 	{
 		var len = length;
@@ -448,9 +382,6 @@ import cs.NativeArray;
 		return ofNative(newarr);
 	}
 
-	/**
-		Returns an iterator of the Array values.
-	**/
 	public function iterator() : Iterator<T>
 	{
 		var i = 0;

+ 0 - 47
std/cs/_std/Date.hx

@@ -27,9 +27,6 @@ import haxe.Int64;
 {
 	private var date:DateTime;
 
-	/**
-		Creates a new date object.
-	**/
 	public function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void
 	{
 		if (day <= 0) day = 1;
@@ -37,77 +34,46 @@ import haxe.Int64;
 		date = new DateTime(year, month + 1, day, hour, min, sec);
 	}
 
-	/**
-		Returns the timestamp of the date. It's the number of milliseconds
-		elapsed since 1st January 1970. It might only have a per-second precision
-		depending on the platforms.
-	**/
 	public inline function getTime() : Float
 	{
 		return (cast(date.Ticks, Float) / TimeSpan.TicksPerMillisecond);
 	}
 
-	/**
-		Returns the hours value of the date (0-23 range).
-	**/
 	public inline function getHours() : Int
 	{
 		return date.Hour;
 	}
 
-	/**
-		Returns the minutes value of the date (0-59 range).
-	**/
 	public inline function getMinutes() : Int
 	{
 		return date.Minute;
 	}
 
-	/**
-		Returns the seconds of the date (0-59 range).
-	**/
 	public inline function getSeconds() : Int
 	{
 		return date.Second;
 	}
 
-	/**
-		Returns the full year of the date.
-	**/
 	public inline function getFullYear() : Int
 	{
 		return date.Year;
 	}
 
-	/**
-		Returns the month of the date (0-11 range).
-	**/
 	public inline function getMonth() : Int
 	{
 		return date.Month - 1;
 	}
 
-	/**
-		Returns the day of the date (1-31 range).
-	**/
 	public inline function getDate() : Int
 	{
 		return date.Day;
 	}
 
-	/**
-		Returns the week day of the date (0-6 range).
-	**/
 	public inline function getDay() : Int
 	{
 		return cast(date.DayOfWeek, Int);
 	}
 
-	/**
-		Returns a string representation for the Date, by using the
-		standard format [YYYY-MM-DD HH:MM:SS]. See [DateTools.format] for
-		other formating rules.
-	**/
 	public function toString():String
 	{
 		var m = getMonth() + 1;
@@ -123,9 +89,6 @@ import haxe.Int64;
 			+":"+(if( s < 10 ) "0"+s else ""+s);
 	}
 
-	/**
-		Returns a Date representing the current local time.
-	**/
 	static public function now() : Date
 	{
 		var d = new Date(0, 0, 0, 0, 0, 0);
@@ -133,10 +96,6 @@ import haxe.Int64;
 		return d;
 	}
 
-	/**
-		Returns a Date from a timestamp [t] which is the number of
-		milliseconds elapsed since 1st January 1970.
-	**/
 	static public function fromTime( t : Float ) : Date
 	{
 		var d = new Date(0, 0, 0, 0, 0, 0);
@@ -144,12 +103,6 @@ import haxe.Int64;
 		return d;
 	}
 
-
-	/**
-		Returns a Date from a formated string of one of the following formats :
-		[YYYY-MM-DD hh:mm:ss] or [YYYY-MM-DD] or [hh:mm:ss]. The first two formats
-		are expressed in local time, the third in UTC Epoch.
-	**/
 	static public function fromString( s : String ) : Date
 	{
 		switch( s.length )

+ 3 - 3
std/cs/_std/EReg.hx

@@ -21,7 +21,7 @@
  */
 import cs.system.text.regularExpressions.Regex;
 
-class EReg {
+@:coreApi class EReg {
 
 	private var regex : Regex;
 	private var m : Match;
@@ -86,12 +86,12 @@ class EReg {
 		return untyped [s.Substring(0, m.Index), s.Substring(m.Index + m.Length)];
 	}
 
-	inline function start(group:Int)
+	inline function start(group:Int) : Int
 	{
 		return m.Groups[group].Index;
 	}
 
-	inline function len(group:Int)
+	inline function len(group:Int) : Int
 	{
 		return m.Groups[group].Length;
 	}

+ 1 - 50
std/cs/_std/Reflect.hx

@@ -21,7 +21,7 @@
  */
 import cs.internal.Function;
 /*
- * Copyright (c) 2005, The haXe Project Contributors
+ * Copyright (c) 2005, The Haxe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -45,15 +45,8 @@ import cs.internal.Function;
  * DAMAGE.
  */
 
-/**
-	The Reflect API is a way to manipulate values dynamicly through an
-	abstract interface in an untyped manner. Use with care.
-**/
 @:keep @:coreApi class Reflect {
 
-	/**
-		Tells if an object has a field set. This doesn't take into account the object prototype (class methods).
-	**/
 	@:functionCode('
 		if (o is haxe.lang.IHxObject)
 			return ((haxe.lang.IHxObject) o).__hx_getField(field, haxe.lang.FieldLookup.hash(field), false, true, false) != haxe.lang.Runtime.undefined;
@@ -65,9 +58,6 @@ import cs.internal.Function;
 		return false;
 	}
 
-	/**
-		Returns the field of an object, or null if [o] is not an object or doesn't have this field.
-	**/
 	@:functionCode('
 		if (o is haxe.lang.IHxObject)
 			return ((haxe.lang.IHxObject) o).__hx_getField(field, haxe.lang.FieldLookup.hash(field), false, false, false);
@@ -79,10 +69,6 @@ import cs.internal.Function;
 		return null;
 	}
 
-
-	/**
-		Set an object field value.
-	**/
 	@:functionCode('
 		if (o is haxe.lang.IHxObject)
 			((haxe.lang.IHxObject) o).__hx_setField(field, haxe.lang.FieldLookup.hash(field), value, false);
@@ -94,9 +80,6 @@ import cs.internal.Function;
 
 	}
 
-	/**
-		Similar to field but also supports property (might be slower).
-	**/
 	@:functionCode('
 		if (o is haxe.lang.IHxObject)
 			return ((haxe.lang.IHxObject) o).__hx_getField(field, haxe.lang.FieldLookup.hash(field), false, false, true);
@@ -111,9 +94,6 @@ import cs.internal.Function;
 		return null;
 	}
 
-	/**
-		Similar to setField but also supports property (might be slower).
-	**/
 	@:functionCode('
 		if (o is haxe.lang.IHxObject)
 			((haxe.lang.IHxObject) o).__hx_setField(field, haxe.lang.FieldLookup.hash(field), value, true);
@@ -127,9 +107,6 @@ import cs.internal.Function;
 
 	}
 
-	/**
-		Call a method with the given object and arguments.
-	**/
 	@:functionCode('
 		return ((haxe.lang.Function) func).__hx_invokeDynamic(args);
 	')
@@ -138,9 +115,6 @@ import cs.internal.Function;
 		return null;
 	}
 
-	/**
-		Returns the list of fields of an object, excluding its prototype (class methods).
-	**/
 	@:functionCode('
 		if (o is haxe.lang.IHxObject)
 		{
@@ -158,9 +132,6 @@ import cs.internal.Function;
 		return null;
 	}
 
-	/**
-		Tells if a value is a function or not.
-	**/
 	@:functionCode('
 		return f is haxe.lang.Function;
 	')
@@ -169,9 +140,6 @@ import cs.internal.Function;
 		return false;
 	}
 
-	/**
-		Generic comparison function, does not work for methods, see [compareMethods]
-	**/
 	@:functionCode('
 		return haxe.lang.Runtime.compare(a, b);
 	')
@@ -180,9 +148,6 @@ import cs.internal.Function;
 		return 0;
 	}
 
-	/**
-		Compare two methods closures. Returns true if it's the same method of the same instance.
-	**/
 	@:functionCode('
 		if (f1 == f2)
 			return true;
@@ -202,10 +167,6 @@ import cs.internal.Function;
 		return false;
 	}
 
-	/**
-		Tells if a value is an object or not.
-
-	**/
 	@:functionCode('
 		return v != null && !(v is haxe.lang.Enum || v is haxe.lang.Function || v is System.ValueType);
 	')
@@ -224,9 +185,6 @@ import cs.internal.Function;
 		}
 	}
 
-	/**
-		Delete an object field.
-	**/
 	@:functionCode('
 		return (o is haxe.lang.DynamicObject && ((haxe.lang.DynamicObject) o).__hx_deleteField(field, haxe.lang.FieldLookup.hash(field)));
 	')
@@ -235,9 +193,6 @@ import cs.internal.Function;
 		return false;
 	}
 
-	/**
-		Make a copy of the fields of an object.
-	**/
 	public static function copy<T>( o : T ) : T
 	{
 		var o2 : Dynamic = {};
@@ -246,10 +201,6 @@ import cs.internal.Function;
 		return cast o2;
 	}
 
-	/**
-		Transform a function taking an array of arguments into a function that can
-		be called with any number of arguments.
-	**/
 	@:overload(function( f : Array<Dynamic> -> Void ) : Dynamic {})
 	public static function makeVarArgs( f : Array<Dynamic> -> Dynamic ) : Dynamic
 	{

+ 1 - 1
std/cs/_std/String.hx

@@ -21,7 +21,7 @@
  */
 import cs.StdTypes;
 
-@:coreType extern class String implements ArrayAccess<Char16> {
+@:coreApi extern class String implements ArrayAccess<Char16> {
 
 	private static function Compare(s1:String, s2:String):Int;
 

+ 6 - 0
std/cs/_std/StringBuf.hx

@@ -24,10 +24,16 @@ class StringBuf {
 
 	private var b : cs.StringBuilder;
 
+	public var length(get,never) : Int;
+
 	public function new() : Void {
 		b = new cs.StringBuilder();
 	}
 
+	inline function get_length() : Int {
+		return b.Length;
+	}
+
 	public inline function add( x : Dynamic ) : Void {
 		b.Append(Std.string(x));
 	}

+ 1 - 68
std/cs/_std/Sys.hx

@@ -23,7 +23,7 @@ import sys.io.Process;
 import cs.system.Environment;
 import cs.system.threading.Thread;
 /*
- * Copyright (c) 2005-2012, The haXe Project Contributors
+ * Copyright (c) 2005-2012, The Haxe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -47,33 +47,21 @@ import cs.system.threading.Thread;
  * DAMAGE.
  */
 
-/**
-	This class gives you access to many base functionalities of system platforms. Looks in [sys] sub packages for more system APIs.
-**/
 @:coreApi
 class Sys {
 	private static var _env:haxe.ds.StringMap<String>;
 	private static var _args:Array<String>;
 
-	/**
-		Print any value on the standard output.
-	**/
 	public static function print( v : Dynamic ) : Void
 	{
 		cs.system.Console.Write(v);
 	}
 
-	/**
-		Print any value on the standard output, followed by a newline
-	**/
 	public static function println( v : Dynamic ) : Void
 	{
 		cs.system.Console.WriteLine(v);
 	}
 
-	/**
-		Returns all the arguments that were passed by the commandline.
-	**/
 	public static function args() : Array<String>
 	{
 		if (_args == null)
@@ -85,17 +73,11 @@ class Sys {
 		return _args.copy();
 	}
 
-	/**
-		Returns the value of the given environment variable.
-	**/
 	public static function getEnv( s : String ) : String
 	{
 		return Environment.GetEnvironmentVariable(s);
 	}
 
-	/**
-		Set the value of the given environment variable.
-	**/
 	public static function putEnv( s : String, v : String ) : Void
 	{
 		Environment.SetEnvironmentVariable(s, v);
@@ -103,9 +85,6 @@ class Sys {
 			_env.set(s, v);
 	}
 
-	/**
-		Returns the whole environement variables.
-	**/
 	public static function environment() : haxe.ds.StringMap<String>
 	{
 		if (_env == null)
@@ -121,44 +100,27 @@ class Sys {
 		return _env;
 	}
 
-	/**
-		Suspend the current execution for the given time (in seconds).
-	**/
 	public static function sleep( seconds : Float ) : Void
 	{
 		Thread.Sleep( Std.int(seconds * 1000) );
 	}
 
-	/**
-		Change the current time locale, which will affect [DateTools.format] date formating.
-		Returns true if the locale was successfully changed
-	**/
 	public static function setTimeLocale( loc : String ) : Bool
 	{
 		//TODO C#
 		return false;
 	}
 
-	/**
-		Get the current working directory (usually the one in which the program was started)
-	**/
 	public static function getCwd() : String
 	{
 		return cs.system.io.Directory.GetCurrentDirectory();
 	}
 
-	/**
-		Change the current working directory.
-	**/
 	public static function setCwd( s : String ) : Void
 	{
 		cs.system.io.Directory.SetCurrentDirectory(s);
 	}
 
-	/**
-		Returns the name of the system you are running on. For instance :
-			"Windows", "Linux", "BSD" and "Mac" depending on your desktop OS.
-	**/
 	public static function systemName() : String
 	{
 		//doing a switch with strings since MacOS might not be available
@@ -175,11 +137,6 @@ class Sys {
 		}
 	}
 
-	/**
-		Run the given command with the list of arguments. The command output will be printed on the same output as the current process.
-		The current process will block until the command terminates and it will return the command result (0 if there was no error).
-		Read the [sys.io.Process] api for a more complete way to start background processes.
-	**/
 	public static function command( cmd : String, ?args : Array<String> ) : Int
 	{
 		var proc:Process = new Process(cmd, args == null ? [] : args);
@@ -189,42 +146,27 @@ class Sys {
 		return ret;
 	}
 
-	/**
-		Exit the current process with the given error code.
-	**/
 	public static function exit( code : Int ) : Void
 	{
 		Environment.Exit(code);
 	}
 
-	/**
-		Gives the most precise timestamp value (in seconds).
-	**/
 	public static function time() : Float
 	{
 		return Date.now().getTime() / 1000;
 	}
 
-	/**
-		Gives the most precise timestamp value (in seconds) but only account for the actual time spent running on the CPU for the current thread/process.
-	**/
 	public static function cpuTime() : Float
 	{
 		return Environment.TickCount / 1000;
 	}
 
-	/**
-		Returns the path to the current executable that we are running.
-	**/
 	public static function executablePath() : String
 	{
 		//TODO: add extern references
 		return untyped __cs__('System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase');
 	}
 
-	/**
-		Read a single input character from the standard input (without blocking) and returns it. Setting [echo] to true will also display it on the output.
-	**/
 	public static function getChar( echo : Bool ) : Int
 	{
 		#if !(Xbox || CF || MF) //Xbox, Compact Framework, Micro Framework
@@ -234,9 +176,6 @@ class Sys {
 		#end
 	}
 
-	/**
-		Returns the process standard input, from which you can read what user enters. Usually it will block until the user send a full input line. See [getChar] for an alternative.
-	**/
 	public static function stdin() : haxe.io.Input
 	{
 #if !(Xbox || CF || MF)
@@ -246,9 +185,6 @@ class Sys {
 #end
 	}
 
-	/**
-		Returns the process standard output on which you can write.
-	**/
 	public static function stdout() : haxe.io.Output
 	{
 #if !(Xbox || CF || MF)
@@ -258,9 +194,6 @@ class Sys {
 #end
 	}
 
-	/**
-		Returns the process standard error on which you can write.
-	**/
 	public static function stderr() : haxe.io.Output
 	{
 #if !(Xbox || CF || MF)

+ 1 - 1
std/cs/_std/Type.hx

@@ -23,7 +23,7 @@ import cs.Lib;
 import cs.internal.HxObject;
 import cs.internal.Runtime;
 /*
- * Copyright (c) 2005, The haXe Project Contributors
+ * Copyright (c) 2005, The Haxe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:

+ 1 - 4
std/cs/_std/haxe/Int64.hx

@@ -129,10 +129,7 @@ using haxe.Int64;
 	{
 		return cast (a.asNative() - b.asNative());
 	}
-
-	/**
-		Compare two Int64 in unsigned mode.
-	**/
+	
 	public static function ucompare( a : Int64, b : Int64 ) : Int
 	{
 		if (a.asNative() < 0.mkNative())

+ 1 - 1
std/cs/_std/haxe/ds/IntMap.hx

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, The haXe Project Contributors
+ * Copyright (c) 2005, The Haxe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:

+ 4 - 34
std/cs/_std/sys/FileSystem.hx

@@ -25,31 +25,19 @@ import cs.system.io.File;
 import cs.system.io.Directory;
 import cs.system.io.FileInfo;
 
-/**
-	This class allows you to get informations about the files and directories.
-**/
 @:coreApi
 class FileSystem {
 
-	/**
-		Tells if the given file or directory exists.
-	**/
 	public static function exists( path : String ) : Bool
 	{
 		return (File.Exists(path) || Directory.Exists(path));
 	}
 
-	/**
-		Rename the corresponding file or directory, allow to move it accross directories as well.
-	**/
-	public static function rename( path : String, newpath : String ) : Void
+	public static function rename( path : String, newPath : String ) : Void
 	{
-		Directory.Move(path, newpath);
+		Directory.Move(path, newPath);
 	}
 
-	/**
-		Returns informations for the given file/directory.
-	**/
 	public static function stat( path : String ) : FileStat
 	{
 		if (File.Exists(path))
@@ -89,17 +77,11 @@ class FileSystem {
 
 	}
 
-	/**
-		Returns the full path for the given path which is relative to the current working directory.
-	**/
-	public static function fullPath( relpath : String ) : String
+	public static function fullPath( relPath : String ) : String
 	{
-		return new FileInfo(relpath).FullName;
+		return new FileInfo(relPath).FullName;
 	}
 
-	/**
-		Tells if the given path is a directory. Throw an exception if it does not exists or is not accesible.
-	**/
 	public static function isDirectory( path : String ) : Bool
 	{
 		var isdir = Directory.Exists(path);
@@ -108,33 +90,21 @@ class FileSystem {
 		throw "Path '" + path + "' doesn't exist";
 	}
 
-	/**
-		Create the given directory. Not recursive : the parent directory must exists.
-	**/
 	public static function createDirectory( path : String ) : Void
 	{
 		Directory.CreateDirectory(path);
 	}
 
-	/**
-		Delete a given file.
-	**/
 	public static function deleteFile( path : String ) : Void
 	{
 		File.Delete(path);
 	}
 
-	/**
-		Delete a given directory.
-	**/
 	public static function deleteDirectory( path : String ) : Void
 	{
 		Directory.Delete(path);
 	}
 
-	/**
-		Read all the files/directories stored into the given directory.
-	**/
 	public static function readDirectory( path : String ) : Array<String>
 	{
 		var ret = Directory.GetFileSystemEntries(path);

+ 2 - 5
std/cs/_std/sys/io/File.hx

@@ -21,9 +21,6 @@
  */
 package sys.io;
 
-/**
-	API for reading and writing to files.
-**/
 @:coreApi
 class File {
 
@@ -87,8 +84,8 @@ class File {
 		return new FileOutput(stream);
 	}
 
-	public static function copy( src : String, dst : String ) : Void
+	public static function copy( srcPath : String, dstPath : String ) : Void
 	{
-		cs.system.io.File.Copy(src, dst);
+		cs.system.io.File.Copy(srcPath, dstPath);
 	}
 }

+ 0 - 3
std/cs/_std/sys/io/FileInput.hx

@@ -21,9 +21,6 @@
  */
 package sys.io;
 
-/**
-	Use [sys.io.File.read] to create a [FileInput]
-**/
 class FileInput extends cs.io.NativeInput {
 	public function new(stream:cs.system.io.FileStream)
 	{

+ 0 - 3
std/cs/_std/sys/io/FileOutput.hx

@@ -21,9 +21,6 @@
  */
 package sys.io;
 
-/**
-	Use [sys.io.File.write] to create a [FileOutput]
-**/
 class FileOutput extends cs.io.NativeOutput {
 	public function new(stream:cs.system.io.FileStream)
 	{

+ 1 - 1
std/haxe/CallStack.hx

@@ -22,7 +22,7 @@
 package haxe;
 
 /**
-	Elements return by [Stack] methods.
+	Elements return by `CallStack` methods.
 **/
 enum StackItem {
 	CFunction;

+ 10 - 10
std/haxe/EnumFlags.hx

@@ -34,43 +34,43 @@ package haxe;
 abstract EnumFlags<T:EnumValue>(Int) {
 
 	/**
-		Initializes the bitflags to [i].
+		Initializes the bitflags to `i`.
 	**/
 	public inline function new(i = 0) {
 		this = i;
 	}
 
 	/**
-		Checks if the index of enum instance [v] is set.
+		Checks if the index of enum instance `v` is set.
 		
-		This method is optimized if [v] is an enum instance expression such as
+		This method is optimized if `v` is an enum instance expression such as
 		SomeEnum.SomeCtor.
 		
-		If [v] is null, the result is unspecified.
+		If `v` is null, the result is unspecified.
 	**/
 	public inline function has( v : T ) : Bool {
 		return this & (1 << Type.enumIndex(v)) != 0;
 	}
 
 	/**
-		Sets the index of enum instance [v].
+		Sets the index of enum instance `v`.
 		
-		This method is optimized if [v] is an enum instance expression such as
+		This method is optimized if `v` is an enum instance expression such as
 		SomeEnum.SomeCtor.
 		
-		If [v] is null, the result is unspecified.
+		If `v` is null, the result is unspecified.
 	**/
 	public inline function set( v : T ) : Void {
 		this |= 1 << Type.enumIndex(v);
 	}
 
 	/**
-		Unsets the index of enum instance [v].
+		Unsets the index of enum instance `v`.
 		
-		This method is optimized if [v] is an enum instance expression such as
+		This method is optimized if `v` is an enum instance expression such as
 		SomeEnum.SomeCtor.
 		
-		If [v] is null, the result is unspecified.
+		If `v` is null, the result is unspecified.
 	**/
 	public inline function unset( v : T ) : Void {
 		this &= 0xFFFFFFF - (1 << Type.enumIndex(v));

+ 31 - 31
std/haxe/EnumTools.hx

@@ -24,17 +24,17 @@ package haxe;
 
 extern class EnumTools {
 	/**
-		Returns the name of enum [e], including its path.
+		Returns the name of enum `e`, including its path.
 		
-		If [e] is inside a package, the package structure is returned dot-
+		If `e` is inside a package, the package structure is returned dot-
 		separated, with another dot separating the enum name:
 			pack1.pack2.(...).packN.EnumName
-		If [e] is a sub-type of a haxe module, that module is not part of the
+		If `e` is a sub-type of a haxe module, that module is not part of the
 		package structure.
 			
-		If [e] has no package, the enum name is returned.
+		If `e` has no package, the enum name is returned.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 		
 		The enum name does not include any type parameters.
 	**/
@@ -43,11 +43,11 @@ extern class EnumTools {
 	}
 		
 	/**
-		Creates an instance of enum [e] by calling its constructor [constr] with
-		arguments [params].
+		Creates an instance of enum `e` by calling its constructor `constr` with
+		arguments `params`.
 		
-		If [e] or [constr] is null, or if enum [e] has no constructor named
-		[constr], or if the number of elements in [params] does not match the
+		If `e` or `constr` is null, or if enum `e` has no constructor named
+		`constr`, or if the number of elements in `params` does not match the
 		expected number of constructor arguments, or if any argument has an
 		invalid type, the result is unspecified.
 	**/
@@ -56,14 +56,14 @@ extern class EnumTools {
 	}
 	
 	/**
-		Creates an instance of enum [e] by calling its constructor number
-		[index] with arguments [params].
+		Creates an instance of enum `e` by calling its constructor number
+		`index` with arguments `params`.
 		
 		The constructor indices are preserved from haxe syntax, so the first
 		declared is index 0, the next index 1 etc.
 		
-		If [e] or [constr] is null, or if enum [e] has no constructor named
-		[constr], or if the number of elements in [params] does not match the
+		If `e` or `constr` is null, or if enum `e` has no constructor named
+		`constr`, or if the number of elements in `params` does not match the
 		expected number of constructor arguments, or if any argument has an
 		invalid type, the result is unspecified.
 	**/
@@ -72,29 +72,29 @@ extern class EnumTools {
 	}
 		
 	/**
-		Returns a list of all constructors of enum [e] that require no
+		Returns a list of all constructors of enum `e` that require no
 		arguments.
 		
-		This may return the empty Array [] if all constructors of [e] require
+		This may return the empty Array [] if all constructors of `e` require
 		arguments.
 		
-		Otherwise an instance of [e] constructed through each of its non-
+		Otherwise an instance of `e` constructed through each of its non-
 		argument constructors is returned, in the order of the constructor
 		declaration.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 	**/
 	static public inline function createAll<T>(e:Enum<T>):Array<T> {
 		return Type.allEnums(e);
 	}
 		
 	/**
-		Returns a list of the names of all constructors of enum [e].
+		Returns a list of the names of all constructors of enum `e`.
 		
 		The order of the constructor names in the returned Array is preserved
 		from the original syntax.
 		
-		If [c] is null, the result is unspecified.
+		If `c` is null, the result is unspecified.
 	**/
 	static public inline function getConstructors<T>(e:Enum<T>):Array<String> {
 		return Type.getEnumConstructs(e);
@@ -104,49 +104,49 @@ extern class EnumTools {
 extern class EnumValueTools {
 	
 	/**
-		Recursively compares two enum instances [a] and [b] by value.
+		Recursively compares two enum instances `a` and `b` by value.
 		
-		Unlike [a] == [b], this function performs a deep equality check on the
+		Unlike `a == b`, this function performs a deep equality check on the
 		arguments of the constructors, if exists.
 		
-		If [a] or [b] are null, the result is unspecified.
+		If `a` or `b` are null, the result is unspecified.
 	**/
 	static public inline function equals<T:EnumValue>(a:T, b:T):Bool {
 		return Type.enumEq(a, b);
 	}
 		
 	/**
-		Returns the constructor name of enum instance [e].
+		Returns the constructor name of enum instance `e`.
 		
 		The result String does not contain any constructor arguments.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 	**/
 	static public inline function getName(e:EnumValue):String {
 		return Type.enumConstructor(e);
 	}
 		
 	/**
-		Returns a list of the constructor arguments of enum instance [e].
+		Returns a list of the constructor arguments of enum instance `e`.
 		
-		If [e] has no arguments, the result is [].
+		If `e` has no arguments, the result is [].
 		
-		Otherwise the result are the values that were used as arguments to [e],
+		Otherwise the result are the values that were used as arguments to `e`,
 		in the order of their declaration.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 	**/
 	static public inline function getParameters(e:EnumValue):Array<Dynamic> {
 		return Type.enumParameters(e);
 	}
 		
 	/**
-		Returns the index of enum instance [e].
+		Returns the index of enum instance `e`.
 		
-		This corresponds to the original syntactic position of [e]. The index of
+		This corresponds to the original syntactic position of `e`. The index of
 		the first declared constructor is 0, the next one is 1 etc.
 		
-		If [e] is null, the result is unspecified.
+		If `e` is null, the result is unspecified.
 	**/
 	static public inline function getIndex(e:EnumValue):Int {
 		return Type.enumIndex(e);

+ 25 - 24
std/haxe/Http.hx

@@ -41,15 +41,16 @@ private typedef AbstractSocket = {
 /**
 	This class can be used to handle Http requests consistently across
 	platforms. There are two intended usages:
+	
 	- call haxe.Http.requestUrl(url) and receive the result as a String (not
-		available on flash)
+	available on flash)
 	- create a new haxe.Http(url), register your callbacks for onData, onError
-		and onStatus, then call request().
+	and onStatus, then call request().
 **/
 class Http {
 
 	/**
-		The url of [this] request. It is used only by the request() method and
+		The url of `this` request. It is used only by the request() method and
 		can be changed in order to send the same request to different target
 		Urls.
 	**/
@@ -74,11 +75,11 @@ class Http {
 	#end
 
 	/**
-		Creates a new Http instance with [url] as parameter.
+		Creates a new Http instance with `url` as parameter.
 
 		This does not do a request until request() is called.
 
-		If [url] is null, the field url must be set to a value before making the
+		If `url` is null, the field url must be set to a value before making the
 		call to request(), or the result is unspecified.
 
 		(Php) Https (SSL) connections are allowed only if the OpenSSL extension
@@ -99,9 +100,9 @@ class Http {
 	}
 
 	/**
-		Sets the header identified as [header] to value [value].
+		Sets the header identified as `header` to value `value`.
 
-		If [header] or [value] are null, the result is unspecified.
+		If `header` or `value` are null, the result is unspecified.
 
 		This method provides a fluent interface.
 	**/
@@ -111,9 +112,9 @@ class Http {
 	}
 
 	/**
-		Sets the parameter identified as [param] to value [value].
+		Sets the parameter identified as `param` to value `value`.
 
-		If [header] or [value] are null, the result is unspecified.
+		If `header` or `value` are null, the result is unspecified.
 
 		This method provides a fluent interface.
 	**/
@@ -124,12 +125,12 @@ class Http {
 
 	#if !flash8
 	/**
-		Sets the post data of [this] Http request to [data].
+		Sets the post data of `this` Http request to `data`.
 
 		There can only be one post data per request. Subsequent calls overwrite
 		the previously set value.
 
-		If [data] is null, the post data is considered to be absent.
+		If `data` is null, the post data is considered to be absent.
 
 		This method provides a fluent interface.
 	**/
@@ -140,20 +141,20 @@ class Http {
 	#end
 
 	/**
-		Sends [this] Http request to the Url specified by [this].url.
+		Sends `this` Http request to the Url specified by `this.url`.
 
-		If [post] is true, the request is sent as POST request, otherwise it is
+		If `post` is true, the request is sent as POST request, otherwise it is
 		sent as GET request.
 
 		Depending on the outcome of the request, this method calls the
 		onStatus(), onError() or onData() callback functions.
 
-		If [this].url is null, the result is unspecified.
+		If `this.url` is null, the result is unspecified.
 
-		If [this].url is an invalid or inaccessible Url, the onError() callback
+		If `this.url` is an invalid or inaccessible Url, the onError() callback
 		function is called.
 
-		(Js) If [this].async is false, the callback functions are called before
+		(Js) If `this.async` is false, the callback functions are called before
 		this method returns.
 	**/
 	public function request( ?post : Bool ) : Void {
@@ -695,43 +696,43 @@ class Http {
 #end
 
 	/**
-		This method is called upon a successful request, with [data] containing
+		This method is called upon a successful request, with `data` containing
 		the result String.
 
 		The intended usage is to bind it to a custom function:
-			httpInstance.onData = function(data) { // handle result }
+		`httpInstance.onData = function(data) { // handle result }`
 	**/
 	public dynamic function onData( data : String ) {
 	}
 
 	/**
-		This method is called upon a request error, with [msg] containing the
+		This method is called upon a request error, with `msg` containing the
 		error description.
 
 		The intended usage is to bind it to a custom function:
-			httpInstance.onError = function(msg) { // handle error }
+		`httpInstance.onError = function(msg) { // handle error }`
 	**/
 	public dynamic function onError( msg : String ) {
 	}
 
 	/**
-		This method is called upon a Http status change, with [status] being the
+		This method is called upon a Http status change, with `status` being the
 		new status.
 
 		The intended usage is to bind it to a custom function:
-			httpInstance.onStatus = function(status) { // handle status }
+		`httpInstance.onStatus = function(status) { // handle status }`
 	**/
 	public dynamic function onStatus( status : Int ) {
 	}
 
 #if !flash
 	/**
-		Makes a synchronous request to [url].
+		Makes a synchronous request to `url`.
 
 		This creates a new Http instance and makes a GET request by calling its
 		request(false) method.
 
-		If [url] is null, the result is unspecified.
+		If `url` is null, the result is unspecified.
 	**/
 	public static function requestUrl( url : String ) : String {
 		var h = new Http(url);

+ 1 - 1
std/haxe/Json.hx

@@ -23,7 +23,7 @@ package haxe;
 
 /**
 	Crossplatform JSON API : it will automatically use the optimized native API if available.
-	Use -D haxeJSON to force usage of the haXe implementation even if a native API is found : this will provide
+	Use -D haxeJSON to force usage of the Haxe implementation even if a native API is found : this will provide
 	extra encoding features such as enums (replaced by their index), Hashs and Iterable.
 **/
 #if (flash11 && !haxeJSON)

+ 3 - 3
std/haxe/Log.hx

@@ -28,9 +28,9 @@ package haxe;
 class Log {
 
 	/**
-		Outputs [v] in a platform-dependent way.
+		Outputs `v` in a platform-dependent way.
 
-		The second parameter [infos] is injected by the compiler and contains
+		The second parameter `infos` is injected by the compiler and contains
 		information about the position where the trace() call was made.
 
 		This method can be rebound to a custom function:
@@ -112,7 +112,7 @@ class Log {
 
 	#if flash
 	/**
-		Sets the color of the trace output to [rgb].
+		Sets the color of the trace output to `rgb`.
 	**/
 	public static dynamic function setColor( rgb : Int ) {
 		untyped flash.Boot.__set_trace_color(rgb);

+ 4 - 4
std/haxe/Resource.hx

@@ -75,9 +75,9 @@ class Resource {
 	}
 
 	/**
-		Retrieves the resource identified by [name] as a String.
+		Retrieves the resource identified by `name` as a String.
 
-		If [name] does not match any resource name, null is returned.
+		If `name` does not match any resource name, null is returned.
 	**/
 	public static function getString( name : String ) : String {
 		#if java
@@ -107,10 +107,10 @@ class Resource {
 	}
 
 	/**
-		Retrieves the resource identified by [name] as an instance of
+		Retrieves the resource identified by `name` as an instance of
 		haxe.io.Bytes.
 
-		If [name] does not match any resource name, null is returned.
+		If `name` does not match any resource name, null is returned.
 	**/
 	public static function getBytes( name : String ) : haxe.io.Bytes {
 		#if java

+ 14 - 13
std/haxe/Serializer.hx

@@ -26,17 +26,18 @@ package haxe;
 	from which the Unserializer class can recreate the original representation.
 
 	This class can be used in two ways:
-		- create a new Serializer() instance, call its serialize() method with
+	
+	- create a new Serializer() instance, call its serialize() method with
 		any argument and finally retrieve the String representation from
 		toString()
-		- call Serializer.run() to obtain the serialized representation of a
+	- call Serializer.run() to obtain the serialized representation of a
 		single argument
 
 	Serialization is guaranteed to work for all haxe-defined classes, but may
 	or may not work for instances of external/native classes.
 
 	The specification of the serialization format can be found here:
-		http://haxe.org/manual/serialization/format
+	`http://haxe.org/manual/serialization/format`
 **/
 class Serializer {
 
@@ -73,14 +74,14 @@ class Serializer {
 	var scount : Int;
 
 	/**
-		The individual cache setting for [this] Serializer instance.
+		The individual cache setting for `this` Serializer instance.
 
 		See USE_CACHE for a complete description.
 	**/
 	public var useCache : Bool;
 
 	/**
-		The individual enum index setting for [this] Serializer instance.
+		The individual enum index setting for `this` Serializer instance.
 
 		See USE_ENUM_INDEX for a complete description.
 	**/
@@ -89,11 +90,11 @@ class Serializer {
 	/**
 		Creates a new Serializer instance.
 
-		Subsequent calls to [this].serialize() will append values to the
+		Subsequent calls to `this.serialize` will append values to the
 		internal buffer of this String. Once complete, the contents can be
-		retrieved through a call to [this].toString() .
+		retrieved through a call to `this.toString`.
 
-		Each Serializer instance maintains its own cache if [this].useCache is
+		Each Serializer instance maintains its own cache if this.useCache` is
 		true.
 	**/
 	public function new() {
@@ -106,7 +107,7 @@ class Serializer {
 	}
 
 	/**
-		Return the String representation of [this] Serializer.
+		Return the String representation of `this` Serializer.
 
 		The exact format specification can be found here:
 		http://haxe.org/manual/serialization/format
@@ -211,13 +212,13 @@ class Serializer {
 	}
 
 	/**
-		Serializes [v].
+		Serializes `v`.
 
 		All haxe-defined values and objects with the exception of functions can
 		be serialized. Serialization of external/native objects is not
 		guaranteed to work.
 
-		The values of [this].useCache and [this].useEnumIndex may affect
+		The values of `this.useCache` and `this.useEnumIndex` may affect
 		serialization output.
 	**/
 	public function serialize( v : Dynamic ) {
@@ -511,10 +512,10 @@ class Serializer {
 	}
 
 	/**
-		Serializes [v] and returns the String representation.
+		Serializes `v` and returns the String representation.
 
 		This is a convenience function for creating a new instance of
-		Serializer, serialize [v] into it and obtain the result through a call
+		Serializer, serialize `v` into it and obtain the result through a call
 		to toString().
 	**/
 	public static function run( v : Dynamic ) {

+ 9 - 9
std/haxe/Template.hx

@@ -70,14 +70,14 @@ class Template {
 	var buf : StringBuf;
 
 	/**
-		Creates a new Template instance from [str].
+		Creates a new Template instance from `str`.
 		
-		[str] is parsed into tokens, which are stored for internal use. This
+		`str` is parsed into tokens, which are stored for internal use. This
 		means that multiple execute() operations on a single Template instance
 		are more efficient than one execute() operations on multiple Template
 		instances.
 		
-		If [str] is null, the result is unspecified.
+		If `str` is null, the result is unspecified.
 	**/
 	public function new( str : String ) {
 		var tokens = parseTokens(str);
@@ -87,19 +87,19 @@ class Template {
 	}
 
 	/**
-		Executes [this] Template, taking into account [context] for
-		replacements and [macros] for callback functions.
+		Executes `this` Template, taking into account `context` for
+		replacements and `macros` for callback functions.
 		
-		If [context] has a field 'name', its value replaces all occurrences of
+		If `context` has a field 'name', its value replaces all occurrences of
 		::name:: in the Template. Otherwise Template.globals is checked instead,
 		If 'name' is not a field of that either, ::name:: is replaced with null.
 		
-		If [macros] has a field 'name', all occurrences of $$name(args) are
+		If `macros` has a field 'name', all occurrences of $$name(args) are
 		replaced with the result of calling that field. The first argument is
 		always the the resolve() method, followed by the given arguments.
-		If [macros] has no such field, the result is unspecified.
+		If `macros` has no such field, the result is unspecified.
 		
-		If [context] is null, the result is unspecified. If [macros] is null,
+		If `context` is null, the result is unspecified. If `macros` is null,
 		no macros are used.
 	**/
 	public function execute( context : Dynamic, ?macros : Dynamic ):String {

+ 19 - 19
std/haxe/Timer.hx

@@ -39,12 +39,12 @@ class Timer {
 	private var id : Null<Int>;
 
 	/**
-		Creates a new timer that will run every [time_ms] milliseconds.
+		Creates a new timer that will run every `time_ms` milliseconds.
 		
-		After creating the Timer instance, it calls [this].run() repeatedly,
-		with delays of [time_ms] milliseconds, until [this].stop() is called.
+		After creating the Timer instance, it calls `this].run` repeatedly,
+		with delays of `time_ms` milliseconds, until `this.stop` is called.
 		
-		The first invocation occurs after [time_ms] milliseconds, not
+		The first invocation occurs after `time_ms` milliseconds, not
 		immediately.
 		
 		The accuracy of this may be platform-dependent.
@@ -63,12 +63,12 @@ class Timer {
 	}
 
 	/**
-		Stops [this] Timer.
+		Stops `this` Timer.
 		
-		After calling this method, no additional invocations of [this].run()
+		After calling this method, no additional invocations of `this.run`
 		will occur.
 		
-		It is not possible to restart [this] Timer once stopped.
+		It is not possible to restart `this` Timer once stopped.
 	**/
 	public function stop() {
 		if( id == null )
@@ -84,28 +84,28 @@ class Timer {
 	}
 
 	/**
-		This method is invoked repeatedly on [this] Timer.
+		This method is invoked repeatedly on `this` Timer.
 		
 		It can be overridden in a subclass, or rebound directly to a custom
 		function:
 			var timer = new haxe.Timer(1000); // 1000ms delay
 			timer.run = function() { ... }
 			
-		Once bound, it can still be rebound to different functions until [this]
-		Timer is stopped through a call to [this].stop().
+		Once bound, it can still be rebound to different functions until `this`
+		Timer is stopped through a call to `this.stop`.
 	**/
 	public dynamic function run() {
-		trace("run");
+
 	}
 
 	/**
-		Invokes [f] after [time_ms] milliseconds.
+		Invokes `f` after `time_ms` milliseconds.
 		
 		This is a convenience function for creating a new Timer instance with
-		[time_ms] as argument, binding its run() method to [f] and then stopping
-		[this] Timer upon the first invocation.
+		`time_ms` as argument, binding its run() method to `f` and then stopping
+		`this` Timer upon the first invocation.
 		
-		If [f] is null, the result is unspecified.
+		If `f` is null, the result is unspecified.
 	**/
 	public static function delay( f : Void -> Void, time_ms : Int ) {
 		var t = new haxe.Timer(time_ms);
@@ -119,15 +119,15 @@ class Timer {
 	#end
 
 	/**
-		Measures the time it takes to execute [f], in seconds with fractions.
+		Measures the time it takes to execute `f`, in seconds with fractions.
 		
 		This is a convenience function for calculating the difference between
-		Timer.stamp() before and after the invocation of [f].
+		Timer.stamp() before and after the invocation of `f`.
 		
 		The difference is passed as argument to Log.trace(), with "s" appended
-		to denote the unit. The optional [pos] argument is passed through.
+		to denote the unit. The optional `pos` argument is passed through.
 		
-		If [f] is null, the result is unspecified.
+		If `f` is null, the result is unspecified.
 	**/
 	public static function measure<T>( f : Void -> T, ?pos : PosInfos ) : T {
 		var t0 = stamp();

+ 19 - 16
std/haxe/Unserializer.hx

@@ -21,6 +21,7 @@
  */
 package haxe;
 
+@:noDoc
 typedef TypeResolver = {
 	function resolveClass( name : String ) : Class<Dynamic>;
 	function resolveEnum( name : String ) : Enum<Dynamic>;
@@ -31,10 +32,11 @@ typedef TypeResolver = {
 	a serialization String and creates objects from the contained data.
 
 	This class can be used in two ways:
-		- create a new Unserializer() instance with a given serialization
+	
+	- create a new Unserializer() instance with a given serialization
 		String, then call its unserialize() method until all values are
 		extracted
-		- call Unserializer.run() to unserialize a single value from a given
+	- call Unserializer.run() to unserialize a single value from a given
 		String
 **/
 class Unserializer {
@@ -46,9 +48,10 @@ class Unserializer {
 		default, the haxe Type Api is used.
 
 		A type resolver must provide two methods:
-			resolveClass(name:String):Class<Dynamic> is called to determine a
+		
+		1. resolveClass(name:String):Class<Dynamic> is called to determine a
 				Class from a class name
-			resolveEnum(name:String):Enum<Dynamic> is called to determine an
+		2. resolveEnum(name:String):Enum<Dynamic> is called to determine an
 				Enum from an enum name
 
 		This value is applied when a new Unserializer instance is created.
@@ -86,10 +89,10 @@ class Unserializer {
 
 	/**
 		Creates a new Unserializer instance, with its internal buffer
-		initialized to [buf].
+		initialized to `buf`.
 
-		This does not parse [buf] immediately. It is parsed only when calls to
-		[this].unserialize are made.
+		This does not parse `buf` immediately. It is parsed only when calls to
+		`this.unserialize` are made.
 
 		Each Unserializer instance maintains its own cache.
 	**/
@@ -111,9 +114,9 @@ class Unserializer {
  	}
 
 	/**
-		Sets the type resolver of [this] Unserializer instance to [r].
+		Sets the type resolver of `this` Unserializer instance to `r`.
 
-		If [r] is null, a special resolver is used which returns null for all
+		If `r` is null, a special resolver is used which returns null for all
 		input values.
 
 		See DEFAULT_RESOLVER for more information on type resolvers.
@@ -129,7 +132,7 @@ class Unserializer {
 	}
 
 	/**
-		Gets the type resolver of [this] Unserializer instance.
+		Gets the type resolver of `this` Unserializer instance.
 
 		See DEFAULT_RESOLVER for more information on type resolvers.
 	**/
@@ -194,14 +197,14 @@ class Unserializer {
 	}
 
 	/**
-		Unserializes the next part of [this] Unserializer instance and returns
+		Unserializes the next part of `this` Unserializer instance and returns
 		the according value.
 
-		This function may call [this].resolver.resolveClass to determine a
-		Class from a String, and [this].resolver.resolveEnum to determine an
+		This function may call `this.resolver.resolveClass` to determine a
+		Class from a String, and `this.resolver.resolveEnum` to determine an
 		Enum from a String.
 
-		If [this] Unserializer instance contains no more or invalid data, an
+		If `this` Unserializer instance contains no more or invalid data, an
 		exception is thrown.
 
 		This operation may fail on structurally valid data if a type cannot be
@@ -421,10 +424,10 @@ class Unserializer {
  	}
 
 	/**
-		Unserializes [v] and returns the according value.
+		Unserializes `v` and returns the according value.
 
 		This is a convenience function for creating a new instance of
-		Unserializer with [v] as buffer and calling its unserialize() method
+		Unserializer with `v` as buffer and calling its unserialize() method
 		once.
 	**/
 	public static function run( v : String ) : Dynamic {

+ 3 - 3
std/haxe/Utf8.hx

@@ -51,7 +51,7 @@ class Utf8 {
 	}
 
 	/**
-		Call the [chars] function for each UTF8 char of the string.
+		Call the `chars` function for each UTF8 char of the string.
 	**/
 	public static function iter( s : String, chars : Int -> Void ) {
 		for( i in 0...s.length )
@@ -76,7 +76,7 @@ class Utf8 {
 	}
 
 	/**
-		Similar to [String.charCodeAt] but uses the UTF8 character position.
+		Similar to `String.charCodeAt` but uses the UTF8 character position.
 	**/
 	public static inline function charCodeAt( s : String, index : Int ) : Int {
 		return s.charCodeAt(index);
@@ -105,7 +105,7 @@ class Utf8 {
 	}
 
 	/**
-		This is similar to [String.substr] but the [pos] and [len] parts are considering UTF8 characters.
+		This is similar to `String.substr` but the `pos` and `len` parts are considering UTF8 characters.
 	**/
 	public static inline function sub( s : String, pos : Int, len : Int ) : String {
 		return s.substr(pos,len);

+ 8 - 7
std/haxe/ds/ArraySort.hx

@@ -23,21 +23,22 @@
 package haxe.ds;
 
 /**
-	ArraySort provides a stable implementation of merge sort through its sort()
-	method. It should be used instead of Array.sort() in cases where the order
+	ArraySort provides a stable implementation of merge sort through its `sort`
+	method. It should be used instead of `Array.sort` in cases where the order
 	of equal elements has to be retained on all targets.
 **/
 class ArraySort {
+	
 	/**
-		Sorts Array [a] according to the comparison function [cmp], where
-		[cmp(x,y)] returns 0 if x == y, a positive Int if x > y and a
-		negative Int if x < y.
+		Sorts Array `a` according to the comparison function `cmp`, where
+		`cmp(x,y)` returns 0 if `x == y`, a positive Int if `x > y` and a
+		negative Int if `x < y`.
 		
-		This operation modifies Array [a] in place.
+		This operation modifies Array `a` in place.
 		
 		This operation is stable: The order of equal elements is preserved.
 		
-		If [a] or [cmp] are null, the result is unspecified.
+		If `a` or `cmp` are null, the result is unspecified.
 	**/
 	static public function sort<T>(a:Array<T>, cmp:T -> T -> Int) {
 		rec(a, cmp, 0, a.length);

+ 64 - 10
std/haxe/ds/BalancedTree.hx

@@ -22,19 +22,46 @@
 
 package haxe.ds;
 
+/**
+	BalancedTree allows key-value mapping with arbitrary keys, as long as they
+	can be ordered. By default, `Reflect.compare` is used in the `compare`
+	method, which can be overridden in subclasses.
+	
+	Operations have a logarithmic average and worst-case cost.
+	
+	Iteration over keys and values, using `keys` and `iterator` respectively,
+	are in-order.
+**/
 class BalancedTree<K,V> {
 	var root:TreeNode<K,V>;
 	
+	/**
+		Creates a new BalancedTree, which is initially empty.
+	**/
 	public function new() { }
 	
-	public function set(k:K, v:V) {
-		root = setLoop(k, v, root);
+	/**
+		Binds `key` to `value`.
+		
+		If `key` is already bound to a value, that binding disappears.
+		
+		If `key` is null, the result is unspecified.
+	**/
+	public function set(key:K, value:V) {
+		root = setLoop(key, value, root);
 	}
 	
-	public function get(k:K):Null<V> {
+	/**
+		Returns the value `key` is bound to.
+		
+		If `key` is not bound to any value, `null` is returned.
+		
+		If `key` is null, the result is unspecified.
+	**/
+	public function get(key:K):Null<V> {
 		var node = root;
 		while (node != null) {
-			var c = compare(k, node.key);
+			var c = compare(key, node.key);
 			if (c == 0) return node.value;
 			if (c < 0) node = node.left;
 			else node = node.right;
@@ -42,9 +69,19 @@ class BalancedTree<K,V> {
 		return null;
 	}
 	
-	public function remove(k:K) {
+	/**
+		Removes the current binding of `key`.
+		
+		If `key` has no binding, `this` BalancedTree is unchanged and false is
+		returned.
+		
+		Otherwise the binding of `key` is removed and true is returned.
+		
+		If `key` is null, the result is unspecified.
+	**/
+	public function remove(key:K) {
 		try {
-			root = removeLoop(k, root);
+			root = removeLoop(key, root);
 			return true;
 		}
 		catch (e:String) {
@@ -52,10 +89,17 @@ class BalancedTree<K,V> {
 		}
 	}
 	
-	public function exists(k:K) {
+	/**
+		Tells if `key` is bound to a value.
+		
+		This method returns true even if `key` is bound to null.
+		
+		If `key` is null, the result is unspecified.
+	**/
+	public function exists(key:K) {
 		var node = root;
 		while (node != null) {
-			var c = compare(k, node.key);
+			var c = compare(key, node.key);
 			if (c == 0) return true;
 			else if (c < 0) node = node.left;
 			else node = node.right;
@@ -63,12 +107,22 @@ class BalancedTree<K,V> {
 		return false;
 	}
 	
+	/**
+		Iterates over the bound values of `this` BalancedTree.
+		
+		This operation is performed in-order.
+	**/
 	public function iterator():Iterator<V> {
 		var ret = [];
 		iteratorLoop(root, ret);
 		return ret.iterator();
 	}
 	
+	/**
+		Iterates over the keys of `this` BalancedTree.
+		
+		This operation is performed in-order.
+	**/
 	public function keys():Iterator<K> {
 		var ret = [];
 		keysLoop(root, ret);
@@ -98,16 +152,16 @@ class BalancedTree<K,V> {
 	
 	function iteratorLoop(node:TreeNode<K,V>, acc:Array<V>) {
 		if (node != null) {
-			acc.push(node.value);
 			iteratorLoop(node.left, acc);
+			acc.push(node.value);
 			iteratorLoop(node.right, acc);
 		}
 	}
 	
 	function keysLoop(node:TreeNode<K,V>, acc:Array<K>) {
 		if (node != null) {
-			acc.push(node.key);
 			keysLoop(node.left, acc);
+			acc.push(node.key);
 			keysLoop(node.right, acc);
 		}
 	}

+ 6 - 0
std/haxe/ds/EnumValueMap.hx

@@ -22,6 +22,12 @@
 
 package haxe.ds;
 
+/**
+	EnumValueMap allows mapping of enum value keys to arbitrary values.
+	
+	Keys are compared by value and recursively over their parameters. If any
+	parameter is not an enum value, `Reflect.compare` is used to compare them.
+**/
 class EnumValueMap<K:EnumValue, V> extends haxe.ds.BalancedTree<K, V> implements Map.IMap<K,V> {
 	
 	override function compare(k1:EnumValue, k2:EnumValue) {

+ 29 - 14
std/haxe/ds/GenericStack.hx

@@ -43,7 +43,16 @@ private class GenericStackIterator<T> extends cpp.FastIterator<T> {
 #end
 
 /**
-	A linked-list of elements. A different class is created for each container used in platforms where it matters
+	A stack of elements.
+	
+	This class is generic, which means one type is generated for each type
+	parameter T on static targets. For example:
+		
+	- `new GenericStack<Int>()` generates `GenericStack_Int`
+	- `new GenericStack<String>()` generates `GenericStack_String`
+	
+	The generated name is an implementation detail and should not be relied
+	upon.
 **/
 #if (flash9 || cpp)
 @:generic
@@ -53,30 +62,31 @@ class GenericStack<T> {
 	public var head : GenericCell<T>;
 
 	/**
-		Creates a new empty list.
+		Creates a new empty GenericStack.
 	**/
 	public function new() {
 	}
 
 	/**
-		Add an element at the head of the list.
+		Pushes element `item` onto the stack.
 	**/
 	public inline function add( item : T ) {
 		head = new GenericCell<T>(item,head);
 	}
 
 	/**
-		Returns the first element of the list, or null
-		if the list is empty.
+		Returns the topmost stack element without removing it.
+		
+		If the stack is empty, null is returned.
 	**/
 	public inline function first() : Null<T> {
 		return if( head == null ) null else head.elt;
 	}
 
 	/**
-		Removes the first element of the list and
-		returns it or simply returns null if the
-		list is empty.
+		Returns the topmost stack element and removes it.
+		
+		If the stack is empty, null is returned.
 	**/
 	public inline function pop() : Null<T> {
 		var k = head;
@@ -89,15 +99,20 @@ class GenericStack<T> {
 	}
 
 	/**
-		Tells if a list is empty.
+		Tells if the stack is empty.
 	**/
 	public inline function isEmpty() : Bool {
 		return (head == null);
 	}
 
 	/**
-		Remove the first element that is [== v] from the list.
-		Returns [true] if an element was removed, [false] otherwise.
+		Removes the first element which is equal to `v` according to the `==`
+		operator.
+		
+		This method traverses the stack until it finds a matching element and
+		unlinks it, returning true.
+		
+		If no matching element is found, false is returned.
 	**/
 	public function remove( v : T ) : Bool {
 		var prev = null;
@@ -119,7 +134,7 @@ class GenericStack<T> {
 	#if cpp
 
 	/**
-		Returns an iterator on the elements of the list.
+		Returns an iterator over the elements of `this` GenericStack.
 	**/
 	public function iterator() : Iterator<T> {
 		return new GenericStackIterator<T>(head);
@@ -128,7 +143,7 @@ class GenericStack<T> {
 	#else
 
 	/**
-		Returns an iterator on the elements of the list.
+		Returns an iterator over the elements of `this` GenericStack.
 	**/
 	public function iterator() : Iterator<T> {
 		var l = head;
@@ -146,7 +161,7 @@ class GenericStack<T> {
    #end
 
 	/**
-		Returns a displayable representation of the String.
+		Returns a String representation of `this` GenericStack.
 	**/
 	public function toString() {
 		var a = new Array();

+ 12 - 13
std/haxe/ds/IntMap.hx

@@ -22,50 +22,49 @@
 package haxe.ds;
 
 /**
-	Hashtable over a set of elements, using [Int] as keys.
-	On Flash and Javascript, the underlying structure is an Object.
+	IntMap allows mapping of Int keys to arbitrary values.
+	
+	See `Map` for documentation details.
 **/
 extern class IntMap<T> implements Map.IMap<Int,T> {
 
 	/**
-		Creates a new empty hashtable.
+		Creates a new IntMap.
 	**/
 	public function new() : Void;
 
 	/**
-		Set a value for the given key.
+		See `Map.set`
 	**/
 	public function set( key : Int, value : T ) : Void;
+	
 	/**
-		Get a value for the given key.
+		See `Map.get`
 	**/
 	public function get( key : Int ) : Null<T>;
 
 	/**
-		Tells if a value exists for the given key.
-		In particular, it's useful to tells if a key has
-		a [null] value versus no value.
+		See `Map.exists`
 	**/
 	public function exists( key : Int ) : Bool;
 
 	/**
-		Removes a hashtable entry. Returns [true] if
-		there was such entry.
+		See `Map.remove`
 	**/
 	public function remove( key : Int ) : Bool;
 
 	/**
-		Returns an iterator of all keys in the hashtable.
+		See `Map.keys`
 	**/
 	public function keys() : Iterator<Int>;
 
 	/**
-		Returns an iterator of all values in the hashtable.
+		See `Map.iterator`
 	**/
 	public function iterator() : Iterator<T>;
 
 	/**
-		Returns an displayable representation of the hashtable content.
+		See `Map.toString`
 	**/
 	public function toString() : String;
 

+ 40 - 0
std/haxe/ds/ObjectMap.hx

@@ -22,13 +22,53 @@
 
 package haxe.ds;
 
+/**
+	ObjectMap allows mapping of object keys to arbitrary values.
+	
+	On static targets, the keys are considered to be strong references. Refer
+	to `haxe.ds.WeakMap` for a weak reference version.
+	
+	See `Map` for documentation details.
+**/
 extern class ObjectMap < K: { }, V > implements Map.IMap<K,V> {
+	
+	/**
+		Creates a new ObjectMap.
+	**/
 	public function new():Void;
+	
+	/**
+		See `Map.set`
+	**/
 	public function set(key:K, value:V):Void;
+	
+	/**
+		See `Map.get`
+	**/	
 	public function get(key:K):Null<V>;
+	
+	/**
+		See `Map.exists`
+	**/	
 	public function exists(key:K):Bool;
+	
+	/**
+		See `Map.remove`
+	**/	
 	public function remove(key:K):Bool;
+	
+	/**
+		See `Map.keys`
+	**/	
 	public function keys():Iterator<K>;
+	
+	/**
+		See `Map.iterator`
+	**/	
 	public function iterator():Iterator<V>;
+	
+	/**
+		See `Map.toString`
+	**/	
 	public function toString():String;
 }

+ 11 - 14
std/haxe/ds/StringMap.hx

@@ -23,52 +23,49 @@
 package haxe.ds;
 
 /**
-	Hashtable over a set of elements, using [String] as keys.
-	Other kind of keys are not possible on all platforms since they
-	can't always be implemented efficiently.
+	StringMap allows mapping of String keys to arbitrary values.
+	
+	See `Map` for documentation details.
 **/
 extern class StringMap<T> implements Map.IMap<String,T> {
 
 	/**
-		Creates a new empty hashtable.
+		Creates a new StringMap.
 	**/
 	public function new() : Void;
 
 	/**
-		Set a value for the given key.
+		See `Map.set`
 	**/
 	public function set( key : String, value : T ) : Void;
 
 	/**
-		Get a value for the given key.
+		See `Map.get`
 	**/
 	public function get( key : String ) : Null<T>;
 
 	/**
-		Tells if a value exists for the given key.
-		In particular, it's useful to tells if a key has
-		a [null] value versus no value.
+		See `Map.exists`
 	**/
 	public function exists( key : String ) : Bool;
 
 	/**
-		Removes a hashtable entry. Returns [true] if
-		there was such entry.
+		See `Map.remove`
 	**/
 	public function remove( key : String ) : Bool;
 
 	/**
-		Returns an iterator of all keys in the hashtable.
+		See `Map.keys`
 	**/
 	public function keys() : Iterator<String>;
 
 	/**
-		Returns an iterator of all values in the hashtable.
+		See `Map.iterator`
 	**/
 	public function iterator() : Iterator<T>;
 
 	/**
-		Returns an displayable representation of the hashtable content.
+		See `Map.toString`
 	**/
 	public function toString() : String;
 

+ 23 - 21
std/haxe/ds/Vector.hx

@@ -40,15 +40,15 @@ private typedef VectorData<T> = #if flash10
 @:arrayAccess
 abstract Vector<T>(VectorData<T>) {
 	/**
-		Creates a new Vector of length [length].
+		Creates a new Vector of length `length`.
 
-		Initially [this] Vector contains [length] neutral elements:
-			- always null on dynamic targets
-			- 0, 0.0 or false for Int, Float and Bool respectively on static
-			targets
-			- null for other types on static targets
+		Initially `this` Vector contains `length` neutral elements:
+			
+		- always null on dynamic targets
+		- 0, 0.0 or false for Int, Float and Bool respectively on static targets
+		- null for other types on static targets
 
-		If [length] is less than or equal to 0, the result is unspecified.
+		If `length` is less than or equal to 0, the result is unspecified.
 	**/
 	public inline function new(length:Int) {
 		#if flash9
@@ -70,9 +70,9 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Returns the value at index [index].
+		Returns the value at index `index`.
 
-		If [index] is negative or exceeds [this].length, the result is
+		If `index` is negative or exceeds `this.length`, the result is
 		unspecified.
 	**/
 	public inline function get(index:Int):Null<T> {
@@ -80,9 +80,9 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Sets the value at index [index] to [val].
+		Sets the value at index `index` to `val`.
 
-		If [index] is negative or exceeds [this].length, the result is
+		If `index` is negative or exceeds `this.length`, the result is
 		unspecified.
 	**/
 	public inline function set(index:Int, val:T):T {
@@ -90,7 +90,7 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Returns the length of [this] Vector.
+		Returns the length of `this` Vector.
 	**/
 	public var length(get, never):Int;
 
@@ -107,9 +107,11 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Copies [length] of elements from [src] Vector, beginning at [srcPos] to [dest] Vector, beginning at [destPos]
+		Copies `length` of elements from `src` Vector, beginning at `srcPos` to
+		`dest` Vector, beginning at `destPos`
 
-		The results are unspecified if [length] results in out-of-bounds access, or if [src] or [dest] are null
+		The results are unspecified if `length` results in out-of-bounds access,
+		or if `src` or `dest` are null
 	**/
 	public static #if (cs || java || neko) inline #end function blit<T>(src:Vector<T>, srcPos:Int, dest:Vector<T>, destPos:Int, len:Int):Void
 	{
@@ -128,7 +130,7 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Extracts the data of [this] Vector.
+		Extracts the data of `this` Vector.
 
 		This returns the internal representation type.
 	**/
@@ -136,25 +138,25 @@ abstract Vector<T>(VectorData<T>) {
 		return cast this;
 
 	/**
-		Initializes a new Vector from [data].
+		Initializes a new Vector from `data`.
 
-		Since [data] is the internal representation of Vector, this is a no-op.
+		Since `data` is the internal representation of Vector, this is a no-op.
 
-		If [data] is null, the corresponding Vector is also [null].
+		If `data` is null, the corresponding Vector is also `null`.
 	**/
 	static public inline function fromData<T>(data:VectorData<T>):Vector<T>
 		return cast data;
 
 	/**
-		Creates a new Vector by copying the elements of [array].
+		Creates a new Vector by copying the elements of `array`.
 
 		This always creates a copy, even on platforms where the internal
 		representation is Array.
 
 		The elements are not copied and retain their identity, so
-		a[i] == Vector.fromArrayCopy(a).get(i) is true for any valid i.
+		`a[i] == Vector.fromArrayCopy(a).get(i)` is true for any valid i.
 
-		If [array] is null, the result is unspecified.
+		If `array` is null, the result is unspecified.
 	**/
 	static public inline function fromArrayCopy<T>(array:Array<T>):Vector<T> {
 		// TODO: Optimize this for flash (and others?)

+ 40 - 1
std/haxe/ds/WeakMap.hx

@@ -22,27 +22,66 @@
 
 package haxe.ds;
 
-class WeakMap<K:{},V> implements Map.IMap<K,V> {
+/**
+	WeakMap allows mapping of object keys to arbitrary values.
+	
+	The keys are considered to be weak references on static targets.
+	
+	See `Map` for documentation details.
+**/
+class WeakMap<K: { },V> implements Map.IMap<K,V> {
+	
+	/**
+		Creates a new WeakMap.
+	**/	
 	public function new():Void {
 		throw "Not implemented for this platform";
 	}
+	
+	/**
+		See `Map.set`
+	**/	
 	public function set(key:K, value:V):Void {
 	}
+	
+	/**
+		See `Map.get`
+	**/		
 	public function get(key:K):Null<V> {
 		return null;
 	}
+	
+	/**
+		See `Map.exists`
+	**/		
 	public function exists(key:K):Bool {
 		return false;
 	}
+	
+	/**
+		See `Map.remove`
+	**/		
 	public function remove(key:K):Bool {
 		return false;
 	}
+	
+	/**
+		See `Map.keys`
+	**/		
 	public function keys():Iterator<K> {
 		return null;
 	}
+	
+	/**
+		See `Map.iterator`
+	**/		
 	public function iterator():Iterator<V> {
 		return null;
 	}
+	
+	/**
+		See `Map.toString`
+	**/		
 	public function toString():String {
 		return null;
 	}

+ 15 - 0
std/haxe/io/BytesBuffer.hx

@@ -39,6 +39,9 @@ class BytesBuffer {
 	var b : Array<Int>;
 	#end
 
+	/** The length of the buffer in bytes. **/
+	public var length(get,never) : Int;
+
 	public function new() {
 		#if neko
 		b = untyped StringBuf.__make();
@@ -57,6 +60,18 @@ class BytesBuffer {
 		#end
 	}
 
+	inline function get_length() : Int {
+		#if neko
+		return untyped __dollar__ssize( StringBuf.__to_string(b) );
+		#elseif cs
+		return haxe.Int64.toInt( b.Length );
+		#elseif java
+		return b.size();
+		#else
+		return b.length;
+		#end
+	}
+
 	public inline function addByte( byte : Int ) {
 		#if neko
 		untyped StringBuf.__add_char(b,byte);

+ 15 - 1
std/haxe/io/BytesInput.hx

@@ -26,10 +26,15 @@ class BytesInput extends Input {
 	#if !flash9
 	var pos : Int;
 	var len : Int;
+	var totlen : Int;
 	#end
 	
+	/** The current position in the stream in bytes. */
 	public var position(get,set) : Int;
 
+	/** The length of the stream in bytes. */
+	public var length(get,never) : Int;
+
 	public function new( b : Bytes, ?pos : Int, ?len : Int ) {
 		if( pos == null ) pos = 0;
 		if( len == null ) len = b.length - pos;
@@ -48,10 +53,11 @@ class BytesInput extends Input {
 		this.b = b.getData();
 		this.pos = pos;
 		this.len = len;
+		this.totlen = len;
 		#end
 	}
 	
-	function get_position() : Int {
+	inline function get_position() : Int {
 		#if flash9
 		return b.position;
 		#else
@@ -59,6 +65,14 @@ class BytesInput extends Input {
 		#end
 	}
 
+	inline function get_length() : Int {
+		#if flash9
+		return b.length;
+		#else
+		return totlen;
+		#end
+	}
+	
 	function set_position( p : Int ) : Int {
 		#if flash9
 		return b.position = p;

+ 7 - 0
std/haxe/io/BytesOutput.hx

@@ -29,6 +29,9 @@ class BytesOutput extends Output {
 	var b : BytesBuffer;
 	#end
 
+	/** The length of the stream in bytes. **/
+	public var length(get,never) : Int;
+
 	public function new() {
 		#if flash9
 		b = new flash.utils.ByteArray();
@@ -38,6 +41,10 @@ class BytesOutput extends Output {
 		#end
 	}
 
+	inline function get_length() : Int {
+		return b.length;
+	}
+
 	override function writeByte(c) {
 		#if flash9
 		b.writeByte(c);

+ 44 - 25
std/haxe/io/Path.hx

@@ -24,8 +24,9 @@ package haxe.io;
 /**
 	This class provides a convenient way of working with paths. It supports the
 	common path formats:
-		directory1/directory2/filename.extension
-		directory1\directory2\filename.excention
+		
+	- directory1/directory2/filename.extension
+	- directory1\directory2\filename.excention
 **/
 class Path {
 
@@ -35,7 +36,7 @@ class Path {
 		This is the leading part of the path that is not part of the file name
 		and the extension.
 		
-		Does not end with a / or \ separator.
+		Does not end with a `/` or `\` separator.
 		
 		If the path has no directory, the value is null.
 	**/
@@ -67,7 +68,7 @@ class Path {
 	public var backslash : Bool;
 
 	/**
-		Creates a new Path instance by parsing [path].
+		Creates a new Path instance by parsing `path`.
 		
 		Path information can be retrieved by accessing the dir, file and ext
 		properties.
@@ -95,13 +96,13 @@ class Path {
 	}
 
 	/**
-		Returns a String representation of [this] path.
+		Returns a String representation of `this` path.
 		
-		If [this].backslash is true, backslash is used as directory separator,
+		If `this.backslash` is true, backslash is used as directory separator,
 		otherwise slash is used. This only affects the separator between
-		[this].dir and [this].file.
+		`this.dir` and `this.file`.
 		
-		If [this].directory or [this].extension is null, their representation
+		If `this.directory` or `this.extension` is null, their representation
 		is the empty String "".
 	**/
 	public function toString() {
@@ -109,9 +110,9 @@ class Path {
 	}
 
 	/**
-		Returns the String representation of [path] without the file extension.
+		Returns the String representation of `path` without the file extension.
 		
-		If [path] is null, the result is unspecified.
+		If `path` is null, the result is unspecified.
 	**/
 	public static function withoutExtension( path : String ) {
 		var s = new Path(path);
@@ -120,9 +121,9 @@ class Path {
 	}
 
 	/**
-		Returns the String representation of [path] without the directory.
+		Returns the String representation of `path` without the directory.
 		
-		If [path] is null, the result is unspecified.
+		If `path` is null, the result is unspecified.
 	**/
 	public static function withoutDirectory( path ) {
 		var s = new Path(path);
@@ -131,11 +132,11 @@ class Path {
 	}
 
 	/**
-		Returns the directory of [path].
+		Returns the directory of `path`.
 		
 		If the directory is null, the empty String "" is returned.
 		
-		If [path] is null, the result is unspecified.
+		If `path` is null, the result is unspecified.
 	**/
 	public static function directory( path ) {
 		var s = new Path(path);
@@ -145,11 +146,11 @@ class Path {
 	}
 
 	/**
-		Returns the extension of [path].
+		Returns the extension of `path`.
 		
 		If the extension is null, the empty String "" is returned.
 		
-		If [path] is null, the result is unspecified.
+		If `path` is null, the result is unspecified.
 	**/
 	public static function extension( path ) {
 		var s = new Path(path);
@@ -159,11 +160,11 @@ class Path {
 	}
 
 	/**
-		Returns a String representation of [path] where the extension is [ext].
+		Returns a String representation of `path` where the extension is `ext`.
 		
-		If [path] has no extension, [ext] is added as extension.
+		If `path` has no extension, `ext` is added as extension.
 		
-		If [path] or [ext] are null, the result is unspecified.
+		If `path` or `ext` are null, the result is unspecified.
 	**/
 	public static function withExtension( path, ext ) {
 		var s = new Path(path);
@@ -172,16 +173,16 @@ class Path {
 	}
 
 	/**
-		Adds a trailing slash to [path], if it does not have one already.
+		Adds a trailing slash to `path`, if it does not have one already.
 		
-		If the last slash in [path] is a backslash, a backslash is appended to
-		[path].
+		If the last slash in `path` is a backslash, a backslash is appended to
+		`path`.
 		
-		If the last slash in [path] is a slash, or if no slash is found, a slash
-		is appended to [path]. In particular, this applies to the empty String
+		If the last slash in `path` is a slash, or if no slash is found, a slash
+		is appended to `path`. In particular, this applies to the empty String
 		"".
 		
-		If [path] is null, the result is unspecified.
+		If `path` is null, the result is unspecified.
 	**/
 	public static function addTrailingSlash( path : String ) : String {
 		if (path.length == 0)
@@ -196,4 +197,22 @@ class Path {
 			else path;
 		}
 	}
+	
+	/**
+		Removes a trailing slash from `path` if it exists.
+		
+		If `path` does not end with a `/` or `\`, `path` is returned unchanged.
+		
+		Otherwise the substring of `path` excluding the trailing slash or
+		backslash is returned.
+		
+		If `path` is null, the result is unspecified.
+	**/
+	@:require(haxe_ver >= 3.1)
+	public static function removeTrailingSlash ( path : String ) : String {
+		return switch(path.charCodeAt(path.length - 1)) {
+			case '/'.code | '\\'.code: path.substr(0, -1);
+			case _: path;
+		}
+	}
 }

+ 132 - 37
std/haxe/macro/Context.hx

@@ -20,38 +20,58 @@
  * DEALINGS IN THE SOFTWARE.
  */
 package haxe.macro;
+
 import haxe.macro.Expr;
 
 /**
-	This is an API that can be used by macros implementations.
+	Context provides an API for macro programming.
+	
+	It contains common functions that interact with the macro interpreter to
+	query or set information. Other API functions are available in the tools
+	classes:
+		
+	- `haxe.macro.ComplexTypeTools`
+	- `haxe.macro.ExprTools`
+	- `haxe.macro.TypeTools`
 **/
 #if !neko @:noDoc #end
 class Context {
 
 #if neko
 	/**
-		Display a compilation error at the given position in code and abort the current macro call
+		Displays a compilation error `msg` at the given `Position` `pos`
+		and aborts the current macro call.
 	**/
 	public static function error( msg : String, pos : Position ) : Dynamic {
 		return load("error",2)(untyped msg.__s, pos);
 	}
 
 	/**
-		Display a compilation warning at the given position in code
+		Displays a compilation warning `msg` at the given `Position` `pos`.
 	**/
 	public static function warning( msg : String, pos : Position ) {
 		load("warning",2)(untyped msg.__s, pos);
 	}
 
 	/**
-		Resolve a filename based on current classpath.
+		Resolves a file name `file` based on the current class paths.
+		
+		The resolution follows the usual class path rules where the last
+		declared class path has priority.
+		
+		If a class path was declared relative, this method returns the relative
+		file path. Otherwise it returns the absolute file path.
 	**/
 	public static function resolvePath( file : String ) {
 		return new String(load("resolve",1)(untyped file.__s));
 	}
 
 	/**
-		Return the current classpath
+		Returns an `Array` of current class paths in the order of their
+		declaration.
+		
+		Modifying the returned array has no effect on the compiler. Class paths
+		can be added using `haxe.macro.Compiler.addClassPath`.
 	**/
 	public static function getClassPath() : Array<String> {
 		var c : neko.NativeArray<neko.NativeString> = load("class_path",0)();
@@ -62,14 +82,16 @@ class Context {
 	}
 
 	/**
-		Returns the position at which the macro is called
+		Returns the position at which the macro was called.
 	**/
 	public static function currentPos() : Position {
 		return load("curpos", 0)();
 	}
 
 	/**
-		Returns the current class in which the macro is called
+		Returns the current class in which the macro was called.
+		
+		If no such class exists, null is returned.
 	**/
 	public static function getLocalClass() : Null<Type.Ref<Type.ClassType>> {
 		var l : Type = load("local_type", 0)();
@@ -81,7 +103,9 @@ class Context {
 	}
 
 	/**
-		Returns the current type in/on which the macro is called
+		Returns the current type in/on which the macro was called.
+		
+		If no such type exists, null is returned.
 	**/
 	public static function getLocalType() : Null<Type> {
 		var l : Type = load("local_type", 0)();
@@ -90,7 +114,9 @@ class Context {
 	}
 
 	/**
-		Returns the name of the method from which the macro was called
+		Returns the name of the method from which the macro was called.
+		
+		If no such method exists, null is returned.
 	**/
 	public static function getLocalMethod() : Null<String> {
 		var l : String = load("local_method", 0)();
@@ -99,28 +125,47 @@ class Context {
 	}
 
 	/**
-		Returns classes which are available for "using" where the macro was called
+		Returns an `Array` of classes which are available for `using` usage in
+		the context the macro was called.
+		
+		Modifying the returned array has no effect on the compiler.
 	**/
 	public static function getLocalUsing() :  Array<Type.Ref<Type.ClassType>> {
 		return load("local_using", 0)();
 	}
 
 	/**
-		Returns local variables accessible where the macro was called
+		Returns a map of local variables accessible in the context the macro was
+		called.
+		
+		The keys of the returned map are the variable names, the values are
+		their types.
+		
+		Modifying the returned map has no effect on the compiler.
 	**/
 	public static function getLocalVars() : haxe.ds.StringMap<Type> {
 		return load("local_vars", 0)();
 	}
 
 	/**
-		Tells is the given compiler directive has been defined with -D
+		Tells if compiler directive `s` has been set.
+		
+		Compiler directives are set using the `-D` command line parameter, or
+		by calling `haxe.macro.Compiler.define`.
 	**/
 	public static function defined( s : String ) : Bool {
 		return load("defined", 1)(untyped s.__s);
 	}
 
 	/**
-		Returns the value defined through -D key=value
+		Returns the value defined for compiler directive `key`.
+		
+		If no value is defined for `key`, null is returned.
+		
+		Compiler directive values are set using the `-D key=value` command line
+		parameter, or by calling `haxe.macro.Compiler.define`.
+		
+		The default value is `"1"`.
 	**/
 	public static function definedValue( key : String ) : String {
 		var d = load("defined_value", 1)(untyped key.__s);
@@ -128,91 +173,128 @@ class Context {
 	}
 
 	/**
-		Resolve a type from its name.
+		Resolves a type identified by `name`.
+		
+		The resolution follows the usual class path rules where the last
+		declared class path has priority.
+		
+		If no type can be found, null is returned.
 	**/
 	public static function getType( name : String ) : Type {
 		return load("get_type", 1)(untyped name.__s);
 	}
 
 	/**
-		Return the list of types defined in the given compilation unit module
+		Resolves a module identified by `name` and returns an `Array` of all
+		its contained types.
+		
+		The resolution follows the usual class path rules where the last
+		declared class path has priority.
+		
+		If no module can be found, null is returned.
 	**/
 	public static function getModule( name : String ) : Array<Type> {
 		return load("get_module", 1)(untyped name.__s);
 	}
 
 	/**
-		Parse a constructed string into the corresponding expression.
+		Parses `expr` as haxe code, returning the corresponding AST.
+		
+		The provided `Position` `pos` is used for all generated inner AST nodes.
 	**/
 	public static function parse( expr : String, pos : Position ) : Expr {
 		return load("parse", 3)(untyped expr.__s, pos, false);
 	}
 
 	/**
-		Parse a string contained into source code into the corresponding expression. Errors positions are reported within this string
+		Similar to `parse`, but error positions are reported within the provided
+		String `expr`.
 	**/
 	public static function parseInlineString( expr : String, pos : Position ) : Expr {
 		return load("parse", 3)(untyped expr.__s, pos, true);
 	}
 
 	/**
-		Build an expression corresponding to the given runtime value. Only basic types + enums are supported.
+		Builds an expression from `v`.
+		
+		This method generates AST nodes depending on the macro-runtime value of
+		`v`. As such, only basic types and enums are supported and the behavior
+		for other types is undefined.
+		
+		The provided `Position` `pos` is used for all generated inner AST nodes.
 	**/
 	public static function makeExpr( v : Dynamic, pos : Position ) : Expr {
 		return load("make_expr", 2)(v, pos);
 	}
 
 	/**
-		Quickly build an hashed MD5 signature for any given value
+		Returns a hashed MD5 signature of value `v`.
 	**/
 	public static function signature( v : Dynamic ) : String {
 		return new String(load("signature", 1)(v));
 	}
 
 	/**
-		Set a callback function that will return all the types compiled before they get generated.
+		Adds a callback function `callback` which is invoked after the
+		compiler's typing phase, just before its generation phase.
+		
+		The callback receives an `Array` containing all types which are about
+		to be generated. Modifications are limited to metadata, it is mainly
+		intended to obtain information.
 	**/
-	public static function onGenerate( callb : Array<Type> -> Void ) {
-		load("on_generate",1)(callb);
+	public static function onGenerate( callback : Array<Type> -> Void ) {
+		load("on_generate",1)(callback);
 	}
 
 	/**
-		Set a callback function that will be called when a type cannot be found.
+		Adds a callback function `callback` which is invoked when a type name
+		cannot be resolved.
+		
+		The callback may return a type definition, which is then used for the
+		expected type. If it returns null, the type is considered to still not
+		exist.
 	**/
-	public static function onTypeNotFound ( callb : String -> TypeDefinition ) {
-		load("on_type_not_found",1)(callb);
+	public static function onTypeNotFound ( callback : String -> TypeDefinition ) {
+		load("on_type_not_found",1)(callback);
 	}
 
 	/**
-		Evaluate the type a given expression would have in the context of the current macro call.
+		Types expression `e` and returns its type.
+		
+		Typing the expression may result in an compiler error which can be
+		caught using `try ... catch`.
 	**/
 	public static function typeof( e : Expr ) : Type {
 		return load("typeof", 1)(e);
 	}
 
 	/**
-		Returns the ComplexType corresponding to the given Type.
+		Returns the `ComplexType` corresponding to the given `Type` `t`.
+		
+		See `haxe.macro.TypeTools.toComplexType` for details.
 	**/
 	public static function toComplexType( t : Type ) : Null<ComplexType> {
 		return load("to_complex", 1)(t);
 	}
 
 	/**
-		Returns true if t1 and t2 unify, false otherwise
+		Returns true if `t1` and `t2` unify, false otherwise.
 	**/
 	public static function unify( t1 : Type, t2 : Type) : Bool {
 		return load("unify", 2)(t1, t2);
 	}
 
 	/**
-		Follow all typedefs to reach the actual real type
+		Follows a type.
+		
+		See `haxe.macro.TypeTools.follow` for details.
 	**/
 	public static function follow( t : Type, ?once : Bool ) : Type {
 		return load("follow", 2)(t,once);
 	}
 
 	/**
-		Get the informations stored into a given position.
+		Returns the information stored in `Position` `p`.
 	**/
 	public static function getPosInfos( p : Position ) : { min : Int, max : Int, file : String } {
 		var i = load("get_pos_infos",1)(p);
@@ -221,28 +303,34 @@ class Context {
 	}
 
 	/**
-		Build a position with the given informations.
+		Builds a `Position` from `inf`.
 	**/
 	public static function makePosition( inf : { min : Int, max : Int, file : String } ) : Position {
 		return load("make_pos",3)(inf.min,inf.max,untyped inf.file.__s);
 	}
 
 	/**
-		Add or modify a resource that will be accessible with haxe.Resource api.
+		Makes resource `data` available as `name`.
+		
+		The resource is then available using the `haxe.macro.Resource` API.
+		
+		If a previous resource was bound to `name`, it is overwritten.
 	**/
 	public static function addResource( name : String, data : haxe.io.Bytes ) {
 		load("add_resource",2)(untyped name.__s,data.getData());
 	}
 
 	/**
-		Returns the list of fields for the current type inside the build macro.
+		Returns an `Array` of fields of the class which is to be built.
+		
+		This is only defined for `@:build/@:autoBuild` macros.
 	**/
 	public static function getBuildFields() : Array<Field> {
 		return load("build_fields", 0)();
 	}
 
 	/**
-		Define a new type based on the given definition.
+		Defines a new type from `TypeDefinition` `t`.
 	**/
 	public static function defineType( t : TypeDefinition ) : Void {
 		load("define_type", 1)(t);
@@ -250,15 +338,22 @@ class Context {
 
 
 	/**
-		Return the raw expression corresponding to the given typed expression.
+		Returns a syntax-level expression corresponding to typed expression `t`.
+		
+		This process may lose some information.
 	**/
 	public static function getTypedExpr( t : Type.TypedExpr ) : Expr {
 		return load("get_typed_expr",1)(t);
 	}
 
 	/**
-		Manually add a dependency between a module and a third party file :
-		make sure the module gets recompiled (if it was cached) in case the extern file has been modified as well.
+		Manually adds a dependency between module `modulePath` and an external
+		file `externFile`.
+		
+		This affects the compilation cache, causing the module to be typed if
+		`externFile` has changed.
+		
+		Has no effect if the compilation cache is not used.
 	**/
 	public static function registerModuleDependency( modulePath : String, externFile : String ) {
 		load("module_dependency", 2)(untyped modulePath.__s,untyped externFile.__s);

+ 1 - 1
std/haxe/macro/JSGenApi.hx

@@ -28,7 +28,7 @@ import haxe.macro.Type;
 typedef JSGenApi = {
 	/** the file in which the JS code can be generated **/
 	var outputFile : String;
-	/** all the types that were compiled by haXe **/
+	/** all the types that were compiled by Haxe **/
 	var types : Array<Type>;
 	/** the main call expression, if a -main class is defined **/
 	var main : Null<TypedExpr>;

+ 33 - 33
std/haxe/macro/Printer.hx

@@ -88,21 +88,21 @@ class Printer {
 		(tp.pack.length > 0 ? tp.pack.join(".") + "." : "")
 		+ tp.name
 		+ (tp.sub != null ? '.${tp.sub}' : "")
-		+ (tp.params.length > 0 ? "<" + tp.params.map(printTypeParam).join(",") + ">" : "");
+		+ (tp.params.length > 0 ? "<" + tp.params.map(printTypeParam).join(", ") + ">" : "");
 
 	// TODO: check if this can cause loops
 	public function printComplexType(ct:ComplexType) return switch(ct) {
 		case TPath(tp): printTypePath(tp);
-		case TFunction(args, ret): args.map(printComplexType).join("->") + "->" + printComplexType(ret);
-		case TAnonymous(fields): "{" + [for (f in fields) printField(f) + ";"].join("") + "}";
+		case TFunction(args, ret): args.map(printComplexType).join(" -> ") + " -> " + printComplexType(ret);
+		case TAnonymous(fields): "{ " + [for (f in fields) printField(f) + "; "].join("") + "}";
 		case TParent(ct): "(" + printComplexType(ct) + ")";
 		case TOptional(ct): "?" + printComplexType(ct);
-		case TExtend(tp, fields): '{${printTypePath(tp)} >, ${fields.map(printField).join(",")}}';
+		case TExtend(tp, fields): '{${printTypePath(tp)} >, ${fields.map(printField).join(", ")} }';
 	}
 
 	public function printMetadata(meta:MetadataEntry) return
 		'@${meta.name}'
-		+ (meta.params.length > 0 ? '(${printExprs(meta.params,",")})' : "");
+		+ (meta.params.length > 0 ? '(${printExprs(meta.params,", ")})' : "");
 
 	public function printAccess(access:Access) return switch(access) {
 		case AStatic: "static";
@@ -119,50 +119,50 @@ class Printer {
 		+ (field.meta != null && field.meta.length > 0 ? field.meta.map(printMetadata).join(" ") + " " : "")
 		+ (field.access != null && field.access.length > 0 ? field.access.map(printAccess).join(" ") + " " : "")
 		+ switch(field.kind) {
-		  case FVar(t, eo): 'var ${field.name}' + opt(t, printComplexType, ":") + opt(eo, printExpr, "=");
-		  case FProp(get, set, t, eo): 'var ${field.name}($get,$set)' + opt(t, printComplexType, ":") + opt(eo, printExpr, "=");
+		  case FVar(t, eo): 'var ${field.name}' + opt(t, printComplexType, " : ") + opt(eo, printExpr, " = ");
+		  case FProp(get, set, t, eo): 'var ${field.name}($get, $set)' + opt(t, printComplexType, " : ") + opt(eo, printExpr, " = ");
 		  case FFun(func): 'function ${field.name}' + printFunction(func);
 		}
 
 	public function printTypeParamDecl(tpd:TypeParamDecl) return
 		tpd.name
-		+ (tpd.params != null && tpd.params.length > 0 ? "<" + tpd.params.map(printTypeParamDecl).join(",") + ">" : "")
-		+ (tpd.constraints != null && tpd.constraints.length > 0 ? ":(" + tpd.constraints.map(printComplexType).join(",") + ")" : "");
+		+ (tpd.params != null && tpd.params.length > 0 ? "<" + tpd.params.map(printTypeParamDecl).join(", ") + ">" : "")
+		+ (tpd.constraints != null && tpd.constraints.length > 0 ? ":(" + tpd.constraints.map(printComplexType).join(", ") + ")" : "");
 
 	public function printFunctionArg(arg:FunctionArg) return
 		(arg.opt ? "?" : "")
 		+ arg.name
-		+ opt(arg.type, printComplexType, ":")
-		+ opt(arg.value, printExpr, "=");
+		+ opt(arg.type, printComplexType, " : ")
+		+ opt(arg.value, printExpr, " = ");
 
 	public function printFunction(func:Function) return
-		(func.params.length > 0 ? "<" + func.params.map(printTypeParamDecl).join(",") + ">" : "")
-		+ "(" + func.args.map(printFunctionArg).join(",") + ")"
-		+ opt(func.ret, printComplexType, ":")
+		(func.params.length > 0 ? "<" + func.params.map(printTypeParamDecl).join(", ") + ">" : "")
+		+ "( " + func.args.map(printFunctionArg).join(", ") + " )"
+		+ opt(func.ret, printComplexType, " : ")
 		+ opt(func.expr, printExpr, " ");
 
 	public function printVar(v:Var) return
 		v.name
-		+ opt(v.type, printComplexType, ":")
-		+ opt(v.expr, printExpr, "=");
+		+ opt(v.type, printComplexType, " : ")
+		+ opt(v.expr, printExpr, " = ");
 
 
 	public function printExpr(e:Expr) return e == null ? "#NULL" : switch(e.expr) {
 		case EConst(c): printConstant(c);
 		case EArray(e1, e2): '${printExpr(e1)}[${printExpr(e2)}]';
-		case EBinop(op, e1, e2): '${printExpr(e1)}${printBinop(op)}${printExpr(e2)}';
+		case EBinop(op, e1, e2): '${printExpr(e1)} ${printBinop(op)} ${printExpr(e2)}';
 		case EField(e1, n): '${printExpr(e1)}.$n';
 		case EParenthesis(e1): '(${printExpr(e1)})';
 		case EObjectDecl(fl):
-			"{" + fl.map(function(fld) return '${fld.field}:${printExpr(fld.expr)}').join(",") + "}";
-		case EArrayDecl(el): '[${printExprs(el, ",")}]';
-		case ECall(e1, el): '${printExpr(e1)}(${printExprs(el,",")})';
-		case ENew(tp, el): 'new ${printTypePath(tp)}(${printExprs(el,",")})';
+			"{ " + fl.map(function(fld) return '${fld.field} : ${printExpr(fld.expr)} ').join(",") + "}";
+		case EArrayDecl(el): '[${printExprs(el, ", ")}]';
+		case ECall(e1, el): '${printExpr(e1)}(${printExprs(el,", ")})';
+		case ENew(tp, el): 'new ${printTypePath(tp)}(${printExprs(el,", ")})';
 		case EUnop(op, true, e1): printExpr(e1) + printUnop(op);
 		case EUnop(op, false, e1): printUnop(op) + printExpr(e1);
 		case EFunction(no, func) if (no != null): 'function $no' + printFunction(func);
 		case EFunction(_, func): "function " +printFunction(func);
-		case EVars(vl): "var " +vl.map(printVar).join(",");
+		case EVars(vl): "var " +vl.map(printVar).join(", ");
 		case EBlock([]): '{\n$tabs}';
 		case EBlock(el):
 			var old = tabs;
@@ -180,17 +180,17 @@ class Printer {
 			tabs += tabString;
 			var s = 'switch ${printExpr(e1)} {\n$tabs' +
 				cl.map(function(c)
-					return 'case ${printExprs(c.values, ",")}'
-						+ (c.guard != null ? 'if(${printExpr(c.guard)}):' : ":")
-						+ (opt(c.expr, printExpr)) + ";")
+					return 'case ${printExprs(c.values, ", ")}'
+						+ (c.guard != null ? ' if(${printExpr(c.guard)}): ' : ":")
+						+ (c.expr != null ? (opt(c.expr, printExpr)) + ";" : ""))
 				.join('\n$tabs');
 			if (edef != null)
-				s += '\n${tabs}default:' + (edef.expr == null ? "" : printExpr(edef)) + ";";
+				s += '\n${tabs}default: ' + (edef.expr == null ? "" : printExpr(edef)) + ";";
 			tabs = old;
 			s + '\n$tabs}';
 		case ETry(e1, cl):
 			'try ${printExpr(e1)}'
-			+ cl.map(function(c) return ' catch(${c.name}:${printComplexType(c.type)}) ${printExpr(c.expr)}').join("");
+			+ cl.map(function(c) return ' catch(${c.name} : ${printComplexType(c.type)}) ${printExpr(c.expr)}').join("");
 		case EReturn(eo): "return" + opt(eo, printExpr, " ");
 		case EBreak: "break";
 		case EContinue: "continue";
@@ -200,7 +200,7 @@ class Printer {
 		case ECast(e1, _): "cast " +printExpr(e1);
 		case EDisplay(e1, _): '#DISPLAY(${printExpr(e1)})';
 		case EDisplayNew(tp): '#DISPLAY(${printTypePath(tp)})';
-		case ETernary(econd, eif, eelse): '${printExpr(econd)} ? ${printExpr(eif)} : ${printExpr(eelse) }';
+		case ETernary(econd, eif, eelse): '${printExpr(econd)} ? ${printExpr(eif)} : ${printExpr(eelse)}';
 		case ECheckType(e1, ct): '#CHECK_TYPE(${printExpr(e1)}, ${printComplexType(ct)})';
 		case EMeta(meta, e1): printMetadata(meta) + " " +printExpr(e1);
 	}
@@ -217,7 +217,7 @@ class Printer {
 			(printPackage && t.pack.length > 0 && t.pack[0] != "" ? "package " + t.pack.join(".") + ";\n" : "") +
 			(t.meta != null && t.meta.length > 0 ? t.meta.map(printMetadata).join(" ") + " " : "") + (t.isExtern ? "extern " : "") + switch (t.kind) {
 				case TDEnum:
-					"enum " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(",") + ">" : "") + " {\n"
+					"enum " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "") + " {\n"
 					+ [for (field in t.fields)
 						tabs + (field.doc != null && field.doc != "" ? "/**\n" + tabs + tabString + StringTools.replace(field.doc, "\n", "\n" + tabs + tabString) + "\n" + tabs + "**/\n" + tabs : "")
 						+ (field.meta != null && field.meta.length > 0 ? field.meta.map(printMetadata).join(" ") + " " : "")
@@ -229,13 +229,13 @@ class Printer {
 					].join("\n")
 					+ "\n}";
 				case TDStructure:
-					"typedef " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(",") + ">" : "") + " = {\n"
+					"typedef " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "") + " = {\n"
 					+ [for (f in t.fields) {
 						tabs + printField(f) + ";";
 					}].join("\n")
 					+ "\n}";
 				case TDClass(superClass, interfaces, isInterface):
-					(isInterface ? "interface " : "class ") + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(",") + ">" : "")
+					(isInterface ? "interface " : "class ") + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "")
 					+ (superClass != null ? " extends " + printTypePath(superClass) : "")
 					+ (interfaces != null ? (isInterface ? [for (tp in interfaces) " extends " + printTypePath(tp)] : [for (tp in interfaces) " implements " + printTypePath(tp)]).join("") : "")
 					+ " {\n"
@@ -249,13 +249,13 @@ class Printer {
 					}].join("\n")
 					+ "\n}";
 				case TDAlias(ct):
-					"typedef " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(",") + ">" : "") + " = "
+					"typedef " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "") + " = "
 					+ printComplexType(ct)
 					+ ";";
 				case TDAbstract(tthis, from, to):
 					"abstract " + t.name
 					+ (tthis == null ? "" : "(" + printComplexType(tthis) + ")")
-					+ (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(",") + ">" : "")
+					+ (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "")
 					+ (from == null ? "" : [for (f in from) " from " + printComplexType(f)].join(""))
 					+ (to == null ? "" : [for (t in to) " to " + printComplexType(t)].join(""))
 					+ " {\n"

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

@@ -122,10 +122,51 @@ typedef AbstractType = {>BaseType,
 	var array : Array<ClassField>;
 }
 
+/**
+	MetaAccess is a wrapper for the `Metadata` array. It can be used to add
+	metadata to and remove metadata from its origin.
+**/
 typedef MetaAccess = {
+	/**
+		Return the wrapped `Metadata` array.
+		
+		Modifying this array has no effect on the origin of `this` MetaAccess.
+		The `add` and `remove` methods can be used for that.
+	**/
 	function get() : Expr.Metadata;
+	
+	/**
+		Adds the metadata specified by `name`, `params` and `pos` to the origin
+		of `this` MetaAccess.
+		
+		Metadata names are not unique during compilation, so this method never
+		overwrites a previous metadata.
+		
+		If a `Metadata` array is obtained through a call to `get`, a subsequent
+		call to `add` has no effect on that array.
+		
+		If any argument is null, compilation fails with an error.
+	**/
 	function add( name : String, params : Array<Expr>, pos : Expr.Position ) : Void;
+	
+	/**
+		Removes all `name` metadata entries from the origin of `this`
+		MetaAccess.
+		
+		This method might clear several metadata entries of the same name.
+		
+		If a `Metadata` array is obtained through a call to `get`, a subsequent
+		call to `remove` has no effect on that array.
+		
+		If `name` is null, compilation fails with an error.
+	**/
 	function remove( name : String ) : Void;
+	
+	/**
+		Tells if the origin of `this` MetaAccess has a `name` metadata entry.
+		
+		If `name` is null, compilation fails with an error.
+	**/
 	function has( name : String ) : Bool;
 }
 

+ 16 - 16
std/haxe/macro/TypeTools.hx

@@ -37,15 +37,15 @@ class TypeTools {
 	#if macro
 	
 	/**
-		Follows all typedefs of [t] to reach the actual type.
+		Follows all typedefs of `t` to reach the actual type.
 		
-		If [once] is true, this function does not call itself recursively,
+		If `once` is true, this function does not call itself recursively,
 		otherwise it does. This can be useful in cases where intermediate
 		typedefs might be of interest.
 		
-		Affected types are monomorphs (TMono) and typedefs (TType(t,pl)).
+		Affected types are monomorphs `TMono` and typedefs `TType(t,pl)`.
 		
-		If [t] is null, an internal exception is thrown.
+		If `t` is null, an internal exception is thrown.
 		
 		Usage example:
 			var t = Context.typeof(macro null); // TMono(<mono>)
@@ -58,25 +58,25 @@ class TypeTools {
 		return Context.follow(t, once);
 		
 	/**
-		Returns a syntax-level type corresponding to Type [t].
+		Returns a syntax-level type corresponding to Type `t`.
 		
-		This function is mostly inverse to ComplexTypeTools.toType(), but may
+		This function is mostly inverse to `ComplexTypeTools.toType`, but may
 		lose some information on types that do not have a corresponding syntax
 		version, such as monomorphs. In these cases, the result is null.
 		
-		If [t] is null, an internal exception is thrown.
+		If `t` is null, an internal exception is thrown.
 	**/
 	static public inline function toComplexType( t : Type ) : ComplexType
 		return Context.toComplexType(t);
 		
 	/**
-		Tries to extract the class instance stored inside [t].
+		Tries to extract the class instance stored inside `t`.
 		
-		If [t] is a class instance TInst(c,pl), c is returned.
+		If `t` is a class instance `TInst(c,pl)`, c is returned.
 		
-		If [t] is of a different type, an exception of type String is thrown.
+		If `t` is of a different type, an exception of type String is thrown.
 
-		If [t] is null, the result is null.
+		If `t` is null, the result is null.
 	**/
 	static public function getClass( t : Type ) return t == null ? null : switch(follow(t)) {
 		case TInst(c, _): c.get();
@@ -84,13 +84,13 @@ class TypeTools {
 	}
 	
 	/**
-		Tries to extract the enum instance stored inside [t].
+		Tries to extract the enum instance stored inside `t`.
 		
-		If [t] is an enum instance TEnum(e,pl), e is returned.
+		If `t` is an enum instance `TEnum(e,pl)`, e is returned.
 		
-		If [t] is of a different type, an exception of type String is thrown.
+		If `t` is of a different type, an exception of type String is thrown.
 
-		If [t] is null, the result is null.
+		If `t` is null, the result is null.
 	**/
 	static public function getEnum( t : Type ) return t == null ? null : switch(follow(t)) {
 		case TEnum(e, _): e.get();
@@ -98,7 +98,7 @@ class TypeTools {
 	}
 
 	/**
-		Converts type [t] to a human-readable String representation.
+		Converts type `t` to a human-readable String representation.
 	**/
 	static public function toString( t : Type ) : String return new String(Context.load("s_type", 1)(t));
 	#end

+ 1 - 1
std/haxe/remoting/SocketProtocol.hx

@@ -35,7 +35,7 @@ typedef Socket =
 	#end
 
 /**
-	The haXe Remoting Socket Protocol is composed of serialized string exchanges.
+	The Haxe Remoting Socket Protocol is composed of serialized string exchanges.
 	Each string is prefixed with a 2-chars header encoding the string size (up to 4KB)
 	and postfixed with the \0 message delimiting char.
 	A request string is composed of the following serialized values :

+ 2 - 0
std/haxe/rtti/CType.hx

@@ -66,6 +66,7 @@ typedef ClassField = {
 	var platforms : Platforms;
 	var meta : MetaData;
 	var line : Null<Int>;
+	var overloads : Null<List<ClassField>>;
 }
 
 typedef TypeInfos = {
@@ -110,6 +111,7 @@ typedef Typedef = {> TypeInfos,
 typedef Abstractdef = {> TypeInfos,
 	var subs : Array<CType>;
 	var supers : Array<CType>;
+	var impl : Classdef;
 }
 
 enum TypeTree {

+ 16 - 1
std/haxe/rtti/XmlParser.hx

@@ -231,6 +231,7 @@ class XmlParser {
 					else
 						tinf.doc = inf.doc;
 				}
+				if (tinf.path == "haxe._Int64.NativeInt64") continue;
 				if( tinf.module == inf.module && tinf.doc == inf.doc && tinf.isPrivate == inf.isPrivate )
 					switch( ct ) {
 					case TClassdecl(c):
@@ -331,6 +332,14 @@ class XmlParser {
 		}
 		return ml;
 	}
+	
+	function xoverloads( x : Fast ) : List<ClassField> {
+		var l = new List();
+		for ( m in x.elements ) {
+			l.add(xclassfield(m));
+		}
+		return l;
+	}
 
 	function xpath( x : Fast ) : PathParams {
 		var path = mkPath(x.att.path);
@@ -388,10 +397,12 @@ class XmlParser {
 		var t = xtype(e.next());
 		var doc = null;
 		var meta = [];
+		var overloads = null;
 		for( c in e )
 			switch( c.name ) {
 			case "haxe_doc": doc = c.innerData;
 			case "meta": meta = xmeta(c);
+			case "overloads": overloads = xoverloads(c);
 			default: xerror(c);
 			}
 		return {
@@ -406,6 +417,7 @@ class XmlParser {
 			params : if( x.has.params ) mkTypeParams(x.att.params) else null,
 			platforms : defplat(),
 			meta : meta,
+			overloads: overloads
 		};
 	}
 
@@ -465,7 +477,7 @@ class XmlParser {
 	}
 
 	function xabstract( x : Fast ) : Abstractdef {
-		var doc = null;
+		var doc = null, impl = null;
 		var meta = [], subs = [], supers = [];
 		for( c in x.elements )
 			switch( c.name ) {
@@ -479,6 +491,8 @@ class XmlParser {
 			case "from":
 				for( t in c.elements )
 					supers.push(xtype(t));
+			case "impl":
+				impl = xclass(c.node.resolve("class"));
 			default:
 				xerror(c);
 			}
@@ -493,6 +507,7 @@ class XmlParser {
 			meta : meta,
 			subs : subs,
 			supers : supers,
+			impl: impl
 		};
 	}
 

+ 0 - 69
std/java/_std/Array.hx

@@ -22,11 +22,6 @@
 import java.lang.System;
 import java.NativeArray;
 
-/**
-	An Array is a storage for values. You can access it using indexes or
-	with its API. On the server side, it's often better to use a [List] which
-	is less memory and CPU consuming, unless you really need indexed access.
-**/
 @:classCode('
 	public Array(T[] _native)
 	{
@@ -36,9 +31,6 @@ import java.NativeArray;
 ')
 @:final @:coreApi class Array<T> implements ArrayAccess<T> {
 
-	/**
-		The length of the Array
-	**/
 	public var length(default,null) : Int;
 
 	private var __a:NativeArray<T>;
@@ -59,18 +51,12 @@ import java.NativeArray;
 		return null;
 	}
 
-	/**
-		Creates a new Array.
-	**/
 	public function new() : Void
 	{
 		this.length = 0;
 		this.__a = new NativeArray(0);
 	}
 
-	/**
-		Returns a new Array by appending [a] to [this].
-	**/
 	public function concat( a : Array<T> ) : Array<T>
 	{
 		var length = length;
@@ -101,9 +87,6 @@ import java.NativeArray;
 		this.length = len;
 	}
 
-	/**
-		Returns a representation of an array with [sep] for separating each element.
-	**/
 	public function join( sep : String ) : String
 	{
 		var buf = new StringBuf();
@@ -123,9 +106,6 @@ import java.NativeArray;
 		return buf.toString();
 	}
 
-	/**
-		Removes the last element of the array and returns it.
-	**/
 	public function pop() : Null<T>
 	{
 		var __a = __a;
@@ -142,9 +122,6 @@ import java.NativeArray;
 		}
 	}
 
-	/**
-		Adds the element [x] at the end of the array.
-	**/
 	public function push(x : T) : Int
 	{
 		var length = length;
@@ -161,9 +138,6 @@ import java.NativeArray;
 		return ++this.length;
 	}
 
-	/**
-		Reverse the order of elements of the Array.
-	**/
 	public function reverse() : Void
 	{
 		var i = 0;
@@ -180,9 +154,6 @@ import java.NativeArray;
 		}
 	}
 
-	/**
-		Removes the first element and returns it.
-	**/
 	public function shift() : Null<T>
 	{
 		var l = this.length;
@@ -199,12 +170,6 @@ import java.NativeArray;
 		return x;
 	}
 
-	/**
-		Copies the range of the array starting at [pos] up to,
-		but not including, [end]. Both [pos] and [end] can be
-		negative to count from the end: -1 is the last item in
-		the array.
-	**/
 	public function slice( pos : Int, ?end : Int ) : Array<T>
 	{
 		if( pos < 0 ){
@@ -227,11 +192,6 @@ import java.NativeArray;
 		return ofNative(newarr);
 	}
 
-	/**
-		Sort the Array according to the comparison public function [f].
-		[f(x,y)] should return [0] if [x == y], [>0] if [x > y]
-		and [<0] if [x < y].
-	**/
 	public function sort( f : T -> T -> Int ) : Void
 	{
 		if (length == 0)
@@ -239,10 +199,6 @@ import java.NativeArray;
 		quicksort(0, length - 1, f);
 	}
 
-	/**
-		quicksort author: tong disktree
-		http://blog.disktree.net/2008/10/26/array-sort-performance.html
-	 */
 	private function quicksort( lo : Int, hi : Int, f : T -> T -> Int ) : Void
 	{
         var buf = __a;
@@ -264,9 +220,6 @@ import java.NativeArray;
         if( i < hi ) quicksort( i, hi, f );
 	}
 
-	/**
-		Removes [len] elements starting from [pos] an returns them.
-	**/
 	public function splice( pos : Int, len : Int ) : Array<T>
 	{
 		if( len < 0 ) return new Array();
@@ -318,9 +271,6 @@ import java.NativeArray;
 			a[this.length + len] = null;
 	}
 
-	/**
-		Returns a displayable representation of the Array content.
-	**/
 	public function toString() : String
 	{
 		var ret = new StringBuf();
@@ -340,9 +290,6 @@ import java.NativeArray;
 		return ret.toString();
 	}
 
-	/**
-		Adds the element [x] at the start of the array.
-	**/
 	public function unshift( x : T ) : Void
 	{
 		var __a = __a;
@@ -362,10 +309,6 @@ import java.NativeArray;
 		++this.length;
 	}
 
-	/**
-		Inserts the element [x] at the position [pos].
-		All elements after [pos] are moved one index ahead.
-	**/
 	public function insert( pos : Int, x : T ) : Void
 	{
 		var l = this.length;
@@ -400,11 +343,6 @@ import java.NativeArray;
 		}
 	}
 
-	/**
-		Removes the first occurence of [x].
-		Returns false if [x] was not present.
-		Elements are compared by using standard equality.
-	**/
 	public function remove( x : T ) : Bool
 	{
 		var __a = __a;
@@ -424,10 +362,6 @@ import java.NativeArray;
 		return false;
 	}
 
-	/**
-		Returns a copy of the Array. The values are not
-		copied, only the Array structure.
-	**/
 	public function copy() : Array<T>
 	{
 		var len = length;
@@ -437,9 +371,6 @@ import java.NativeArray;
 		return ofNative(newarr);
 	}
 
-	/**
-		Returns an iterator of the Array values.
-	**/
 	public function iterator() : Iterator<T>
 	{
 		var i = 0;

+ 0 - 46
std/java/_std/Date.hx

@@ -27,9 +27,6 @@ import haxe.Int64;
 {
 	private var date:java.util.Date;
 
-	/**
-		Creates a new date object.
-	**/
 	public function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void
 	{
 		//issue #1769
@@ -37,77 +34,46 @@ import haxe.Int64;
 		date = new java.util.Date(year, month, day, hour, min, sec);
 	}
 
-	/**
-		Returns the timestamp of the date. It's the number of milliseconds
-		elapsed since 1st January 1970. It might only have a per-second precision
-		depending on the platforms.
-	**/
 	public inline function getTime() : Float
 	{
 		return cast date.getTime();
 	}
 
-	/**
-		Returns the hours value of the date (0-23 range).
-	**/
 	public inline function getHours() : Int
 	{
 		return date.getHours();
 	}
 
-	/**
-		Returns the minutes value of the date (0-59 range).
-	**/
 	public inline function getMinutes() : Int
 	{
 		return date.getMinutes();
 	}
 
-	/**
-		Returns the seconds of the date (0-59 range).
-	**/
 	public inline function getSeconds() : Int
 	{
 		return date.getSeconds();
 	}
 
-	/**
-		Returns the full year of the date.
-	**/
 	public inline function getFullYear() : Int
 	{
 		return date.getYear() + 1900;
 	}
 
-	/**
-		Returns the month of the date (0-11 range).
-	**/
 	public inline function getMonth() : Int
 	{
 		return date.getMonth();
 	}
 
-	/**
-		Returns the day of the date (1-31 range).
-	**/
 	public inline function getDate() : Int
 	{
 		return date.getDate();
 	}
 
-	/**
-		Returns the week day of the date (0-6 range).
-	**/
 	public inline function getDay() : Int
 	{
 		return date.getDay();
 	}
 
-	/**
-		Returns a string representation for the Date, by using the
-		standard format [YYYY-MM-DD HH:MM:SS]. See [DateTools.format] for
-		other formating rules.
-	**/
 	public function toString():String
 	{
 		var m = date.getMonth() + 1;
@@ -123,9 +89,6 @@ import haxe.Int64;
 			+":"+(if( s < 10 ) "0"+s else ""+s);
 	}
 
-	/**
-		Returns a Date representing the current local time.
-	**/
 	static public function now() : Date
 	{
 		var d = new Date(0, 0, 0, 0, 0, 0);
@@ -133,10 +96,6 @@ import haxe.Int64;
 		return d;
 	}
 
-	/**
-		Returns a Date from a timestamp [t] which is the number of
-		milliseconds elapsed since 1st January 1970.
-	**/
 	static public function fromTime( t : Float ) : Date
 	{
 		var d = new Date(0, 0, 0, 0, 0, 0);
@@ -144,11 +103,6 @@ import haxe.Int64;
 		return d;
 	}
 
-	/**
-		Returns a Date from a formated string of one of the following formats :
-		[YYYY-MM-DD hh:mm:ss] or [YYYY-MM-DD] or [hh:mm:ss]. The first two formats
-		are expressed in local time, the third in UTC Epoch.
-	**/
 	static public function fromString( s : String ) : Date
 	{
 		switch( s.length )

+ 3 - 3
std/java/_std/EReg.hx

@@ -21,7 +21,7 @@
  */
 import java.util.regex.*;
 
-@:coreType class EReg {
+@:coreApi class EReg {
 
 	private var pattern:String;
 	private var matcher:Matcher;
@@ -136,12 +136,12 @@ import java.util.regex.*;
 		}
 	}
 
-	inline function start(group:Int)
+	inline function start(group:Int) : Int
 	{
 		return matcher.start(group);
 	}
 
-	inline function len(group:Int)
+	inline function len(group:Int) : Int
 	{
 		return matcher.end(group) - matcher.start(group);
 	}

+ 1 - 3
std/java/_std/Math.hx

@@ -19,9 +19,7 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-/**
-	This class defines mathematical functions and constants.
-**/
+
 @:coreApi
 @:native("java.lang.Math") extern class Math
 {

部分文件因文件數量過多而無法顯示