|
@@ -53,6 +53,13 @@ type stats = {
|
|
|
s_macros_called : int ref;
|
|
|
}
|
|
|
|
|
|
+type platform_config = {
|
|
|
+ (** has a static type system, with not-nullable basic types (Int/Float/Bool) *)
|
|
|
+ pf_static : bool;
|
|
|
+ (** has access to the "sys" package *)
|
|
|
+ pf_sys : bool;
|
|
|
+}
|
|
|
+
|
|
|
type context = {
|
|
|
(* config *)
|
|
|
version : int;
|
|
@@ -63,6 +70,7 @@ type context = {
|
|
|
mutable foptimize : bool;
|
|
|
mutable dead_code_elimination : bool;
|
|
|
mutable platform : platform;
|
|
|
+ mutable config : platform_config;
|
|
|
mutable std_path : string list;
|
|
|
mutable class_path : string list;
|
|
|
mutable main_class : Type.path option;
|
|
@@ -105,6 +113,63 @@ let stats =
|
|
|
s_macros_called = ref 0;
|
|
|
}
|
|
|
|
|
|
+let default_config =
|
|
|
+ {
|
|
|
+ pf_static = true;
|
|
|
+ pf_sys = true;
|
|
|
+ }
|
|
|
+
|
|
|
+let get_config com =
|
|
|
+ let defined f = PMap.mem f com.defines in
|
|
|
+ match com.platform with
|
|
|
+ | Cross ->
|
|
|
+ default_config
|
|
|
+ | Flash8 ->
|
|
|
+ {
|
|
|
+ pf_static = false;
|
|
|
+ pf_sys = false;
|
|
|
+ }
|
|
|
+ | Js ->
|
|
|
+ {
|
|
|
+ pf_static = false;
|
|
|
+ pf_sys = false;
|
|
|
+ }
|
|
|
+ | Neko ->
|
|
|
+ {
|
|
|
+ pf_static = false;
|
|
|
+ pf_sys = true;
|
|
|
+ }
|
|
|
+ | Flash when defined "as3" ->
|
|
|
+ {
|
|
|
+ pf_static = true;
|
|
|
+ pf_sys = false;
|
|
|
+ }
|
|
|
+ | Flash ->
|
|
|
+ {
|
|
|
+ pf_static = true;
|
|
|
+ pf_sys = false;
|
|
|
+ }
|
|
|
+ | Php ->
|
|
|
+ {
|
|
|
+ pf_static = false;
|
|
|
+ pf_sys = true;
|
|
|
+ }
|
|
|
+ | Cpp ->
|
|
|
+ {
|
|
|
+ pf_static = true;
|
|
|
+ pf_sys = true;
|
|
|
+ }
|
|
|
+ | Cs ->
|
|
|
+ {
|
|
|
+ pf_static = true;
|
|
|
+ pf_sys = true;
|
|
|
+ }
|
|
|
+ | Java ->
|
|
|
+ {
|
|
|
+ pf_static = true;
|
|
|
+ pf_sys = true;
|
|
|
+ }
|
|
|
+
|
|
|
let create v args =
|
|
|
let m = Type.mk_mono() in
|
|
|
{
|
|
@@ -117,6 +182,7 @@ let create v args =
|
|
|
features = Hashtbl.create 0;
|
|
|
dead_code_elimination = false;
|
|
|
platform = Cross;
|
|
|
+ config = default_config;
|
|
|
print = print_string;
|
|
|
std_path = [];
|
|
|
class_path = [];
|
|
@@ -222,9 +288,9 @@ let init_platform com pf =
|
|
|
let name = platform_name pf in
|
|
|
let forbid acc p = if p = name || PMap.mem p acc then acc else PMap.add p Forbidden acc in
|
|
|
com.package_rules <- List.fold_left forbid com.package_rules (List.map platform_name platforms);
|
|
|
- (match pf with
|
|
|
- | Cpp | Php | Neko | Java | Cs -> define com "sys"
|
|
|
- | _ -> com.package_rules <- PMap.add "sys" Forbidden com.package_rules);
|
|
|
+ com.config <- get_config com;
|
|
|
+ if com.config.pf_static then define com "static";
|
|
|
+ if com.config.pf_sys then define com "sys" else com.package_rules <- PMap.add "sys" Forbidden com.package_rules;
|
|
|
define com name
|
|
|
|
|
|
let add_feature com f =
|
|
@@ -256,11 +322,6 @@ let error msg p = raise (Abort (msg,p))
|
|
|
|
|
|
let platform ctx p = ctx.platform = p
|
|
|
|
|
|
-let is_static_platform ctx =
|
|
|
- match ctx.platform with
|
|
|
- | Cpp | Flash | Cs | Java -> true
|
|
|
- | _ -> false
|
|
|
-
|
|
|
let add_filter ctx f =
|
|
|
ctx.filters <- f :: ctx.filters
|
|
|
|