Quellcode durchsuchen

split up define handling from common

The goal is to lose dependency of parser.mly to the "heavy" common.ml.
Simon Krajewski vor 8 Jahren
Ursprung
Commit
fc2a500e14

+ 2 - 2
src/compiler/main.ml

@@ -218,7 +218,7 @@ module Initialize = struct
 				add_std "neko";
 				"n"
 			| Js ->
-				if not (PMap.exists (fst (Define.infos Define.JqueryVer)) com.defines) then
+				if not (PMap.exists (fst (Define.infos Define.JqueryVer)) com.defines.Define.values) then
 					Common.define_value com Define.JqueryVer "11204";
 
 				let es_version =
@@ -769,7 +769,7 @@ try
 	end else begin
 		ctx.setup();
 		Common.log com ("Classpath : " ^ (String.concat ";" com.class_path));
-		Common.log com ("Defines : " ^ (String.concat ";" (PMap.foldi (fun k v acc -> (match v with "1" -> k | _ -> k ^ "=" ^ v) :: acc) com.defines [])));
+		Common.log com ("Defines : " ^ (String.concat ";" (PMap.foldi (fun k v acc -> (match v with "1" -> k | _ -> k ^ "=" ^ v) :: acc) com.defines.Define.values [])));
 		let t = Common.timer ["typing"] in
 		Typecore.type_expr_ref := (fun ctx e with_type -> Typer.type_expr ctx e with_type);
 		let tctx = Typer.create com in

+ 6 - 6
src/compiler/server.ml

@@ -193,7 +193,7 @@ let rec wait_loop process_params verbose accept =
 	let test_server_messages = DynArray.create () in
 	let cs = CompilationServer.create () in
 	let sign_string com =
-		let sign = get_signature com in
+		let sign = Define.get_signature com.defines in
 		let	sign_id =
 			try
 				CompilationServer.get_sign cs sign;
@@ -245,7 +245,7 @@ let rec wait_loop process_params verbose accept =
 		| true, Some stdin when Common.defined com2 Define.DisplayStdin ->
 			Typeload.parse_file_from_string com2 file p stdin
 		| _ ->
-			let sign = get_signature com2 in
+			let sign = Define.get_signature com2.defines in
 			let ftime = file_time ffile in
 			let fkey = (ffile,sign) in
 			try
@@ -291,7 +291,7 @@ let rec wait_loop process_params verbose accept =
 	let get_changed_directories (ctx : Typecore.typer) =
 		let t = Common.timer ["server";"module cache";"changed dirs"] in
 		let com = ctx.Typecore.com in
-		let sign = get_signature com in
+		let sign = Define.get_signature com.defines in
 		let dirs = try
 			(* First, check if we already have determined changed directories for current compilation. *)
 			Hashtbl.find changed_directories sign
@@ -357,7 +357,7 @@ let rec wait_loop process_params verbose accept =
 	Typeload.type_module_hook := (fun (ctx:Typecore.typer) mpath p ->
 		let t = Common.timer ["server";"module cache"] in
 		let com2 = ctx.Typecore.com in
-		let sign = get_signature com2 in
+		let sign = Define.get_signature com2.defines in
 		let content_changed m file =
 			let ffile = Path.unique_full_path file in
 			let fkey = (ffile,sign) in
@@ -527,9 +527,9 @@ let rec wait_loop process_params verbose accept =
 				end else cache_context ctx.com;
 			);
 			ctx.setup <- (fun() ->
-				let sign = get_signature ctx.com in
+				let sign = Define.get_signature ctx.com.defines in
 				if verbose then begin
-					let defines = PMap.foldi (fun k v acc -> (k ^ "=" ^ v) :: acc) ctx.com.defines [] in
+					let defines = PMap.foldi (fun k v acc -> (k ^ "=" ^ v) :: acc) ctx.com.defines.Define.values [] in
 					print_endline ("Defines " ^ (String.concat "," (List.sort compare defines)));
 					print_endline ("Using signature " ^ Digest.to_hex sign);
 					print_endline ("Display position: " ^ (Printer.s_pos !Parser.resume_display));

+ 37 - 285
src/context/common.ml

@@ -20,6 +20,7 @@
 open Ast
 open Type
 open Globals
+open Define
 
 type package_rule =
 	| Forbidden
@@ -264,13 +265,12 @@ type context = {
 	mutable std_path : string list;
 	mutable class_path : string list;
 	mutable main_class : Type.path option;
-	mutable defines : (string,string) PMap.t;
 	mutable package_rules : (string,package_rule) PMap.t;
 	mutable error : string -> pos -> unit;
 	mutable warning : string -> pos -> unit;
 	mutable load_extern_type : (path -> pos -> (string * Ast.package) option) list; (* allow finding types which are not in sources *)
 	callbacks : compiler_callback;
-	mutable defines_signature : string option;
+	defines : Define.define;
 	mutable print : string -> unit;
 	mutable get_macros : unit -> context option;
 	mutable run_command : string -> int;
@@ -307,23 +307,6 @@ exception Abort of string * pos
 
 let display_default = ref DisplayMode.DMNone
 
-let get_signature com =
-	match com.defines_signature with
-	| Some s -> s
-	| None ->
-		let defines = PMap.foldi (fun k v acc ->
-			(* don't make much difference between these special compilation flags *)
-			match String.concat "_" (ExtString.String.nsplit k "-") with
-			(* If we add something here that might be used in conditional compilation it should be added to
-			   Parser.parse_macro_ident as well (issue #5682). *)
-			| "display" | "use_rtti_doc" | "macro_times" | "display_details" | "no_copt" | "display_stdin" -> acc
-			| _ -> (k ^ "=" ^ v) :: acc
-		) com.defines [] in
-		let str = String.concat "@" (List.sort compare defines) in
-		let s = Digest.string str in
-		com.defines_signature <- Some s;
-		s
-
 module CompilationServer = struct
 	type cache = {
 		c_haxelib : (string list, string list) Hashtbl.t;
@@ -446,237 +429,33 @@ module CompilationServer = struct
 		Hashtbl.remove cs.cache.c_directories key
 end
 
-module Define = struct
-
-	type strict_defined =
-		| AbsolutePath
-		| AdvancedTelemetry
-		| AnnotateSource
-		(* | Analyzer *)
-		| As3
-		| CheckXmlProxy
-		| CoreApi
-		| CoreApiSerialize
-		| Cppia
-		| NoCppiaAst
-		| Dce
-		| DceDebug
-		| Debug
-		| Display
-		| DisplayStdin
-		| DllExport
-		| DllImport
-		| DocGen
-		| Dump
-		| DumpDependencies
-		| DumpIgnoreVarIds
-		| DynamicInterfaceClosures
-		| EraseGenerics
-		| EvalDebugger
-		| EvalStack
-		| EvalTimes
-		| FastCast
-		| Fdb
-		| FileExtension
-		| FlashStrict
-		| FlashUseStage
-		| ForceLibCheck
-		| ForceNativeProperty
-		| FormatWarning
-		| GencommonDebug
-		| HaxeBoot
-		| HaxeVer
-		| HxcppApiLevel
-		| HxcppGcGenerational
-		| HxcppDebugger
-		| IncludePrefix
-		| Interp
-		| JavaVer
-		| JqueryVer
-		| JsClassic
-		| JsEs
-		| JsUnflatten
-		| JsSourceMap
-		| JsEnumsAsObjects
-		| SourceMap
-		| KeepOldOutput
-		| LoopUnrollMaxCost
-		| LuaVer
-		| LuaJit
-		| Macro
-		| MacroDebug
-		| MacroTimes
-		| NekoSource
-		| NekoV1
-		| NetworkSandbox
-		| NetVer
-		| NetTarget
-		| NoCompilation
-		| NoCOpt
-		| NoDeprecationWarnings
-		| NoFlashOverride
-		| NoDebug
-		| NoInline
-		| NoOpt
-		| NoRoot
-		| NoSwfCompress
-		| NoTraces
-		| Objc
-		| OldConstructorInline
-		| OldErrorFormat
-		| PhpPrefix
-		| RealPosition
-		| ReplaceFiles
-		| Scriptable
-		| ShallowExpose
-		| SourceHeader
-		| SourceMapContent
-		| Swc
-		| SwfCompressLevel
-		| SwfDebugPassword
-		| SwfDirectBlit
-		| SwfGpu
-		| SwfMetadata
-		| SwfPreloaderFrame
-		| SwfProtected
-		| SwfScriptTimeout
-		| SwfUseDoAbc
-		| Sys
-		| Unsafe
-		| UseNekoc
-		| UseRttiDoc
-		| Vcproj
-		| NoMacroCache
-		| Last (* must be last *)
-
-	type define_parameter =
-		| HasParam of string
-		| Platform of platform
-		| Platforms of platform list
-
-	let infos = function
-		| AbsolutePath -> "absolute_path",("Print absolute file path in trace output",[])
-		| AdvancedTelemetry -> "advanced-telemetry",("Allow the SWF to be measured with Monocle tool",[Platform Flash])
-		| AnnotateSource -> "annotate_source",("Add additional comments to generated source code",[Platform Cpp])
-		(* | Analyzer -> "analyzer",("Use static analyzer for optimization (experimental)") *)
-		| As3 -> "as3",("Defined when outputing flash9 as3 source code",[])
-		| CheckXmlProxy -> "check_xml_proxy",("Check the used fields of the xml proxy",[])
-		| CoreApi -> "core_api",("Defined in the core api context",[])
-		| CoreApiSerialize -> "core_api_serialize",("Mark some generated core api classes with the Serializable attribute on C#",[Platform Cs])
-		| Cppia -> "cppia",("Generate cpp instruction assembly",[])
-		| NoCppiaAst -> "nocppiaast",("Use legacy cppia generation",[])
-		| Dce -> "dce",("<mode:std|full|no> Set the dead code elimination mode (default std)",[])
-		| DceDebug -> "dce_debug",("Show DCE log",[])
-		| Debug -> "debug",("Activated when compiling with -debug",[])
-		| Display -> "display",("Activated during completion",[])
-		| DisplayStdin -> "display_stdin",("Read the contents of a file specified in --display from standard input",[])
-		| DllExport -> "dll_export",("GenCPP experimental linking",[Platform Cpp])
-		| DllImport -> "dll_import",("Handle Haxe-generated .NET dll imports",[Platform Cs])
-		| DocGen -> "doc_gen",("Do not perform any removal/change in order to correctly generate documentation",[])
-		| Dump -> "dump",("<mode:pretty|record|legacy> Dump typed AST in dump subdirectory using specified mode or non-prettified default",[])
-		| DumpDependencies -> "dump_dependencies",("Dump the classes dependencies in a dump subdirectory",[])
-		| DumpIgnoreVarIds -> "dump_ignore_var_ids",("Remove variable IDs from non-pretty dumps (helps with diff)",[])
-		| DynamicInterfaceClosures -> "dynamic_interface_closures",("Use slow path for interface closures to save space",[Platform Cpp])
-		| EraseGenerics -> "erase_generics",("Erase generic classes on C#",[Platform Cs])
-		| EvalDebugger -> "eval_debugger",("Support debugger in macro/interp mode. Allows host:port value to open a socket. Implies eval_stack.",[])
-		| EvalStack -> "eval_stack",("Record stack information in macro/interp mode",[])
-		| EvalTimes -> "eval_times",("Record per-method execution times in macro/interp mode. Implies eval_stack.",[])
-		| FastCast -> "fast_cast",("Enables an experimental casts cleanup on C# and Java",[Platforms [Cs;Java]])
-		| Fdb -> "fdb",("Enable full flash debug infos for FDB interactive debugging",[Platform Flash])
-		| FileExtension -> "file_extension",("Output filename extension for cpp source code",[Platform Cpp])
-		| FlashStrict -> "flash_strict",("More strict typing for flash target",[Platform Flash])
-		| FlashUseStage -> "flash_use_stage",("Keep the SWF library initial stage",[Platform Flash])
-		(* force_lib_check is only here as a debug facility - compiler checking allows errors to be found more easily *)
-		| ForceLibCheck -> "force_lib_check",("Force the compiler to check -net-lib and -java-lib added classes (internal)",[Platforms [Cs;Java]])
-		| ForceNativeProperty -> "force_native_property",("Tag all properties with :nativeProperty metadata for 3.1 compatibility",[Platform Cpp])
-		| FormatWarning -> "format_warning",("Print a warning for each formated string, for 2.x compatibility",[])
-		| GencommonDebug -> "gencommon_debug",("GenCommon internal",[Platforms [Cs;Java]])
-		| HaxeBoot -> "haxe_boot",("Given the name 'haxe' to the flash boot class instead of a generated name",[Platform Flash])
-		| HaxeVer -> "haxe_ver",("The current Haxe version value",[])
-		| HxcppApiLevel -> "hxcpp_api_level",("Provided to allow compatibility between hxcpp versions",[Platform Cpp])
-		| HxcppGcGenerational -> "HXCPP_GC_GENERATIONAL",("Experimental Garbage Collector",[Platform Cpp])
-		| HxcppDebugger -> "HXCPP_DEBUGGER",("Include additional information for HXCPP_DEBUGGER",[Platform Cpp])
-		| IncludePrefix -> "include_prefix",("prepend path to generated include files",[Platform Cpp])
-		| Interp -> "interp",("The code is compiled to be run with --interp",[])
-		| JavaVer -> "java_ver",("<version:5-7> Sets the Java version to be targeted",[Platform Java])
-		| JqueryVer -> "jquery_ver",("The jQuery version supported by js.jquery.*. The version is encoded as an interger. e.g. 1.11.3 is encoded as 11103",[Platform Js])
-		| JsClassic -> "js_classic",("Don't use a function wrapper and strict mode in JS output",[Platform Js])
-		| JsEs -> "js_es",("Generate JS compilant with given ES standard version (default 5)",[Platform Js; HasParam "version number"])
-		| JsEnumsAsObjects -> "js_enums_as_objects",("Generate enum representation as object instead of as array",[Platform Js])
-		| JsUnflatten -> "js_unflatten",("Generate nested objects for packages and types",[Platform Js])
-		| JsSourceMap -> "js_source_map",("Generate JavaScript source map even in non-debug mode",[Platform Js])
-		| SourceMap -> "source_map",("Generate source map for compiled files (Currently supported for php only)",[Platform Php])
-		| KeepOldOutput -> "keep_old_output",("Keep old source files in the output directory (for C#/Java)",[Platforms [Cs;Java]])
-		| LoopUnrollMaxCost -> "loop_unroll_max_cost",("Maximum cost (number of expressions * iterations) before loop unrolling is canceled (default 250)",[])
-		| LuaJit -> "lua_jit",("Enable the jit compiler for lua (version 5.2 only)",[Platform Lua])
-		| LuaVer -> "lua_ver",("The lua version to target",[Platform Lua])
-		| Macro -> "macro",("Defined when code is compiled in the macro context",[])
-		| MacroDebug -> "macro_debug",("Show warnings for potential macro problems (e.g. macro-in-macro calls)",[])
-		| MacroTimes -> "macro_times",("Display per-macro timing when used with --times",[])
-		| NetVer -> "net_ver",("<version:20-45> Sets the .NET version to be targeted",[Platform Cs])
-		| NetTarget -> "net_target",("<name> Sets the .NET target. Defaults to \"net\". xbox, micro (Micro Framework), compact (Compact Framework) are some valid values",[Platform Cs])
-		| NekoSource -> "neko_source",("Output neko source instead of bytecode",[Platform Neko])
-		| NekoV1 -> "neko_v1",("Keep Neko 1.x compatibility",[Platform Neko])
-		| NetworkSandbox -> "network-sandbox",("Use local network sandbox instead of local file access one",[Platform Flash])
-		| NoCompilation -> "no-compilation",("Disable final compilation",[Platforms [Cs;Java;Cpp;Hl]])
-		| NoCOpt -> "no_copt",("Disable completion optimization (for debug purposes)",[])
-		| NoDebug -> "no_debug",("Remove all debug macros from cpp output",[])
-		| NoDeprecationWarnings -> "no-deprecation-warnings",("Do not warn if fields annotated with @:deprecated are used",[])
-		| NoFlashOverride -> "no-flash-override",("Change overrides on some basic classes into HX suffixed methods, flash only",[Platform Flash])
-		| NoOpt -> "no_opt",("Disable optimizations",[])
-		| NoInline -> "no_inline",("Disable inlining",[])
-		| NoRoot -> "no_root",("Generate top-level types into haxe.root namespace",[Platform Cs])
-		| NoMacroCache -> "no_macro_cache",("Disable macro context caching",[])
-		| NoSwfCompress -> "no_swf_compress",("Disable SWF output compression",[Platform Flash])
-		| NoTraces -> "no_traces",("Disable all trace calls",[])
-		| Objc -> "objc",("Sets the hxcpp output to objective-c++ classes. Must be defined for interop",[Platform Cpp])
-		| OldConstructorInline -> "old-constructor-inline",("Use old constructor inlining logic (from haxe 3.4.2) instead of the reworked version.",[])
-		| OldErrorFormat -> "old-error-format",("Use Haxe 3.x zero-based column error messages instead of new one-based format.",[])
-		| PhpPrefix -> "php_prefix",("Root namespace for generated php classes. E.g. if compiled with`--php-prefix some.sub`, then all classes will be generated in `\\some\\sub` namespace.",[Platform Php])
-		| RealPosition -> "real_position",("Disables Haxe source mapping when targetting C#, removes position comments in Java and Php output",[Platforms [Cs;Java;Php]])
-		| ReplaceFiles -> "replace_files",("GenCommon internal",[Platforms [Java;Cs]])
-		| Scriptable -> "scriptable",("GenCPP internal",[Platform Cpp])
-		| ShallowExpose -> "shallow-expose",("Expose types to surrounding scope of Haxe generated closure without writing to window object",[Platform Js])
-		| SourceHeader -> "source-header",("Print value as comment on top of generated files, use '' value to disable",[])
-		| SourceMapContent -> "source-map-content",("Include the hx sources as part of the JS source map",[Platform Js])
-		| Swc -> "swc",("Output a SWC instead of a SWF",[Platform Flash])
-		| SwfCompressLevel -> "swf_compress_level",("<level:1-9> Set the amount of compression for the SWF output",[Platform Flash])
-		| SwfDebugPassword -> "swf_debug_password",("Set a password for debugging",[Platform Flash])
-		| SwfDirectBlit -> "swf_direct_blit",("Use hardware acceleration to blit graphics",[Platform Flash])
-		| SwfGpu -> "swf_gpu",("Use GPU compositing features when drawing graphics",[Platform Flash])
-		| SwfMetadata -> "swf_metadata",("<file> Include contents of <file> as metadata in the swf",[Platform Flash])
-		| SwfPreloaderFrame -> "swf_preloader_frame",("Insert empty first frame in swf",[Platform Flash])
-		| SwfProtected -> "swf_protected",("Compile Haxe private as protected in the SWF instead of public",[Platform Flash])
-		| SwfScriptTimeout -> "swf_script_timeout",("Maximum ActionScript processing time before script stuck dialog box displays (in seconds)",[Platform Flash])
-		| SwfUseDoAbc -> "swf_use_doabc",("Use DoAbc swf-tag instead of DoAbcDefine",[Platform Flash])
-		| Sys -> "sys",("Defined for all system platforms",[])
-		| Unsafe -> "unsafe",("Allow unsafe code when targeting C#",[Platform Cs])
-		| UseNekoc -> "use_nekoc",("Use nekoc compiler instead of internal one",[Platform Neko])
-		| UseRttiDoc -> "use_rtti_doc",("Allows access to documentation during compilation",[])
-		| Vcproj -> "vcproj",("GenCPP internal",[Platform Cpp])
-		| Last -> assert false
-
-	let get_documentation_list() =
-		let m = ref 0 in
-		let rec loop i =
-			let d = Obj.magic i in
-			if d <> Last then begin
-				let t, (doc,flags) = infos d in
-				let pfs = ref [] in
-				List.iter (function
-				| HasParam s -> () (* TODO *)
-				| Platform p -> pfs := p :: !pfs;
-				| Platforms pl -> pfs := pl @ !pfs;
-				) flags;
-				let pfs = platform_list_help (List.rev !pfs) in
-				if String.length t > !m then m := String.length t;
-				((String.concat "-" (ExtString.String.nsplit t "_")),doc ^ pfs) :: (loop (i + 1))
-			end else
-				[]
-		in
-		let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) (loop 0) in
-		all,!m
-end
+(* Defines *)
+
+module Define = Define
+
+let defined com s =
+	Define.defined com.defines s
+
+let raw_defined com v =
+	Define.raw_defined com.defines v
+
+let defined_value com v =
+	Define.defined_value com.defines v
+
+let defined_value_safe com v =
+	Define.defined_value_safe com.defines v
+
+let define com v =
+	Define.define com.defines v
+
+let raw_define com v =
+	Define.raw_define com.defines v
+
+let define_value com k v =
+	Define.define_value com.defines k v
+
+let raw_defined_value com k =
+	Define.raw_defined_value com.defines k
 
 let short_platform_name = function
 	| Cross -> "x"
@@ -713,7 +492,7 @@ let default_config =
 	}
 
 let get_config com =
-	let defined f = PMap.mem (fst (Define.infos f)) com.defines in
+	let defined f = PMap.mem (fst (Define.infos f)) com.defines.values in
 	match com.platform with
 	| Cross ->
 		default_config
@@ -844,7 +623,6 @@ let create version s_version args =
 		std_path = [];
 		class_path = [];
 		main_class = None;
-		defines = defines;
 		package_rules = PMap.empty;
 		file = "";
 		types = [];
@@ -866,7 +644,10 @@ let create version s_version args =
 		php_prefix = None;
 		js_gen = None;
 		load_extern_type = [];
-		defines_signature = None;
+		defines = {
+			defines_signature = None;
+			values = defines;
+		};
 		get_macros = (fun() -> None);
 		warning = (fun _ _ -> assert false);
 		error = (fun _ _ -> assert false);
@@ -938,35 +719,6 @@ let flash_version_tag = function
 	| v when v >= 12.0 && float_of_int (int_of_float v) = v -> int_of_float v + 11
 	| v -> failwith ("Invalid SWF version " ^ string_of_float v)
 
-let raw_defined ctx v =
-	PMap.mem v ctx.defines
-
-let defined ctx v =
-	raw_defined ctx (fst (Define.infos v))
-
-let raw_defined_value ctx k =
-	PMap.find k ctx.defines
-
-let defined_value ctx v =
-	raw_defined_value ctx (fst (Define.infos v))
-
-let defined_value_safe ctx v =
-	try defined_value ctx v
-	with Not_found -> ""
-
-let raw_define ctx v =
-	let k,v = try ExtString.String.split v "=" with _ -> v,"1" in
-	ctx.defines <- PMap.add k v ctx.defines;
-	let k = String.concat "_" (ExtString.String.nsplit k "-") in
-	ctx.defines <- PMap.add k v ctx.defines;
-	ctx.defines_signature <- None
-
-let define_value ctx k v =
-	raw_define ctx (fst (Define.infos k) ^ "=" ^ v)
-
-let define ctx v =
-	raw_define ctx (fst (Define.infos v))
-
 let init_platform com pf =
 	com.platform <- pf;
 	let name = platform_name pf in
@@ -1204,6 +956,6 @@ let dump_context com = s_record_fields "" [
 	"platform",platform_name com.platform;
 	"std_path",s_list ", " (fun s -> s) com.std_path;
 	"class_path",s_list ", " (fun s -> s) com.class_path;
-	"defines",s_pmap (fun s -> s) (fun s -> s) com.defines;
-	"defines_signature",s_opt (fun s -> Digest.to_hex s) com.defines_signature;
-]
+	"defines",s_pmap (fun s -> s) (fun s -> s) com.defines.values;
+	"defines_signature",s_opt (fun s -> Digest.to_hex s) com.defines.defines_signature;
+]

+ 281 - 0
src/context/define.ml

@@ -0,0 +1,281 @@
+open Globals
+
+type define = {
+	mutable values : (string,string) PMap.t;
+	mutable defines_signature : string option;
+}
+
+type strict_defined =
+	| AbsolutePath
+	| AdvancedTelemetry
+	| AnnotateSource
+	(* | Analyzer *)
+	| As3
+	| CheckXmlProxy
+	| CoreApi
+	| CoreApiSerialize
+	| Cppia
+	| NoCppiaAst
+	| Dce
+	| DceDebug
+	| Debug
+	| Display
+	| DisplayStdin
+	| DllExport
+	| DllImport
+	| DocGen
+	| Dump
+	| DumpDependencies
+	| DumpIgnoreVarIds
+	| DynamicInterfaceClosures
+	| EraseGenerics
+	| EvalDebugger
+	| EvalStack
+	| EvalTimes
+	| FastCast
+	| Fdb
+	| FileExtension
+	| FlashStrict
+	| FlashUseStage
+	| ForceLibCheck
+	| ForceNativeProperty
+	| FormatWarning
+	| GencommonDebug
+	| HaxeBoot
+	| HaxeVer
+	| HxcppApiLevel
+	| HxcppGcGenerational
+	| HxcppDebugger
+	| IncludePrefix
+	| Interp
+	| JavaVer
+	| JqueryVer
+	| JsClassic
+	| JsEs
+	| JsUnflatten
+	| JsSourceMap
+	| JsEnumsAsObjects
+	| SourceMap
+	| KeepOldOutput
+	| LoopUnrollMaxCost
+	| LuaVer
+	| LuaJit
+	| Macro
+	| MacroDebug
+	| MacroTimes
+	| NekoSource
+	| NekoV1
+	| NetworkSandbox
+	| NetVer
+	| NetTarget
+	| NoCompilation
+	| NoCOpt
+	| NoDeprecationWarnings
+	| NoFlashOverride
+	| NoDebug
+	| NoInline
+	| NoOpt
+	| NoRoot
+	| NoSwfCompress
+	| NoTraces
+	| Objc
+	| OldConstructorInline
+	| OldErrorFormat
+	| PhpPrefix
+	| RealPosition
+	| ReplaceFiles
+	| Scriptable
+	| ShallowExpose
+	| SourceHeader
+	| SourceMapContent
+	| Swc
+	| SwfCompressLevel
+	| SwfDebugPassword
+	| SwfDirectBlit
+	| SwfGpu
+	| SwfMetadata
+	| SwfPreloaderFrame
+	| SwfProtected
+	| SwfScriptTimeout
+	| SwfUseDoAbc
+	| Sys
+	| Unsafe
+	| UseNekoc
+	| UseRttiDoc
+	| Vcproj
+	| NoMacroCache
+	| Last (* must be last *)
+
+type define_parameter =
+	| HasParam of string
+	| Platform of platform
+	| Platforms of platform list
+
+let infos = function
+	| AbsolutePath -> "absolute_path",("Print absolute file path in trace output",[])
+	| AdvancedTelemetry -> "advanced-telemetry",("Allow the SWF to be measured with Monocle tool",[Platform Flash])
+	| AnnotateSource -> "annotate_source",("Add additional comments to generated source code",[Platform Cpp])
+	(* | Analyzer -> "analyzer",("Use static analyzer for optimization (experimental)") *)
+	| As3 -> "as3",("Defined when outputing flash9 as3 source code",[])
+	| CheckXmlProxy -> "check_xml_proxy",("Check the used fields of the xml proxy",[])
+	| CoreApi -> "core_api",("Defined in the core api context",[])
+	| CoreApiSerialize -> "core_api_serialize",("Mark some generated core api classes with the Serializable attribute on C#",[Platform Cs])
+	| Cppia -> "cppia",("Generate cpp instruction assembly",[])
+	| NoCppiaAst -> "nocppiaast",("Use legacy cppia generation",[])
+	| Dce -> "dce",("<mode:std|full|no> Set the dead code elimination mode (default std)",[])
+	| DceDebug -> "dce_debug",("Show DCE log",[])
+	| Debug -> "debug",("Activated when compiling with -debug",[])
+	| Display -> "display",("Activated during completion",[])
+	| DisplayStdin -> "display_stdin",("Read the contents of a file specified in --display from standard input",[])
+	| DllExport -> "dll_export",("GenCPP experimental linking",[Platform Cpp])
+	| DllImport -> "dll_import",("Handle Haxe-generated .NET dll imports",[Platform Cs])
+	| DocGen -> "doc_gen",("Do not perform any removal/change in order to correctly generate documentation",[])
+	| Dump -> "dump",("<mode:pretty|record|legacy> Dump typed AST in dump subdirectory using specified mode or non-prettified default",[])
+	| DumpDependencies -> "dump_dependencies",("Dump the classes dependencies in a dump subdirectory",[])
+	| DumpIgnoreVarIds -> "dump_ignore_var_ids",("Remove variable IDs from non-pretty dumps (helps with diff)",[])
+	| DynamicInterfaceClosures -> "dynamic_interface_closures",("Use slow path for interface closures to save space",[Platform Cpp])
+	| EraseGenerics -> "erase_generics",("Erase generic classes on C#",[Platform Cs])
+	| EvalDebugger -> "eval_debugger",("Support debugger in macro/interp mode. Allows host:port value to open a socket. Implies eval_stack.",[])
+	| EvalStack -> "eval_stack",("Record stack information in macro/interp mode",[])
+	| EvalTimes -> "eval_times",("Record per-method execution times in macro/interp mode. Implies eval_stack.",[])
+	| FastCast -> "fast_cast",("Enables an experimental casts cleanup on C# and Java",[Platforms [Cs;Java]])
+	| Fdb -> "fdb",("Enable full flash debug infos for FDB interactive debugging",[Platform Flash])
+	| FileExtension -> "file_extension",("Output filename extension for cpp source code",[Platform Cpp])
+	| FlashStrict -> "flash_strict",("More strict typing for flash target",[Platform Flash])
+	| FlashUseStage -> "flash_use_stage",("Keep the SWF library initial stage",[Platform Flash])
+	(* force_lib_check is only here as a debug facility - compiler checking allows errors to be found more easily *)
+	| ForceLibCheck -> "force_lib_check",("Force the compiler to check -net-lib and -java-lib added classes (internal)",[Platforms [Cs;Java]])
+	| ForceNativeProperty -> "force_native_property",("Tag all properties with :nativeProperty metadata for 3.1 compatibility",[Platform Cpp])
+	| FormatWarning -> "format_warning",("Print a warning for each formated string, for 2.x compatibility",[])
+	| GencommonDebug -> "gencommon_debug",("GenCommon internal",[Platforms [Cs;Java]])
+	| HaxeBoot -> "haxe_boot",("Given the name 'haxe' to the flash boot class instead of a generated name",[Platform Flash])
+	| HaxeVer -> "haxe_ver",("The current Haxe version value",[])
+	| HxcppApiLevel -> "hxcpp_api_level",("Provided to allow compatibility between hxcpp versions",[Platform Cpp])
+	| HxcppGcGenerational -> "HXCPP_GC_GENERATIONAL",("Experimental Garbage Collector",[Platform Cpp])
+	| HxcppDebugger -> "HXCPP_DEBUGGER",("Include additional information for HXCPP_DEBUGGER",[Platform Cpp])
+	| IncludePrefix -> "include_prefix",("prepend path to generated include files",[Platform Cpp])
+	| Interp -> "interp",("The code is compiled to be run with --interp",[])
+	| JavaVer -> "java_ver",("<version:5-7> Sets the Java version to be targeted",[Platform Java])
+	| JqueryVer -> "jquery_ver",("The jQuery version supported by js.jquery.*. The version is encoded as an interger. e.g. 1.11.3 is encoded as 11103",[Platform Js])
+	| JsClassic -> "js_classic",("Don't use a function wrapper and strict mode in JS output",[Platform Js])
+	| JsEs -> "js_es",("Generate JS compilant with given ES standard version (default 5)",[Platform Js; HasParam "version number"])
+	| JsEnumsAsObjects -> "js_enums_as_objects",("Generate enum representation as object instead of as array",[Platform Js])
+	| JsUnflatten -> "js_unflatten",("Generate nested objects for packages and types",[Platform Js])
+	| JsSourceMap -> "js_source_map",("Generate JavaScript source map even in non-debug mode",[Platform Js])
+	| SourceMap -> "source_map",("Generate source map for compiled files (Currently supported for php only)",[Platform Php])
+	| KeepOldOutput -> "keep_old_output",("Keep old source files in the output directory (for C#/Java)",[Platforms [Cs;Java]])
+	| LoopUnrollMaxCost -> "loop_unroll_max_cost",("Maximum cost (number of expressions * iterations) before loop unrolling is canceled (default 250)",[])
+	| LuaJit -> "lua_jit",("Enable the jit compiler for lua (version 5.2 only)",[Platform Lua])
+	| LuaVer -> "lua_ver",("The lua version to target",[Platform Lua])
+	| Macro -> "macro",("Defined when code is compiled in the macro context",[])
+	| MacroDebug -> "macro_debug",("Show warnings for potential macro problems (e.g. macro-in-macro calls)",[])
+	| MacroTimes -> "macro_times",("Display per-macro timing when used with --times",[])
+	| NetVer -> "net_ver",("<version:20-45> Sets the .NET version to be targeted",[Platform Cs])
+	| NetTarget -> "net_target",("<name> Sets the .NET target. Defaults to \"net\". xbox, micro (Micro Framework), compact (Compact Framework) are some valid values",[Platform Cs])
+	| NekoSource -> "neko_source",("Output neko source instead of bytecode",[Platform Neko])
+	| NekoV1 -> "neko_v1",("Keep Neko 1.x compatibility",[Platform Neko])
+	| NetworkSandbox -> "network-sandbox",("Use local network sandbox instead of local file access one",[Platform Flash])
+	| NoCompilation -> "no-compilation",("Disable final compilation",[Platforms [Cs;Java;Cpp;Hl]])
+	| NoCOpt -> "no_copt",("Disable completion optimization (for debug purposes)",[])
+	| NoDebug -> "no_debug",("Remove all debug macros from cpp output",[])
+	| NoDeprecationWarnings -> "no-deprecation-warnings",("Do not warn if fields annotated with @:deprecated are used",[])
+	| NoFlashOverride -> "no-flash-override",("Change overrides on some basic classes into HX suffixed methods, flash only",[Platform Flash])
+	| NoOpt -> "no_opt",("Disable optimizations",[])
+	| NoInline -> "no_inline",("Disable inlining",[])
+	| NoRoot -> "no_root",("Generate top-level types into haxe.root namespace",[Platform Cs])
+	| NoMacroCache -> "no_macro_cache",("Disable macro context caching",[])
+	| NoSwfCompress -> "no_swf_compress",("Disable SWF output compression",[Platform Flash])
+	| NoTraces -> "no_traces",("Disable all trace calls",[])
+	| Objc -> "objc",("Sets the hxcpp output to objective-c++ classes. Must be defined for interop",[Platform Cpp])
+	| OldConstructorInline -> "old-constructor-inline",("Use old constructor inlining logic (from haxe 3.4.2) instead of the reworked version.",[])
+	| OldErrorFormat -> "old-error-format",("Use Haxe 3.x zero-based column error messages instead of new one-based format.",[])
+	| PhpPrefix -> "php_prefix",("Root namespace for generated php classes. E.g. if compiled with`--php-prefix some.sub`, then all classes will be generated in `\\some\\sub` namespace.",[Platform Php])
+	| RealPosition -> "real_position",("Disables Haxe source mapping when targetting C#, removes position comments in Java and Php output",[Platforms [Cs;Java;Php]])
+	| ReplaceFiles -> "replace_files",("GenCommon internal",[Platforms [Java;Cs]])
+	| Scriptable -> "scriptable",("GenCPP internal",[Platform Cpp])
+	| ShallowExpose -> "shallow-expose",("Expose types to surrounding scope of Haxe generated closure without writing to window object",[Platform Js])
+	| SourceHeader -> "source-header",("Print value as comment on top of generated files, use '' value to disable",[])
+	| SourceMapContent -> "source-map-content",("Include the hx sources as part of the JS source map",[Platform Js])
+	| Swc -> "swc",("Output a SWC instead of a SWF",[Platform Flash])
+	| SwfCompressLevel -> "swf_compress_level",("<level:1-9> Set the amount of compression for the SWF output",[Platform Flash])
+	| SwfDebugPassword -> "swf_debug_password",("Set a password for debugging",[Platform Flash])
+	| SwfDirectBlit -> "swf_direct_blit",("Use hardware acceleration to blit graphics",[Platform Flash])
+	| SwfGpu -> "swf_gpu",("Use GPU compositing features when drawing graphics",[Platform Flash])
+	| SwfMetadata -> "swf_metadata",("<file> Include contents of <file> as metadata in the swf",[Platform Flash])
+	| SwfPreloaderFrame -> "swf_preloader_frame",("Insert empty first frame in swf",[Platform Flash])
+	| SwfProtected -> "swf_protected",("Compile Haxe private as protected in the SWF instead of public",[Platform Flash])
+	| SwfScriptTimeout -> "swf_script_timeout",("Maximum ActionScript processing time before script stuck dialog box displays (in seconds)",[Platform Flash])
+	| SwfUseDoAbc -> "swf_use_doabc",("Use DoAbc swf-tag instead of DoAbcDefine",[Platform Flash])
+	| Sys -> "sys",("Defined for all system platforms",[])
+	| Unsafe -> "unsafe",("Allow unsafe code when targeting C#",[Platform Cs])
+	| UseNekoc -> "use_nekoc",("Use nekoc compiler instead of internal one",[Platform Neko])
+	| UseRttiDoc -> "use_rtti_doc",("Allows access to documentation during compilation",[])
+	| Vcproj -> "vcproj",("GenCPP internal",[Platform Cpp])
+	| Last -> assert false
+
+let get_documentation_list() =
+	let m = ref 0 in
+	let rec loop i =
+		let d = Obj.magic i in
+		if d <> Last then begin
+			let t, (doc,flags) = infos d in
+			let pfs = ref [] in
+			List.iter (function
+			| HasParam s -> () (* TODO *)
+			| Platform p -> pfs := p :: !pfs;
+			| Platforms pl -> pfs := pl @ !pfs;
+			) flags;
+			let pfs = platform_list_help (List.rev !pfs) in
+			if String.length t > !m then m := String.length t;
+			((String.concat "-" (ExtString.String.nsplit t "_")),doc ^ pfs) :: (loop (i + 1))
+		end else
+			[]
+	in
+	let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) (loop 0) in
+	all,!m
+
+let raw_defined ctx v =
+	PMap.mem v ctx.values
+
+let defined ctx v =
+	raw_defined ctx (fst (infos v))
+
+let raw_defined_value ctx k =
+	PMap.find k ctx.values
+
+let defined_value ctx v =
+	raw_defined_value ctx (fst (infos v))
+
+let defined_value_safe ctx v =
+	try defined_value ctx v
+	with Not_found -> ""
+
+let raw_define ctx v =
+	let k,v = try ExtString.String.split v "=" with _ -> v,"1" in
+	ctx.values <- PMap.add k v ctx.values;
+	let k = String.concat "_" (ExtString.String.nsplit k "-") in
+	ctx.values <- PMap.add k v ctx.values;
+	ctx.defines_signature <- None
+
+let define_value ctx k v =
+	raw_define ctx (fst (infos k) ^ "=" ^ v)
+
+let define ctx v =
+	raw_define ctx (fst (infos v))
+
+let get_signature def =
+	match def.defines_signature with
+	| Some s -> s
+	| None ->
+		let defines = PMap.foldi (fun k v acc ->
+			(* don't make much difference between these special compilation flags *)
+			match String.concat "_" (ExtString.String.nsplit k "-") with
+			(* If we add something here that might be used in conditional compilation it should be added to
+			   Parser.parse_macro_ident as well (issue #5682). *)
+			| "display" | "use_rtti_doc" | "macro_times" | "display_details" | "no_copt" | "display_stdin" -> acc
+			| _ -> (k ^ "=" ^ v) :: acc
+		) def.values [] in
+		let str = String.concat "@" (List.sort compare defines) in
+		let s = Digest.string str in
+		def.defines_signature <- Some s;
+		s

+ 1 - 1
src/display/displayOutput.ml

@@ -786,7 +786,7 @@ let process_global_display_mode com tctx = match com.display.dms_kind with
 		let symbols = match CompilationServer.get() with
 			| None -> symbols
 			| Some cs ->
-				let l = CompilationServer.get_context_files cs ((get_signature com) :: (match com.get_macros() with None -> [] | Some com -> [get_signature com])) in
+				let l = CompilationServer.get_context_files cs ((Define.get_signature com.defines) :: (match com.get_macros() with None -> [] | Some com -> [Define.get_signature com.defines])) in
 				List.fold_left (fun acc (file,data) ->
 					print_endline (Printf.sprintf "%s %b" file (is_display_file file));
 					if (filter <> None || is_display_file file) then

+ 2 - 2
src/generators/gencommon.ml

@@ -870,7 +870,7 @@ let dump_descriptor gen name path_s module_s =
 	PMap.iter (fun name _ ->
 		SourceWriter.write w name;
 		SourceWriter.newline w
-	) gen.gcon.defines;
+	) gen.gcon.defines.Define.values;
 	SourceWriter.write w "end defines";
 	SourceWriter.newline w;
 	(* dump all defines with their values; keeping the old defines for compatibility *)
@@ -881,7 +881,7 @@ let dump_descriptor gen name path_s module_s =
 		SourceWriter.write w "=";
 		SourceWriter.write w v;
 		SourceWriter.newline w
-	) gen.gcon.defines;
+	) gen.gcon.defines.Define.values;
 	SourceWriter.write w "end defines_data";
 	SourceWriter.newline w;
 	(* dump all generated types *)

+ 1 - 1
src/generators/gencommon/realTypeParams.ml

@@ -711,7 +711,7 @@ let default_implementation gen (dyn_tparam_cast:texpr->t->texpr) ifaces =
 							false)
 						| _ -> false
 					in
-					let unifies = unifies && not (PMap.mem "cs_safe_casts" gen.gcon.defines) in
+					let unifies = unifies && not (PMap.mem "cs_safe_casts" gen.gcon.defines.Define.values) in
 					(match follow t with
 						| TInst(cl, p1 :: pl) when is_hxgeneric (TClassDecl cl) && not unifies && not (Meta.has Meta.Enum cl.cl_meta) ->
 							let iface = Hashtbl.find ifaces cl.cl_path in

+ 2 - 2
src/generators/gencpp.ml

@@ -8255,8 +8255,8 @@ let generate_source ctx =
    let cmd_defines = ref "" in
    PMap.iter ( fun name value -> match name with
       | "true" | "sys" | "dce" | "cpp" | "debug" -> ()
-      | _ -> cmd_defines := !cmd_defines ^ " -D" ^ name ^ "=\"" ^ (escape_command value) ^ "\"" ) common_ctx.defines;
-   write_build_options common_ctx (common_ctx.file ^ "/Options.txt") common_ctx.defines;
+      | _ -> cmd_defines := !cmd_defines ^ " -D" ^ name ^ "=\"" ^ (escape_command value) ^ "\"" ) common_ctx.defines.Define.values;
+   write_build_options common_ctx (common_ctx.file ^ "/Options.txt") common_ctx.defines.Define.values;
    if ( not (Common.defined common_ctx Define.NoCompilation) ) then begin
       let t = Common.timer ["generate";"cpp";"native compilation"] in
       let old_dir = Sys.getcwd() in

+ 1 - 1
src/generators/genlua.ml

@@ -1798,7 +1798,7 @@ let alloc_ctx com =
         found_expose = false;
         lua_jit = Common.defined com Define.LuaJit;
         lua_ver = try
-                float_of_string (PMap.find "lua_ver" com.defines)
+                float_of_string (PMap.find "lua_ver" com.defines.Define.values)
             with | Not_found -> 5.2;
     } in
     ctx.type_accessor <- (fun t ->

+ 1 - 1
src/generators/hl2c.ml

@@ -1399,7 +1399,7 @@ let write_c com file (code:code) =
 	block ctx;
 	sline "\"version\" : %d," ctx.version;
 	sline "\"libs\" : [%s]," (String.concat "," (Hashtbl.fold (fun k _ acc -> sprintf "\"%s\"" k :: acc) native_libs []));
-	sline "\"defines\" : {%s\n\t}," (String.concat "," (PMap.foldi (fun k v acc -> sprintf "\n\t\t\"%s\" : \"%s\"" k v :: acc) com.Common.defines []));
+	sline "\"defines\" : {%s\n\t}," (String.concat "," (PMap.foldi (fun k v acc -> sprintf "\n\t\t\"%s\" : \"%s\"" k v :: acc) com.Common.defines.Define.values []));
 	sline "\"files\" : [%s\n\t]" (String.concat "," (List.map (sprintf "\n\t\t\"%s\"") ctx.cfiles));
 	unblock ctx;
 	line "}";

+ 1 - 1
src/macro/eval/evalDebugMisc.ml

@@ -73,7 +73,7 @@ exception Parse_expr_error of string
 
 let parse_expr ctx s p =
 	let error s = raise (Parse_expr_error s) in
-	Parser.parse_expr_string (ctx.curapi.get_com()) s p error false
+	Parser.parse_expr_string (ctx.curapi.get_com()).Common.defines s p error false
 
 (* Vars *)
 

+ 1 - 1
src/macro/macroApi.ml

@@ -1535,7 +1535,7 @@ let macro_api ccom get_api =
 			try encode_string (Common.raw_defined_value (ccom()) (decode_string s)) with Not_found -> vnull
 		);
 		"get_defines", vfun0 (fun() ->
-			encode_string_map encode_string (ccom()).defines
+			encode_string_map encode_string (ccom()).defines.Define.values
 		);
 		"get_type", vfun1 (fun s ->
 			let tname = decode_string s in

+ 8 - 8
src/macro/macroContext.ml

@@ -120,7 +120,7 @@ let load_macro_ref : (typer -> bool -> path -> string -> pos -> (typer * ((strin
 
 let make_macro_api ctx p =
 	let parse_expr_string s p inl =
-		typing_timer ctx false (fun() -> try Parser.parse_expr_string ctx.com s p error inl with Exit -> raise MacroApi.Invalid_expr)
+		typing_timer ctx false (fun() -> try Parser.parse_expr_string ctx.com.defines s p error inl with Exit -> raise MacroApi.Invalid_expr)
 	in
 	{
 		MacroApi.pos = p;
@@ -209,7 +209,7 @@ let make_macro_api ctx p =
 		MacroApi.type_patch = (fun t f s v ->
 			typing_timer ctx false (fun() ->
 				let v = (match v with None -> None | Some s ->
-					match Parser.parse_string ctx.com ("typedef T = " ^ s) null_pos error false with
+					match Parser.parse_string ctx.com.defines ("typedef T = " ^ s) null_pos error false with
 					| _,[ETypedef { d_data = ct },_] -> Some ct
 					| _ -> assert false
 				) in
@@ -220,7 +220,7 @@ let make_macro_api ctx p =
 			);
 		);
 		MacroApi.meta_patch = (fun m t f s ->
-			let m = (match Parser.parse_string ctx.com (m ^ " typedef T = T") null_pos error false with
+			let m = (match Parser.parse_string ctx.com.defines (m ^ " typedef T = T") null_pos error false with
 				| _,[ETypedef t,_] -> t.d_meta
 				| _ -> assert false
 			) in
@@ -353,7 +353,7 @@ let make_macro_api ctx p =
 			)
 		);
 		MacroApi.add_global_metadata = (fun s1 s2 config ->
-			let meta = (match Parser.parse_string ctx.com (s2 ^ " typedef T = T") null_pos error false with
+			let meta = (match Parser.parse_string ctx.com.defines (s2 ^ " typedef T = T") null_pos error false with
 				| _,[ETypedef t,_] -> t.d_meta
 				| _ -> assert false
 			) in
@@ -489,14 +489,14 @@ let get_macro_context ctx p =
 		com2.package_rules <- PMap.empty;
 		com2.main_class <- None;
 		com2.display <- DisplayMode.create DMNone;
-		List.iter (fun p -> com2.defines <- PMap.remove (Globals.platform_name p) com2.defines) Globals.platforms;
-		com2.defines_signature <- None;
+		List.iter (fun p -> com2.defines.Define.values <- PMap.remove (Globals.platform_name p) com2.defines.Define.values) Globals.platforms;
+		com2.defines.Define.defines_signature <- None;
 		com2.class_path <- List.filter (fun s -> not (ExtString.String.exists s "/_std/")) com2.class_path;
 		let name = platform_name !Globals.macro_platform in
 		com2.class_path <- List.map (fun p -> p ^ name ^ "/_std/") com2.std_path @ com2.class_path;
 		let to_remove = List.map (fun d -> fst (Define.infos d)) [Define.NoTraces] in
 		let to_remove = to_remove @ List.map (fun (_,d) -> "flash" ^ d) Common.flash_versions in
-		com2.defines <- PMap.foldi (fun k v acc -> if List.mem k to_remove then acc else PMap.add k v acc) com2.defines PMap.empty;
+		com2.defines.Define.values <- PMap.foldi (fun k v acc -> if List.mem k to_remove then acc else PMap.add k v acc) com2.defines.Define.values PMap.empty;
 		Common.define com2 Define.Macro;
 		Common.init_platform com2 !Globals.macro_platform;
 		let mctx = ctx.g.do_create com2 in
@@ -757,7 +757,7 @@ let call_macro ctx path meth args p =
 let call_init_macro ctx e =
 	let p = { pfile = "--macro"; pmin = 0; pmax = 0 } in
 	let e = try
-		Parser.parse_expr_string ctx.com e p error false
+		Parser.parse_expr_string ctx.com.defines e p error false
 	with err ->
 		display_error ctx ("Could not parse `" ^ e ^ "`") p;
 		raise err

+ 2 - 2
src/syntax/parser.mly

@@ -1704,7 +1704,7 @@ let cmp v1 v2 =
 let rec eval ctx (e,p) =
 	match e with
 	| EConst (Ident i) ->
-		(try TString (Common.raw_defined_value ctx i) with Not_found -> TNull)
+		(try TString (Define.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)
@@ -1736,7 +1736,7 @@ let parse ctx code =
 	let mstack = ref [] in
 	cache := DynArray.create();
 	last_doc := None;
-	in_macro := Common.defined ctx Common.Define.Macro;
+	in_macro := Define.defined ctx Define.Macro;
 	Lexer.skip_header code;
 
 	let sraw = Stream.from (fun _ -> Some (Lexer.token code)) in

+ 12 - 12
src/typing/dotnet.ml

@@ -318,7 +318,7 @@ let convert_ilfield ctx p field =
 		| CInitOnly | CLiteral -> true, acc
 		| _ -> readonly,acc
 	) (false,[cff_access]) field.fflags.ff_contract in
-	if PMap.mem "net_loader_debug" ctx.ncom.defines then
+	if PMap.mem "net_loader_debug" ctx.ncom.defines.Define.values then
 		Printf.printf "\t%sfield %s : %s\n" (if List.mem AStatic acc then "static " else "") cff_name (IlMetaDebug.ilsig_s field.fsig.ssig);
 	let kind = match readonly with
 		| true ->
@@ -358,7 +358,7 @@ let convert_ilevent ctx p ev =
 			else
 				acc
 	in
-	if PMap.mem "net_loader_debug" ctx.ncom.defines then
+	if PMap.mem "net_loader_debug" ctx.ncom.defines.Define.values then
 		Printf.printf "\tevent %s : %s\n" name (IlMetaDebug.ilsig_s ev.esig.ssig);
 	let acc = add_m acc ev.eadd in
 	let acc = add_m acc ev.eremove in
@@ -397,7 +397,7 @@ let convert_ilmethod ctx p m is_explicit_impl =
 			APrivate, meta
 		| FAPublic -> APublic, meta
 		| _ ->
-			if PMap.mem "net_loader_debug" ctx.ncom.defines then
+			if PMap.mem "net_loader_debug" ctx.ncom.defines.Define.values then
 				Printf.printf "\tmethod %s (skipped) : %s\n" cff_name (IlMetaDebug.ilsig_s m.msig.ssig);
 			raise Exit
 	in
@@ -408,7 +408,7 @@ let convert_ilmethod ctx p m is_explicit_impl =
 		| CMFinal -> acc, Some true
 		| _ -> acc, is_final
 	) ([acc],None) m.mflags.mf_contract in
-	if PMap.mem "net_loader_debug" ctx.ncom.defines then
+	if PMap.mem "net_loader_debug" ctx.ncom.defines.Define.values then
 		Printf.printf "\t%smethod %s : %s\n" (if !is_static then "static " else "") cff_name (IlMetaDebug.ilsig_s m.msig.ssig);
 
 	let meta = match is_final with
@@ -546,7 +546,7 @@ let convert_ilprop ctx p prop is_explicit_impl =
 			| _ -> "never");
 		| Some _ -> "set"
 	in
-	if PMap.mem "net_loader_debug" ctx.ncom.defines then
+	if PMap.mem "net_loader_debug" ctx.ncom.defines.Define.values then
 		Printf.printf "\tproperty %s (%s,%s) : %s\n" prop.pname get set (IlMetaDebug.ilsig_s prop.psig.ssig);
 	let ilsig = match prop.psig.snorm with
 		| LMethod (_,ret,[]) -> ret
@@ -712,7 +712,7 @@ let convert_ilclass ctx p ?(delegate=false) ilcls = match ilcls.csuper with
 	| _ ->
 		let flags = ref [HExtern] in
 		(* todo: instead of CsNative, use more specific definitions *)
-		if PMap.mem "net_loader_debug" ctx.ncom.defines then begin
+		if PMap.mem "net_loader_debug" ctx.ncom.defines.Define.values then begin
 			let sup = match ilcls.csuper with | None -> [] | Some c -> [IlMetaDebug.ilsig_s c.ssig] in
 			let sup = sup @ List.map (fun i -> IlMetaDebug.ilsig_s i.ssig) ilcls.cimplements in
 			print_endline ("converting " ^ ilpath_s ilcls.cpath ^ " : " ^ (String.concat ", " sup))
@@ -1124,20 +1124,20 @@ let add_net_lib com file std =
 					failwith (".NET lib " ^ file ^ " not found")
 			in
 			real_file := file;
-			let r = PeReader.create_r (open_in_bin file) com.defines in
+			let r = PeReader.create_r (open_in_bin file) com.defines.Define.values in
 			let ctx = PeReader.read r in
 			let clr_header = PeReader.read_clr_header ctx in
 			let cache = IlMetaReader.create_cache () in
 			let meta = IlMetaReader.read_meta_tables ctx clr_header cache in
 			close_in (r.PeReader.ch);
-			if PMap.mem "net_loader_debug" com.defines then
+			if PMap.mem "net_loader_debug" com.defines.Define.values then
 				print_endline ("for lib " ^ file);
 			let il_typedefs = Hashtbl.copy meta.il_typedefs in
 			Hashtbl.clear meta.il_typedefs;
 
 			Hashtbl.iter (fun _ td ->
 				let path = IlMetaTools.get_path (TypeDef td) in
-				if PMap.mem "net_loader_debug" com.defines then
+				if PMap.mem "net_loader_debug" com.defines.Define.values then
 					Printf.printf "found %s\n" (s_type_path (netpath_to_hx path));
 				Hashtbl.replace com.net_path_map (netpath_to_hx path) path;
 				Hashtbl.replace meta.il_typedefs path td
@@ -1174,7 +1174,7 @@ let add_net_lib com file std =
 		let pack = match fst path with | ["haxe";"root"] -> [] | p -> p in
 		let cp = ref [] in
 		let rec build path = try
-			if PMap.mem "net_loader_debug" com.defines then
+			if PMap.mem "net_loader_debug" com.defines.Define.values then
 				Printf.printf "looking up %s\n" (s_type_path path);
 			match lookup path with
 			| Some({csuper = Some{snorm = LClass( (["System"],[],("Delegate"|"MulticastDelegate")),_)}} as cls)
@@ -1214,7 +1214,7 @@ let add_net_lib com file std =
 let before_generate com =
 	(* net version *)
 	let net_ver = try
-			int_of_string (PMap.find "net_ver" com.defines)
+			int_of_string (PMap.find "net_ver" com.defines.Define.values)
 		with | Not_found ->
 			Common.define_value com Define.NetVer "20";
 			20
@@ -1235,7 +1235,7 @@ let before_generate com =
 
 	(* net target *)
 	let net_target = try
-			String.lowercase (PMap.find "net_target" com.defines)
+			String.lowercase (PMap.find "net_target" com.defines.Define.values)
 		with | Not_found ->
 			"net"
 	in

+ 3 - 3
src/typing/java.ml

@@ -356,7 +356,7 @@ let convert_java_enum ctx p pe =
 							String.concat "_" parts,
 							(Meta.Native, [EConst (String (cff_name) ), cff_pos], cff_pos) :: !cff_meta
 		in
-		if PMap.mem "java_loader_debug" ctx.jcom.defines then
+		if PMap.mem "java_loader_debug" ctx.jcom.defines.Define.values then
 			Printf.printf "\t%s%sfield %s : %s\n" (if List.mem AStatic !cff_access then "static " else "") (if List.mem AOverride !cff_access then "override " else "") cff_name (s_sig field.jf_signature);
 
 		{
@@ -398,7 +398,7 @@ let convert_java_enum ctx p pe =
 				[convert_java_enum ctx p jc]
 		| false ->
 			let flags = ref [HExtern] in
-			if PMap.mem "java_loader_debug" ctx.jcom.defines then begin
+			if PMap.mem "java_loader_debug" ctx.jcom.defines.Define.values then begin
 				let sup = jc.csuper :: jc.cinterfaces in
 				print_endline ("converting " ^ (if List.mem JAbstract jc.cflags then "abstract " else "") ^ JData.path_s jc.cpath ^ " : " ^ (String.concat ", " (List.map s_sig sup)));
 			end;
@@ -1144,7 +1144,7 @@ let add_java_lib com file std =
 
 let before_generate con =
 	let java_ver = try
-			int_of_string (PMap.find "java_ver" con.defines)
+			int_of_string (PMap.find "java_ver" con.defines.Define.values)
 		with | Not_found ->
 			Common.define_value con Define.JavaVer "7";
 			7

+ 1 - 1
src/typing/typecore.ml

@@ -290,7 +290,7 @@ let create_fake_module ctx file =
 			m_id = alloc_mid();
 			m_path = (["$DEP"],file);
 			m_types = [];
-			m_extra = module_extra file (Common.get_signature ctx.com) (file_time file) MFake [];
+			m_extra = module_extra file (Define.get_signature ctx.com.defines) (file_time file) MFake [];
 		} in
 		Hashtbl.add fake_modules file mdep;
 		mdep

+ 4 - 4
src/typing/typeload.ml

@@ -80,7 +80,7 @@ let make_module ctx mpath file loadp =
 		m_id = alloc_mid();
 		m_path = mpath;
 		m_types = [];
-		m_extra = module_extra (Path.unique_full_path file) (Common.get_signature ctx.com) (file_time file) (if ctx.in_macro then MMacro else MCode) (get_policy ctx mpath);
+		m_extra = module_extra (Path.unique_full_path file) (Define.get_signature ctx.com.defines) (file_time file) (if ctx.in_macro then MMacro else MCode) (get_policy ctx mpath);
 	} in
 	m
 
@@ -244,7 +244,7 @@ let parse_file_from_lexbuf com file p lexbuf =
 	Lexer.init file true;
 	incr stats.s_files_parsed;
 	let data = try
-		Parser.parse com lexbuf
+		Parser.parse com.defines lexbuf
 	with
 		| Sedlexing.MalFormed ->
 			t();
@@ -1695,7 +1695,7 @@ let load_core_class ctx c =
 	let ctx2 = (match ctx.g.core_api with
 		| None ->
 			let com2 = Common.clone ctx.com in
-			com2.defines <- PMap.empty;
+			com2.defines.Define.values <- PMap.empty;
 			Common.define com2 Define.CoreApi;
 			Common.define com2 Define.Sys;
 			if ctx.in_macro then Common.define com2 Define.Macro;
@@ -2819,7 +2819,7 @@ module ClassInitializer = struct
 							| EBinop ((OpEq|OpNotEq|OpGt|OpGte|OpLt|OpLte) as op,(EConst (Ident s),_),(EConst ((Int _ | Float _ | String _) as c),_)) -> s ^ s_binop op ^ s_constant c
 							| _ -> ""
 						in
-						if not (Parser.is_true (Parser.eval ctx.com e)) then
+						if not (Parser.is_true (Parser.eval ctx.com.defines e)) then
 							Some (sc,(match List.rev l with (EConst (String msg),_) :: _ -> Some msg | _ -> None))
 						else
 							loop l

+ 1 - 1
src/typing/typer.ml

@@ -2861,7 +2861,7 @@ and format_string ctx s p =
 		if warn_escape then warn (pos + 1) slen;
 		min := !min + 2;
 		if slen > 0 then
-			add_expr (Parser.parse_expr_string ctx.com scode { p with pmin = !pmin + pos + 2; pmax = !pmin + send + 1 } error true) slen;
+			add_expr (Parser.parse_expr_string ctx.com.defines scode { p with pmin = !pmin + pos + 2; pmax = !pmin + send + 1 } error true) slen;
 		min := !min + 1;
 		parse (send + 1) (send + 1)
 	in