Browse Source

added ml generator

Nicolas Cannasse 7 years ago
parent
commit
228d0613f8
4 changed files with 44 additions and 1 deletions
  1. 9 1
      src/compiler/main.ml
  2. 3 0
      src/context/common.ml
  3. 3 0
      src/core/globals.ml
  4. 29 0
      src/generators/genml.ml

+ 9 - 1
src/compiler/main.ml

@@ -78,7 +78,7 @@ let error ctx msg p =
 	ctx.has_error <- true
 	ctx.has_error <- true
 
 
 let reserved_flags = [
 let reserved_flags = [
-	"cross";"js";"lua";"neko";"flash";"php";"cpp";"cs";"java";"python";
+	"cross";"js";"lua";"neko";"flash";"php";"cpp";"cs";"java";"python";"ml";
 	"as3";"swc";"macro";"sys";"static"
 	"as3";"swc";"macro";"sys";"static"
 	]
 	]
 
 
@@ -269,6 +269,9 @@ module Initialize = struct
 			| Eval ->
 			| Eval ->
 				add_std "eval";
 				add_std "eval";
 				"eval"
 				"eval"
+			| Ml ->
+				add_std "ml";
+				"ml"
 end
 end
 
 
 let generate tctx ext xml_out interp swf_header =
 let generate tctx ext xml_out interp swf_header =
@@ -318,6 +321,8 @@ let generate tctx ext xml_out interp swf_header =
 			Genpy.generate,"python"
 			Genpy.generate,"python"
 		| Hl ->
 		| Hl ->
 			Genhl.generate,"hl"
 			Genhl.generate,"hl"
+		| Ml ->
+			Genml.generate,"ml"
 		| Eval ->
 		| Eval ->
 			(fun _ -> MacroContext.interpret tctx),"eval"
 			(fun _ -> MacroContext.interpret tctx),"eval"
 		| Cross ->
 		| Cross ->
@@ -497,6 +502,9 @@ try
 		("-hl",Arg.String (fun file ->
 		("-hl",Arg.String (fun file ->
 			Initialize.set_platform com Hl file;
 			Initialize.set_platform com Hl file;
 		),"<file> : compile HL code as target file");
 		),"<file> : compile HL code as target file");
+		("-ml",Arg.String (fun dir ->
+			Initialize.set_platform com Ml dir;
+		),"<directory> : generate OCaml code into target directory");
 		("-xml",Arg.String (fun file ->
 		("-xml",Arg.String (fun file ->
 			Parser.use_doc := true;
 			Parser.use_doc := true;
 			xml_out := Some file
 			xml_out := Some file

+ 3 - 0
src/context/common.ml

@@ -478,6 +478,7 @@ let short_platform_name = function
 	| Python -> "py"
 	| Python -> "py"
 	| Hl -> "hl"
 	| Hl -> "hl"
 	| Eval -> "evl"
 	| Eval -> "evl"
+	| Ml -> "ml"
 
 
 let stats =
 let stats =
 	{
 	{
@@ -585,6 +586,8 @@ let get_config com =
 			pf_static = false;
 			pf_static = false;
 			pf_pad_nulls = true;
 			pf_pad_nulls = true;
 		}
 		}
+	| Ml ->
+		default_config
 
 
 let memory_marker = [|Unix.time()|]
 let memory_marker = [|Unix.time()|]
 
 

+ 3 - 0
src/core/globals.ml

@@ -20,6 +20,7 @@ type platform =
 	| Python
 	| Python
 	| Hl
 	| Hl
 	| Eval
 	| Eval
+	| Ml
 
 
 let version = 4000
 let version = 4000
 let version_major = version / 1000
 let version_major = version / 1000
@@ -42,6 +43,7 @@ let platforms = [
 	Python;
 	Python;
 	Hl;
 	Hl;
 	Eval;
 	Eval;
+	Ml;
 ]
 ]
 
 
 let platform_name = function
 let platform_name = function
@@ -57,6 +59,7 @@ let platform_name = function
 	| Python -> "python"
 	| Python -> "python"
 	| Hl -> "hl"
 	| Hl -> "hl"
 	| Eval -> "eval"
 	| Eval -> "eval"
+	| Ml -> "ml"
 
 
 let platform_list_help = function
 let platform_list_help = function
 	| [] -> ""
 	| [] -> ""

+ 29 - 0
src/generators/genml.ml

@@ -0,0 +1,29 @@
+(*
+ * Copyright (C)2005-2018 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *)
+
+open Globals
+open Ast
+open Type
+open Common
+
+let generate com =
+	failwith "TODO"