Переглянути джерело

[lua] sidestep #7851 by including helper code directly in genlua

Dan Korostelev 6 роки тому
батько
коміт
436ef40d27
4 змінених файлів з 15 додано та 19 видалено
  1. 15 4
      src/generators/genlua.ml
  2. 0 6
      std/lua/_lua/_hx_apply.lua
  3. 0 4
      std/lua/_std/Array.hx
  4. 0 5
      std/lua/_std/Std.hx

+ 15 - 4
src/generators/genlua.ml

@@ -1944,13 +1944,24 @@ let generate com =
     if has_feature ctx "Class" || has_feature ctx "Type.getClassName" then add_feature ctx "lua.Boot.isClass";
     if has_feature ctx "Enum" || has_feature ctx "Type.getEnumName" then add_feature ctx "lua.Boot.isEnum";
 
+    let print_file path =
+        let file_content = Std.input_file ~bin:true path in
+        print ctx "%s\n" file_content;
+    in
+
+    (* table-to-array helper *)
+    print_file (Common.find_file com "lua/_lua/_hx_tab_array.lua");
+
+    (* lua workarounds for basic anonymous object functionality *)
+    print_file (Common.find_file com "lua/_lua/_hx_anon.lua");
+
+    (* class reflection metadata *)
+    print_file (Common.find_file com "lua/_lua/_hx_classes.lua");
+
     let include_files = List.rev com.include_files in
     List.iter (fun file ->
         match file with
-        | path, "top" ->
-            let file_content = Std.input_file ~bin:true (fst file) in
-            print ctx "%s\n" file_content;
-            ()
+        | path, "top" -> print_file path
         | _ -> ()
     ) include_files;
 

+ 0 - 6
std/lua/_lua/_hx_apply.lua

@@ -1,6 +0,0 @@
-local function _hx_apply(f, ...)
-  return f(...)
-end
-local function _hx_apply_self(self, f, ...)
-  return self[f](self,...)
-end

+ 0 - 4
std/lua/_std/Array.hx

@@ -223,9 +223,5 @@ class Array<T> {
 			this.length = len;
 		}
 	}
-	private static function __init__() : Void{
-		// table-to-array helper
-		haxe.macro.Compiler.includeFile("lua/_lua/_hx_tab_array.lua");
-	}
 
 }

+ 0 - 5
std/lua/_std/Std.hx

@@ -81,11 +81,6 @@ import lua.NativeStringTools;
 	}
 
 	static function __init__() : Void untyped {
-		// lua workarounds for basic anonymous object functionality
-		haxe.macro.Compiler.includeFile("lua/_lua/_hx_anon.lua");
-
-		// class reflection metadata
-		haxe.macro.Compiler.includeFile("lua/_lua/_hx_classes.lua");
 		__feature__("lua.Boot.isClass", String.__name__ = __feature__("Type.getClassName", __lua_table__(["String"]),true));
 		__feature__("Type.resolveClass",_hxClasses["Array"] = Array);
 		__feature__("lua.Boot.isClass",Array.__name__ = __feature__("Type.getClassName",__lua_table__(["Array"]),true));