|
@@ -4138,6 +4138,9 @@ let create_constructor_dependencies common_ctx =
|
|
) common_ctx.types;
|
|
) common_ctx.types;
|
|
result;;
|
|
result;;
|
|
|
|
|
|
|
|
+(*
|
|
|
|
+
|
|
|
|
+ Exports can now be done with macros and a class list
|
|
|
|
|
|
let rec s_type t =
|
|
let rec s_type t =
|
|
let result =
|
|
let result =
|
|
@@ -4178,9 +4181,6 @@ and s_type_params = function
|
|
;;
|
|
;;
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
let gen_extern_class common_ctx class_def file_info =
|
|
let gen_extern_class common_ctx class_def file_info =
|
|
let file = new_source_file common_ctx common_ctx.file "extern" ".hx" class_def.cl_path in
|
|
let file = new_source_file common_ctx common_ctx.file "extern" ".hx" class_def.cl_path in
|
|
let path = class_def.cl_path in
|
|
let path = class_def.cl_path in
|
|
@@ -4294,6 +4294,7 @@ let gen_extern_enum common_ctx enum_def file_info =
|
|
output "}\n";
|
|
output "}\n";
|
|
file#close
|
|
file#close
|
|
;;
|
|
;;
|
|
|
|
+*)
|
|
|
|
|
|
let is_this expression =
|
|
let is_this expression =
|
|
match (remove_parens expression).eexpr with
|
|
match (remove_parens expression).eexpr with
|
|
@@ -4378,6 +4379,7 @@ class script_writer common_ctx ctx filename =
|
|
val mutable indents = []
|
|
val mutable indents = []
|
|
val mutable just_finished_block = false
|
|
val mutable just_finished_block = false
|
|
val mutable classCount = 0
|
|
val mutable classCount = 0
|
|
|
|
+ val mutable return_type = TMono(ref None)
|
|
val buffer = Buffer.create 0
|
|
val buffer = Buffer.create 0
|
|
val identTable = Hashtbl.create 0
|
|
val identTable = Hashtbl.create 0
|
|
val fileTable = Hashtbl.create 0
|
|
val fileTable = Hashtbl.create 0
|
|
@@ -4448,6 +4450,10 @@ class script_writer common_ctx ctx filename =
|
|
| TThis -> "THIS "
|
|
| TThis -> "THIS "
|
|
| TSuper -> "SUPER "
|
|
| TSuper -> "SUPER "
|
|
|
|
|
|
|
|
+ method pushReturn inType =
|
|
|
|
+ let oldReturnType = return_type in
|
|
|
|
+ return_type <- inType;
|
|
|
|
+ fun () -> return_type <- oldReturnType;
|
|
method fileText file = string_of_int (this#fileId file)
|
|
method fileText file = string_of_int (this#fileId file)
|
|
method indent_one = this#write indent_str
|
|
method indent_one = this#write indent_str
|
|
method push_indent = indents <- indent_str::indents; indent <- String.concat "" indents
|
|
method push_indent = indents <- indent_str::indents; indent <- String.concat "" indents
|
|
@@ -4486,11 +4492,12 @@ class script_writer common_ctx ctx filename =
|
|
this#writeBool v.v_capture;
|
|
this#writeBool v.v_capture;
|
|
this#writeType v.v_type;
|
|
this#writeType v.v_type;
|
|
method writeList prefix len = this#write (prefix ^" " ^ (string_of_int (len)) ^ "\n");
|
|
method writeList prefix len = this#write (prefix ^" " ^ (string_of_int (len)) ^ "\n");
|
|
- method checkCast toType expr forceCast =
|
|
|
|
|
|
+ method checkCast toType expr forceCast fromGenExpression=
|
|
let write_cast text =
|
|
let write_cast text =
|
|
- this#begin_expr;
|
|
|
|
- this#write ((string_of_int (Lexer.get_error_line expr.epos) ) ^ "\t" ^ (this#fileText expr.epos.pfile) ^ indent);
|
|
|
|
|
|
+ if (not fromGenExpression) then
|
|
|
|
+ this#write ( (this#fileText expr.epos.pfile) ^ "\t" ^ (string_of_int (Lexer.get_error_line expr.epos) ) ^ indent);
|
|
this#write (text ^"\n" );
|
|
this#write (text ^"\n" );
|
|
|
|
+ this#begin_expr;
|
|
this#gen_expression expr;
|
|
this#gen_expression expr;
|
|
this#end_expr;
|
|
this#end_expr;
|
|
true;
|
|
true;
|
|
@@ -4561,7 +4568,9 @@ class script_writer common_ctx ctx filename =
|
|
| Some const when const <> TNull -> this#write ("1 " ^ (this#constText const) ^ "\n")
|
|
| Some const when const <> TNull -> this#write ("1 " ^ (this#constText const) ^ "\n")
|
|
| _ -> this#write "0\n";
|
|
| _ -> this#write "0\n";
|
|
) function_def.tf_args;
|
|
) function_def.tf_args;
|
|
|
|
+ let pop = this#pushReturn function_def.tf_type in
|
|
this#gen_expression function_def.tf_expr;
|
|
this#gen_expression function_def.tf_expr;
|
|
|
|
+ pop ();
|
|
| TBlock expr_list -> this#writeList "BLOCK" (List.length expr_list);
|
|
| TBlock expr_list -> this#writeList "BLOCK" (List.length expr_list);
|
|
List.iter this#gen_expression expr_list;
|
|
List.iter this#gen_expression expr_list;
|
|
| TConst const -> this#write (this#constText const)
|
|
| TConst const -> this#write (this#constText const)
|
|
@@ -4571,7 +4580,7 @@ class script_writer common_ctx ctx filename =
|
|
| TBinop (op,e1,e2) when op=OpAssign ->
|
|
| TBinop (op,e1,e2) when op=OpAssign ->
|
|
this#write ("SET \n");
|
|
this#write ("SET \n");
|
|
this#gen_expression e1;
|
|
this#gen_expression e1;
|
|
- this#checkCast e1.etype e2 false;
|
|
|
|
|
|
+ this#checkCast e1.etype e2 false false;
|
|
| TBinop (OpEq ,e1, { eexpr = TConst TNull } ) -> this#write "ISNULL\n";
|
|
| TBinop (OpEq ,e1, { eexpr = TConst TNull } ) -> this#write "ISNULL\n";
|
|
this#gen_expression e1;
|
|
this#gen_expression e1;
|
|
| TBinop (OpNotEq ,e1, { eexpr = TConst TNull }) -> this#write "NOTNULL\n";
|
|
| TBinop (OpNotEq ,e1, { eexpr = TConst TNull }) -> this#write "NOTNULL\n";
|
|
@@ -4632,7 +4641,7 @@ class script_writer common_ctx ctx filename =
|
|
let matched_args = match func.etype with
|
|
let matched_args = match func.etype with
|
|
| TFun (args,_) ->
|
|
| TFun (args,_) ->
|
|
( try (
|
|
( try (
|
|
- List.iter2 (fun (_,_,protoT) arg -> this#checkCast protoT arg false ) args arg_list;
|
|
|
|
|
|
+ List.iter2 (fun (_,_,protoT) arg -> this#checkCast protoT arg false false) args arg_list;
|
|
true; )
|
|
true; )
|
|
with Invalid_argument _ -> (*print_endline "Bad count?";*) false )
|
|
with Invalid_argument _ -> (*print_endline "Bad count?";*) false )
|
|
| _ -> false
|
|
| _ -> false
|
|
@@ -4685,14 +4694,14 @@ class script_writer common_ctx ctx filename =
|
|
this#writeVar tvar;
|
|
this#writeVar tvar;
|
|
this#write (" " ^ (this#typeText init.etype));
|
|
this#write (" " ^ (this#typeText init.etype));
|
|
this#write "\n";
|
|
this#write "\n";
|
|
- this#checkCast tvar.v_type init false);
|
|
|
|
|
|
+ this#checkCast tvar.v_type init false false);
|
|
| TNew (clazz,params,arg_list) ->
|
|
| TNew (clazz,params,arg_list) ->
|
|
this#write ("NEW " ^ (this#typeText (TInst(clazz,params))) ^ (string_of_int (List.length arg_list)) ^ "\n");
|
|
this#write ("NEW " ^ (this#typeText (TInst(clazz,params))) ^ (string_of_int (List.length arg_list)) ^ "\n");
|
|
List.iter this#gen_expression arg_list;
|
|
List.iter this#gen_expression arg_list;
|
|
| TReturn optval -> (match optval with
|
|
| TReturn optval -> (match optval with
|
|
| None -> this#write "RETURN\n"
|
|
| None -> this#write "RETURN\n"
|
|
| Some value -> this#write ("RETVAL " ^ (this#typeText value.etype) ^ "\n");
|
|
| Some value -> this#write ("RETVAL " ^ (this#typeText value.etype) ^ "\n");
|
|
- this#gen_expression value;
|
|
|
|
|
|
+ this#checkCast return_type value false false;
|
|
)
|
|
)
|
|
| TObjectDecl (
|
|
| TObjectDecl (
|
|
("fileName" , { eexpr = (TConst (TString file)) }) ::
|
|
("fileName" , { eexpr = (TConst (TString file)) }) ::
|
|
@@ -4745,7 +4754,7 @@ class script_writer common_ctx ctx filename =
|
|
this#gen_expression catch_expr;
|
|
this#gen_expression catch_expr;
|
|
) catches;
|
|
) catches;
|
|
| TCast (cast,None) -> error "Unexpected cast" expression.epos
|
|
| TCast (cast,None) -> error "Unexpected cast" expression.epos
|
|
- | TCast (cast,Some _) -> this#checkCast expression.etype cast true
|
|
|
|
|
|
+ | TCast (cast,Some _) -> this#checkCast expression.etype cast true true
|
|
| TParenthesis _ -> error "Unexpected parens" expression.epos
|
|
| TParenthesis _ -> error "Unexpected parens" expression.epos
|
|
| TMeta(_,_) -> error "Unexpected meta" expression.epos
|
|
| TMeta(_,_) -> error "Unexpected meta" expression.epos
|
|
| TPatMatch _ -> error "Unexpected pattern match" expression.epos
|
|
| TPatMatch _ -> error "Unexpected pattern match" expression.epos
|
|
@@ -4916,18 +4925,12 @@ let generate_source common_ctx =
|
|
let main_deps = ref [] in
|
|
let main_deps = ref [] in
|
|
let build_xml = ref "" in
|
|
let build_xml = ref "" in
|
|
let scriptable = (Common.defined common_ctx Define.Scriptable) in
|
|
let scriptable = (Common.defined common_ctx Define.Scriptable) in
|
|
- let gen_externs = scriptable || (Common.defined common_ctx Define.DllExport) in
|
|
|
|
- if (gen_externs) then begin
|
|
|
|
- make_base_directory (common_ctx.file ^ "/extern");
|
|
|
|
- end;
|
|
|
|
|
|
|
|
List.iter (fun object_def ->
|
|
List.iter (fun object_def ->
|
|
(match object_def with
|
|
(match object_def with
|
|
- | TClassDecl class_def when is_extern_class class_def ->
|
|
|
|
- (*if (gen_externs) then gen_extern_class common_ctx class_def file_info;*)();
|
|
|
|
|
|
+ | TClassDecl class_def when is_extern_class class_def -> ()
|
|
| TClassDecl class_def ->
|
|
| TClassDecl class_def ->
|
|
let name = class_text class_def.cl_path in
|
|
let name = class_text class_def.cl_path in
|
|
- if (gen_externs) then gen_extern_class common_ctx class_def file_info;
|
|
|
|
let is_internal = is_internal_class class_def.cl_path in
|
|
let is_internal = is_internal_class class_def.cl_path in
|
|
let is_generic_def = match class_def.cl_kind with KGeneric -> true | _ -> false in
|
|
let is_generic_def = match class_def.cl_kind with KGeneric -> true | _ -> false in
|
|
if (is_internal || (is_macro class_def.cl_meta) || is_generic_def) then
|
|
if (is_internal || (is_macro class_def.cl_meta) || is_generic_def) then
|
|
@@ -4947,7 +4950,6 @@ let generate_source common_ctx =
|
|
| TEnumDecl enum_def when enum_def.e_extern -> ()
|
|
| TEnumDecl enum_def when enum_def.e_extern -> ()
|
|
| TEnumDecl enum_def ->
|
|
| TEnumDecl enum_def ->
|
|
let name = class_text enum_def.e_path in
|
|
let name = class_text enum_def.e_path in
|
|
- if (gen_externs) then gen_extern_enum common_ctx enum_def file_info;
|
|
|
|
let is_internal = is_internal_class enum_def.e_path in
|
|
let is_internal = is_internal_class enum_def.e_path in
|
|
if (is_internal) then
|
|
if (is_internal) then
|
|
(if (debug>1) then print_endline (" internal enum " ^ name ))
|
|
(if (debug>1) then print_endline (" internal enum " ^ name ))
|
|
@@ -4979,6 +4981,16 @@ let generate_source common_ctx =
|
|
|
|
|
|
write_resources common_ctx;
|
|
write_resources common_ctx;
|
|
|
|
|
|
|
|
+ (* Output class list if requested *)
|
|
|
|
+ if (scriptable || (Common.defined common_ctx Define.DllExport) ) then begin
|
|
|
|
+ let filename = match Common.defined_value_safe common_ctx Define.DllExport with
|
|
|
|
+ | "" -> "exe.classes"
|
|
|
|
+ | x -> x
|
|
|
|
+ in
|
|
|
|
+ let exeClasses = open_out filename in
|
|
|
|
+ List.iter (fun x -> output_string exeClasses ((join_class_path (fst x) ".") ^ "\n") ) !exe_classes;
|
|
|
|
+ close_out exeClasses;
|
|
|
|
+ end;
|
|
|
|
|
|
let output_name = match common_ctx.main_class with
|
|
let output_name = match common_ctx.main_class with
|
|
| Some path -> (snd path)
|
|
| Some path -> (snd path)
|