|
@@ -1405,6 +1405,7 @@ and tcpp_expr_expr =
|
|
| CppString of string
|
|
| CppString of string
|
|
| CppBool of bool
|
|
| CppBool of bool
|
|
| CppNull
|
|
| CppNull
|
|
|
|
+ | CppNullAccess
|
|
| CppNil
|
|
| CppNil
|
|
| CppThis of tcppthis
|
|
| CppThis of tcppthis
|
|
| CppSuper of tcppthis
|
|
| CppSuper of tcppthis
|
|
@@ -1471,6 +1472,7 @@ let rec s_tcpp = function
|
|
| CppFunction _ -> "CppFunction"
|
|
| CppFunction _ -> "CppFunction"
|
|
| CppEnumIndex _ -> "CppEnumIndex"
|
|
| CppEnumIndex _ -> "CppEnumIndex"
|
|
| CppEnumField _ -> "CppEnumField"
|
|
| CppEnumField _ -> "CppEnumField"
|
|
|
|
+ | CppNullAccess -> "CppNullAccess"
|
|
|
|
|
|
| CppCall (FuncThis _,_) -> "CppCallThis"
|
|
| CppCall (FuncThis _,_) -> "CppCallThis"
|
|
| CppCall (FuncInstance (obj,objC,field),_) ->
|
|
| CppCall (FuncInstance (obj,objC,field),_) ->
|
|
@@ -2076,7 +2078,9 @@ let retype_expression ctx request_type function_args expression_tree =
|
|
CppFunction( FuncInstance(retypedObj,false,member), funcReturn ), exprType
|
|
CppFunction( FuncInstance(retypedObj,false,member), funcReturn ), exprType
|
|
else
|
|
else
|
|
CppDynamicField(retypedObj, member.cf_name), TCppVariant
|
|
CppDynamicField(retypedObj, member.cf_name), TCppVariant
|
|
- end else if is_struct_access obj.etype then begin
|
|
|
|
|
|
+ end else if clazzType=TCppNull then
|
|
|
|
+ CppNullAccess, TCppDynamic
|
|
|
|
+ else if is_struct_access obj.etype then begin
|
|
match retypedObj.cppexpr with
|
|
match retypedObj.cppexpr with
|
|
| CppThis ThisReal ->
|
|
| CppThis ThisReal ->
|
|
CppVar(VarThis(member)), exprType
|
|
CppVar(VarThis(member)), exprType
|
|
@@ -2165,6 +2169,8 @@ let retype_expression ctx request_type function_args expression_tree =
|
|
let fieldName = field.cf_name in
|
|
let fieldName = field.cf_name in
|
|
if obj.cpptype=TCppGlobal then
|
|
if obj.cpptype=TCppGlobal then
|
|
CppGlobal(fieldName), cpp_type_of expr.etype
|
|
CppGlobal(fieldName), cpp_type_of expr.etype
|
|
|
|
+ else if obj.cpptype=TCppNull then
|
|
|
|
+ CppNullAccess, TCppDynamic
|
|
else if is_internal_member fieldName then begin
|
|
else if is_internal_member fieldName then begin
|
|
let cppType = cpp_type_of expr.etype in
|
|
let cppType = cpp_type_of expr.etype in
|
|
if obj.cpptype=TCppString then
|
|
if obj.cpptype=TCppString then
|
|
@@ -2176,7 +2182,9 @@ let retype_expression ctx request_type function_args expression_tree =
|
|
|
|
|
|
| FDynamic fieldName ->
|
|
| FDynamic fieldName ->
|
|
let obj = retype TCppDynamic obj in
|
|
let obj = retype TCppDynamic obj in
|
|
- if fieldName="cca" && obj.cpptype=TCppString then
|
|
|
|
|
|
+ if obj.cpptype=TCppNull then
|
|
|
|
+ CppNullAccess, TCppDynamic
|
|
|
|
+ else if fieldName="cca" && obj.cpptype=TCppString then
|
|
CppFunction( FuncInternal(obj,"cca","."), TCppScalar("Int")), TCppDynamic
|
|
CppFunction( FuncInternal(obj,"cca","."), TCppScalar("Int")), TCppDynamic
|
|
else if fieldName="__s" && obj.cpptype=TCppString then
|
|
else if fieldName="__s" && obj.cpptype=TCppString then
|
|
CppVar( VarInternal(obj,".","__s")), TCppPointer("ConstPointer", TCppScalar("char"))
|
|
CppVar( VarInternal(obj,".","__s")), TCppPointer("ConstPointer", TCppScalar("char"))
|
|
@@ -2217,52 +2225,55 @@ let retype_expression ctx request_type function_args expression_tree =
|
|
|
|
|
|
| TCall( func, args ) ->
|
|
| TCall( func, args ) ->
|
|
let retypedFunc = retype TCppDynamic func in
|
|
let retypedFunc = retype TCppDynamic func in
|
|
- let cppType = cpp_type_of expr.etype in
|
|
|
|
- (*
|
|
|
|
- let retypedArgs = List.map2 (fun arg (var,opt) ->
|
|
|
|
- retype (cpp_fun_arg_type_of var opt) arg
|
|
|
|
- ) args, func.tf_args in
|
|
|
|
- *)
|
|
|
|
- let retypedArgs = List.map (retype TCppDynamic ) args in
|
|
|
|
- (match retypedFunc.cppexpr with
|
|
|
|
- | CppFunction(FuncFromStaticFunction ,returnType) ->
|
|
|
|
- ( match retypedArgs with
|
|
|
|
- | [ {cppexpr=CppFunction( FuncStatic(clazz,false,member), funcReturn)} ] ->
|
|
|
|
- CppFunctionAddress(clazz,member), funcReturn
|
|
|
|
- | _ -> error "cpp.Function.fromStaticFunction must be called on static function" expr.epos;
|
|
|
|
- )
|
|
|
|
- | CppEnumIndex(_) ->
|
|
|
|
- (* Not actually a TCall...*)
|
|
|
|
- retypedFunc.cppexpr, retypedFunc.cpptype
|
|
|
|
- | CppFunction(func,returnType) ->
|
|
|
|
- CppCall(func,retypedArgs), returnType
|
|
|
|
- | CppEnumField(enum, field) ->
|
|
|
|
- CppCall( FuncEnumConstruct(enum,field),retypedArgs), cppType
|
|
|
|
- | CppSuper(_) ->
|
|
|
|
- CppCall( FuncSuperConstruct ,retypedArgs), TCppVoid
|
|
|
|
- | CppDynamicField(expr,name) ->
|
|
|
|
- (* Special function calls *)
|
|
|
|
- (match expr.cpptype, name with
|
|
|
|
- | TCppGlobal, _ ->
|
|
|
|
- CppCall( FuncGlobal(name),retypedArgs), cppType
|
|
|
|
-
|
|
|
|
- | TCppString, _ ->
|
|
|
|
- CppCall( FuncInternal(expr,name,"."),retypedArgs), cppType
|
|
|
|
-
|
|
|
|
- | _, "__Tag" ->
|
|
|
|
- CppCall( FuncInternal(expr,"getTag","->"),retypedArgs), cppType
|
|
|
|
-
|
|
|
|
- | _, name when is_internal_member name ->
|
|
|
|
- CppCall( FuncInternal(expr,name,"->"),retypedArgs), cppType
|
|
|
|
-
|
|
|
|
- | _ -> (* not special *)
|
|
|
|
- CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
|
|
|
|
- )
|
|
|
|
- | CppGlobal(_) ->
|
|
|
|
- CppCall( FuncDynamic(retypedFunc) ,retypedArgs), cppType
|
|
|
|
- | _ ->
|
|
|
|
- CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
|
|
|
|
- )
|
|
|
|
|
|
+ if retypedFunc.cpptype=TCppNull then
|
|
|
|
+ CppNullAccess, TCppDynamic
|
|
|
|
+ else begin
|
|
|
|
+ let cppType = cpp_type_of expr.etype in
|
|
|
|
+ (*
|
|
|
|
+ let retypedArgs = List.map2 (fun arg (var,opt) ->
|
|
|
|
+ retype (cpp_fun_arg_type_of var opt) arg
|
|
|
|
+ ) args, func.tf_args in
|
|
|
|
+ *)
|
|
|
|
+ let retypedArgs = List.map (retype TCppDynamic ) args in
|
|
|
|
+ match retypedFunc.cppexpr with
|
|
|
|
+ | CppFunction(FuncFromStaticFunction ,returnType) ->
|
|
|
|
+ ( match retypedArgs with
|
|
|
|
+ | [ {cppexpr=CppFunction( FuncStatic(clazz,false,member), funcReturn)} ] ->
|
|
|
|
+ CppFunctionAddress(clazz,member), funcReturn
|
|
|
|
+ | _ -> error "cpp.Function.fromStaticFunction must be called on static function" expr.epos;
|
|
|
|
+ )
|
|
|
|
+ | CppEnumIndex(_) ->
|
|
|
|
+ (* Not actually a TCall...*)
|
|
|
|
+ retypedFunc.cppexpr, retypedFunc.cpptype
|
|
|
|
+ | CppFunction(func,returnType) ->
|
|
|
|
+ CppCall(func,retypedArgs), returnType
|
|
|
|
+ | CppEnumField(enum, field) ->
|
|
|
|
+ CppCall( FuncEnumConstruct(enum,field),retypedArgs), cppType
|
|
|
|
+ | CppSuper(_) ->
|
|
|
|
+ CppCall( FuncSuperConstruct ,retypedArgs), TCppVoid
|
|
|
|
+ | CppDynamicField(expr,name) ->
|
|
|
|
+ (* Special function calls *)
|
|
|
|
+ (match expr.cpptype, name with
|
|
|
|
+ | TCppGlobal, _ ->
|
|
|
|
+ CppCall( FuncGlobal(name),retypedArgs), cppType
|
|
|
|
+
|
|
|
|
+ | TCppString, _ ->
|
|
|
|
+ CppCall( FuncInternal(expr,name,"."),retypedArgs), cppType
|
|
|
|
+
|
|
|
|
+ | _, "__Tag" ->
|
|
|
|
+ CppCall( FuncInternal(expr,"getTag","->"),retypedArgs), cppType
|
|
|
|
+
|
|
|
|
+ | _, name when is_internal_member name ->
|
|
|
|
+ CppCall( FuncInternal(expr,name,"->"),retypedArgs), cppType
|
|
|
|
+
|
|
|
|
+ | _ -> (* not special *)
|
|
|
|
+ CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
|
|
|
|
+ )
|
|
|
|
+ | CppGlobal(_) ->
|
|
|
|
+ CppCall( FuncDynamic(retypedFunc) ,retypedArgs), cppType
|
|
|
|
+ | _ ->
|
|
|
|
+ CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
|
|
|
|
+ end
|
|
|
|
|
|
| TNew (clazz,params,args) ->
|
|
| TNew (clazz,params,args) ->
|
|
(* New DynamicArray ? *)
|
|
(* New DynamicArray ? *)
|
|
@@ -2643,6 +2654,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
|
|
out ".StaticCast< ::hx::EnumBase >()";
|
|
out ".StaticCast< ::hx::EnumBase >()";
|
|
out "->getIndex()"
|
|
out "->getIndex()"
|
|
|
|
|
|
|
|
+ | CppNullAccess -> out ("hx::Throw(" ^ strq "Null access" ^ ")")
|
|
| CppFunction(func,_) ->
|
|
| CppFunction(func,_) ->
|
|
(match func with
|
|
(match func with
|
|
| FuncThis(field) ->
|
|
| FuncThis(field) ->
|