瀏覽代碼

Merge pull request #2707 from HaxeFoundation/development

3.1.0 hotfix
Simon Krajewski 11 年之前
父節點
當前提交
fa61921d2a
共有 9 個文件被更改,包括 82 次插入92 次删除
  1. 5 5
      README.md
  2. 2 2
      extra/CHANGES.txt
  3. 4 4
      main.ml
  4. 6 17
      optimizer.ml
  5. 10 10
      std/haxe/io/Path.hx
  6. 47 47
      std/haxe/macro/Context.hx
  7. 5 5
      tests/RunTravis.hx
  8. 2 2
      tests/unit/RunJava.hx
  9. 1 0
      tests/unit/unitstd/haxe/io/Path.unit.hx

+ 5 - 5
README.md

@@ -35,12 +35,12 @@ For the complete Haxe licenses, please see http://haxe.org/doc/license or [doc/L
 
 ## Installing Haxe
 
-The latest stable release is [Haxe v3.0.1](http://haxe.org/download). Pre-built binaries are available for your platform:
+The latest stable release is [Haxe v3.1.0](http://haxe.org/download). Pre-built binaries are available for your platform:
 
- * **[Windows installer](http://haxe.org/file/haxe-3.0.1-win.exe)**
- * **[OSX installer](http://haxe.org/file/haxe-3.0.1-osx-installer.pkg)**
- * **[Linux 32-bit binaries](http://haxe.org/file/haxe-3.0.1-linux32.tar.gz)**
- * **[Linux 64-bit binaries](http://haxe.org/file/haxe-3.0.1-linux64.tar.gz)**
+ * **[Windows installer](http://haxe.org/file/haxe-3.1.0-win.exe)**
+ * **[OSX installer](http://haxe.org/file/haxe-3.1.0-osx-installer.pkg)**
+ * **[Linux 32-bit binaries](http://haxe.org/file/haxe-3.1.0-linux32.tar.gz)**
+ * **[Linux 64-bit binaries](http://haxe.org/file/haxe-3.1.0-linux64.tar.gz)**
  
 Automated development builds are available from [build.haxe.org](http://build.haxe.org).
 

+ 2 - 2
extra/CHANGES.txt

@@ -16,7 +16,6 @@
 	cs : support for native delegates
 	cs : support for attributes
 	cs : support for events
-	js : added -D js-flatten
 
 	Standard Library:
 
@@ -38,6 +37,8 @@
 	all : improved inline constructors by detecting more cases where it can be applied
 	js : improved inlining
 	js : always use JSON extern (compile with -D old-browser to disable)
+	js : added -D js-flatten
+	js : added -D js-es5
 	cpp : improved side-effect detection
 
 	Bugfixes:
@@ -46,7 +47,6 @@
 	all : implemented constraints check on enum and enum field type parameters
 	all : fixed memory leak in compilation server and optimized caching in general
 	all : fixed issue with invalid lowercase class name in Windows completion
-	js : window and console are reserved words. Access them with __js__ instead of untyped.
 	flash : fixed font embedding with UTF8 chars
 	flash : give error if non-nullable basic types are skipped in a call
 	flash : give error if assigned parent class field values would be overwritten by super()

+ 4 - 4
main.ml

@@ -45,9 +45,9 @@ exception Abort
 exception Completion of string
 
 
-let version = 30100
-let version_major = version / 10000
-let version_minor = (version mod 10000) / 100
+let version = 3100
+let version_major = version / 1000
+let version_minor = (version mod 1000) / 100
 let version_revision = (version mod 100)
 let version_is_stable = version_minor land 1 = 0
 
@@ -927,7 +927,7 @@ try
 	let pre_compilation = ref [] in
 	let interp = ref false in
 	let swf_version = ref false in
-	Common.define_value com Define.HaxeVer (float_repres (float_of_int version /. 10000.));
+	Common.define_value com Define.HaxeVer (float_repres (float_of_int version /. 1000.));
 	Common.define_value com Define.HxcppApiLevel "310";
 	Common.raw_define com "haxe3";
 	Common.define_value com Define.Dce "std";

+ 6 - 17
optimizer.ml

@@ -754,24 +754,13 @@ let sanitize_expr com e =
 		let e2 = if loop e2 false then parent e2 else e2 in
 		{ e with eexpr = TBinop (op,e1,e2) }
 	| TUnop (op,mode,e1) ->
-		let unop op mode e1 =
-			let rec loop ee =
-				match ee.eexpr with
-				| TBinop _ | TIf _ -> parent e1
-				| TCast (e,None) -> loop e
-				| _ -> e1
-			in
-			{ e with eexpr = TUnop (op,mode,loop e1)}
-		in
-		let rec loop e = match e.eexpr with
-			| TUnop((Not | Neg | NegBits) as op2,Prefix,e2) when op = op2 ->
-				e2
-			| TCast(e1,None) | TParenthesis(e1) | TMeta(_, e1) ->
-				loop e1
-			| _ ->
-				unop op mode e1
+		let rec loop ee =
+			match ee.eexpr with
+			| TBinop _ | TIf _ | TUnop _ -> parent e1
+			| TCast (e,None) -> loop e
+			| _ -> e1
 		in
-		loop e1
+		{ e with eexpr = TUnop (op,mode,loop e1)}
 	| TIf (e1,e2,eelse) ->
 		let e1 = parent e1 in
 		let e2 = (if (eelse <> None && has_if e2) || (match e2.eexpr with TIf _ -> true | _ -> false) then block e2 else complex e2) in

+ 10 - 10
std/haxe/io/Path.hx

@@ -174,10 +174,10 @@ class Path {
 
 	/**
 		Joins all paths in `paths` together.
-		
+
 		If `paths` is empty, the empty String `""` is returned. Otherwise the
 		paths are joined with a slash between them.
-		
+
 		If `paths` is null, the result is unspecified.
 	**/
 	public static function join(paths:Array<String>) : String {
@@ -194,10 +194,10 @@ class Path {
 
 	/**
 		Normalize a given `path` (e.g. make '/usr/local/../lib' to '/usr/lib').
-		
+
 		Also replaces backslashes \ with slashes / and afterwards turns
 		multiple slashes into a single one.
-		
+
 		If `path` is null, the result is unspecified.
 	**/
 	public static function normalize(path : String) : String {
@@ -207,7 +207,6 @@ class Path {
 			return slash;
 		}
 
-		var prependSlash = (path.charAt(0) == slash || path.charAt(0) == '.');
 		var target = [];
 		var src;
 		var parts;
@@ -219,14 +218,15 @@ class Path {
 
 			if(token == '..') {
 				target.pop();
-			} else if(token != '' && token != '.') {
+			} else if(token != '.') {
 				target.push(token);
 			}
 		}
-		var regex = ~/\/\//g;
+
+		var regex = ~/([^:])\/+/g;
 		var tmp = target.join(slash);
-		var result = regex.replace(tmp, slash);
-		return (prependSlash ? slash : '') + result;
+		var result = regex.replace(tmp, "$1" +slash);
+		return result;
 	}
 
 	/**
@@ -265,7 +265,7 @@ class Path {
 
 		If `path` is null, the result is unspecified.
 	**/
-	@:require(haxe_ver >= 3.01)
+	@:require(haxe_ver >= 3.1)
 	public static function removeTrailingSlashes ( path : String ) : String {
 		while (true) {
 			switch(path.charCodeAt(path.length - 1)) {

+ 47 - 47
std/haxe/macro/Context.hx

@@ -26,11 +26,11 @@ import haxe.macro.Type.TypedExpr;
 
 /**
 	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`
@@ -46,7 +46,7 @@ class Context {
 	public static function error( msg : String, pos : Position ) : Dynamic {
 		return load("error",2)(untyped msg.__s, pos);
 	}
-	
+
 	/**
 		Displays a compilation error `msg` at the given `Position` `pos`
 		and aborts the compilation.
@@ -64,10 +64,10 @@ class Context {
 
 	/**
 		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.
 	**/
@@ -78,7 +78,7 @@ class Context {
 	/**
 		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`.
 	**/
@@ -99,23 +99,23 @@ class Context {
 
 	/**
 		Returns the type which is expected at the place the macro is called.
-		
+
 		This affects usages such as `var x:Int = macroCall()`, where the
 		expected type will be reported as Int.
-		
+
 		Might return null if no specific type is expected or if the calling
 		macro is not an expression-macro.
 	**/
-	@:require(haxe_ver >= 3.01)
+	@:require(haxe_ver >= 3.1)
 	public static function getExpectedType():Null<Type> {
 		var l : Type = load("expected_type", 0)();
 		if( l == null ) return null;
 		return l;
 	}
-	
+
 	/**
 		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>> {
@@ -133,10 +133,10 @@ class Context {
 	public static function getLocalModule() : String {
 		return new String(load("local_module", 0)());
 	}
-	
+
 	/**
 		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> {
@@ -147,7 +147,7 @@ class Context {
 
 	/**
 		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> {
@@ -159,7 +159,7 @@ class Context {
 	/**
 		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>> {
@@ -169,10 +169,10 @@ class Context {
 	/**
 		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> {
@@ -181,7 +181,7 @@ class Context {
 
 	/**
 		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`.
 	**/
@@ -191,12 +191,12 @@ class Context {
 
 	/**
 		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 {
@@ -206,10 +206,10 @@ class Context {
 
 	/**
 		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 {
@@ -219,10 +219,10 @@ class Context {
 	/**
 		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> {
@@ -231,7 +231,7 @@ class Context {
 
 	/**
 		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 {
@@ -248,11 +248,11 @@ class Context {
 
 	/**
 		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 {
@@ -269,7 +269,7 @@ class Context {
 	/**
 		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.
@@ -277,23 +277,23 @@ class Context {
 	public static function onGenerate( callback : Array<Type> -> Void ) {
 		load("on_generate",1)(callback);
 	}
-	
+
 	/**
 		Adds a callback function `callback` which is invoked after the compiler
 		generation phase.
-		
+
 		Compilation has completed at this point and cannot be influenced
 		anymore. However, contextual information is still available.
 	**/
-	@:require(haxe_ver >= 3.01)
+	@:require(haxe_ver >= 3.1)
 	public static function onAfterGenerate( callback : Void -> Void ) {
 		load("after_generate",1)(callback);
 	}
-	
+
 	/**
 		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.
@@ -304,7 +304,7 @@ class Context {
 
 	/**
 		Types expression `e` and returns its type.
-		
+
 		Typing the expression may result in an compiler error which can be
 		caught using `try ... catch`.
 	**/
@@ -314,18 +314,18 @@ class Context {
 
 	/**
 		Types expression `e` and returns the corresponding `TypedExpr`.
-		
+
 		Typing the expression may result in an compiler error which can be
 		caught using `try ... catch`.
 	**/
-	@:require(haxe_ver >= 3.01)
+	@:require(haxe_ver >= 3.1)
 	public static function typeExpr( e : Expr ) : TypedExpr {
 		return load("type_expr", 1)(e);
 	}
 
 	/**
 		Returns the `ComplexType` corresponding to the given `Type` `t`.
-		
+
 		See `haxe.macro.TypeTools.toComplexType` for details.
 	**/
 	public static function toComplexType( t : Type ) : Null<ComplexType> {
@@ -341,7 +341,7 @@ class Context {
 
 	/**
 		Follows a type.
-		
+
 		See `haxe.macro.TypeTools.follow` for details.
 	**/
 	public static function follow( t : Type, ?once : Bool ) : Type {
@@ -375,15 +375,15 @@ class Context {
 		var r = new haxe.ds.StringMap();
 		for (k in x.keys()) {
 			r.set(k, haxe.io.Bytes.ofData(x.get(k)));
-		} 
+		}
 		return r;
 	}
 
 	/**
 		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 ) {
@@ -392,7 +392,7 @@ class Context {
 
 	/**
 		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> {
@@ -415,7 +415,7 @@ class Context {
 
 	/**
 		Returns a syntax-level expression corresponding to typed expression `t`.
-		
+
 		This process may lose some information.
 	**/
 	public static function getTypedExpr( t : Type.TypedExpr ) : Expr {
@@ -425,10 +425,10 @@ class Context {
 	/**
 		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 ) {
@@ -441,7 +441,7 @@ class Context {
 	public static function registerModuleReuseCall( modulePath : String, macroCall : String ) {
 		load("module_reuse_call", 2)(untyped modulePath.__s,untyped macroCall.__s);
 	}
-	
+
 	/**
 		Register a callback function that will be called everytime the macro context cached is reused with a new
 		compilation. This enable to reset some static vars since the code might have been changed. If the callback

+ 5 - 5
tests/RunTravis.hx

@@ -98,12 +98,12 @@ class RunTravis {
 				Sys.setCwd(Sys.getEnv("HOME") + "/haxelib/hxcpp/git/project/");
 				runCommand("neko", ["build.n"]);
 				Sys.setCwd(unitDir);
-				
+
 				runCommand("haxe", ["compile-cpp.hxml"]);
 				runCommand("./cpp/Test-debug", []);
 
 				runCommand("rm", ["-rf", "cpp"]);
-				
+
 				runCommand("haxe", ["compile-cpp.hxml", "-D", "HXCPP_M64"]);
 				runCommand("./cpp/Test-debug", []);
 			case "js":
@@ -126,11 +126,11 @@ class RunTravis {
 			case "java":
 				runCommand("haxelib", ["git", "hxjava", "https://github.com/HaxeFoundation/hxjava.git"]);
 				runCommand("haxe", ["compile-java.hxml"]);
-				runCommand("java", ["-jar", "java/java.jar"]);
+				runCommand("java", ["-jar", "java/Test-Debug.jar"]);
 			case "cs":
 				runCommand("sudo", ["apt-get", "install", "mono-devel", "mono-mcs", "-y"]);
 				runCommand("haxelib", ["git", "hxcs", "https://github.com/HaxeFoundation/hxcs.git"]);
-				
+
 				runCommand("haxe", ["compile-cs.hxml"]);
 				runCommand("mono", ["cs/bin/Test-Debug.exe"]);
 
@@ -164,4 +164,4 @@ class RunTravis {
 				throw "unknown target: " + target;
 		}
 	}
-}
+}

+ 2 - 2
tests/unit/RunJava.hx

@@ -1,7 +1,7 @@
 class RunJava {
 
 	static function main() {
-		var p = new sys.io.Process("java", ["-jar", neko.Web.getCwd() + "/java/java.jar"]);
+		var p = new sys.io.Process("java", ["-jar", neko.Web.getCwd() + "/java/Test-Debug.jar"]);
 		if( neko.Web.isModNeko )
 			neko.Web.setHeader("Content-Type","text/plain");
 		try {
@@ -14,4 +14,4 @@ class RunJava {
 		neko.Lib.print(StringTools.htmlEscape(p.stderr.readAll().toString()));
 	}
 
-}
+}

+ 1 - 0
tests/unit/unitstd/haxe/io/Path.unit.hx

@@ -65,6 +65,7 @@ haxe.io.Path.normalize("dir1/dir2/../dir3") == "dir1/dir3";
 haxe.io.Path.normalize("/dir1/dir2/../../test.foo") == "/test.foo";
 haxe.io.Path.normalize("dir1/dir2/dir3/dir4/../../../dir5") == "dir1/dir5";
 haxe.io.Path.normalize("C:\\Windows\\..\\Users/Waneck on Windows///.haxelib") == "C:/Users/Waneck on Windows/.haxelib";
+haxe.io.Path.normalize("http://haxe.org/downloads") == "http://haxe.org/downloads";
 
 // join
 haxe.io.Path.join(["dir1/dir2", "dir3/dir4"]) == "dir1/dir2/dir3/dir4";