|
@@ -2295,7 +2295,7 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
|
|
| TTypeExpr (TClassDecl tcls) ->
|
|
| TTypeExpr (TClassDecl tcls) ->
|
|
self#write (self#use_t (TInst (tcls, [])))
|
|
self#write (self#use_t (TInst (tcls, [])))
|
|
| _ ->
|
|
| _ ->
|
|
- if is_string type_expr then
|
|
|
|
|
|
+ if is_string (reveal_expr type_expr) then
|
|
self#write_expr type_expr
|
|
self#write_expr type_expr
|
|
else begin
|
|
else begin
|
|
self#write "(";
|
|
self#write "(";
|
|
@@ -2368,6 +2368,19 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
|
|
| [] -> self#write_assoc_array_decl []
|
|
| [] -> self#write_assoc_array_decl []
|
|
| { eexpr = TObjectDecl fields } :: [] -> self#write_assoc_array_decl fields
|
|
| { eexpr = TObjectDecl fields } :: [] -> self#write_assoc_array_decl fields
|
|
| _ -> ctx.pgc_common.error "php.Syntax.assocDecl() accepts object declaration only." self#pos
|
|
| _ -> ctx.pgc_common.error "php.Syntax.assocDecl() accepts object declaration only." self#pos
|
|
|
|
+ (**
|
|
|
|
+ Writes `e` to be used as a field access.
|
|
|
|
+ If `e` is a constant string, writes the constant without quotes.
|
|
|
|
+ Otherwise writes `{e}`
|
|
|
|
+ *)
|
|
|
|
+ method write_syntax_field_expr field_expr =
|
|
|
|
+ match reveal_expr field_expr with
|
|
|
|
+ | { eexpr = TConst (TString method_name) } ->
|
|
|
|
+ self#write method_name
|
|
|
|
+ | _ ->
|
|
|
|
+ self#write "{";
|
|
|
|
+ self#write_expr field_expr;
|
|
|
|
+ self#write "}"
|
|
(**
|
|
(**
|
|
Writes a call to instance method (for `php.Syntax.call()`)
|
|
Writes a call to instance method (for `php.Syntax.call()`)
|
|
*)
|
|
*)
|
|
@@ -2375,9 +2388,9 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
|
|
match args with
|
|
match args with
|
|
| obj_expr :: method_expr :: args ->
|
|
| obj_expr :: method_expr :: args ->
|
|
self#write_expr obj_expr;
|
|
self#write_expr obj_expr;
|
|
- self#write "->{";
|
|
|
|
- self#write_expr method_expr;
|
|
|
|
- self#write "}(";
|
|
|
|
|
|
+ self#write "->";
|
|
|
|
+ self#write_syntax_field_expr method_expr;
|
|
|
|
+ self#write "(";
|
|
write_args self#write (fun e -> self#write_expr e) args;
|
|
write_args self#write (fun e -> self#write_expr e) args;
|
|
self#write ")"
|
|
self#write ")"
|
|
| _ -> fail self#pos
|
|
| _ -> fail self#pos
|
|
@@ -2388,9 +2401,9 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
|
|
match args with
|
|
match args with
|
|
| type_expr :: method_expr :: args ->
|
|
| type_expr :: method_expr :: args ->
|
|
self#write_type type_expr;
|
|
self#write_type type_expr;
|
|
- self#write "::{";
|
|
|
|
- self#write_expr method_expr;
|
|
|
|
- self#write "}(";
|
|
|
|
|
|
+ self#write "::";
|
|
|
|
+ self#write_syntax_field_expr method_expr;
|
|
|
|
+ self#write "(";
|
|
write_args self#write (fun e -> self#write_expr e) args;
|
|
write_args self#write (fun e -> self#write_expr e) args;
|
|
self#write ")"
|
|
self#write ")"
|
|
| _ -> fail self#pos
|
|
| _ -> fail self#pos
|
|
@@ -2401,9 +2414,8 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
|
|
match args with
|
|
match args with
|
|
| obj_expr :: field_expr :: [] ->
|
|
| obj_expr :: field_expr :: [] ->
|
|
self#write_expr obj_expr;
|
|
self#write_expr obj_expr;
|
|
- self#write "->{";
|
|
|
|
- self#write_expr field_expr;
|
|
|
|
- self#write "}"
|
|
|
|
|
|
+ self#write "->";
|
|
|
|
+ self#write_syntax_field_expr field_expr;
|
|
| _ -> fail self#pos
|
|
| _ -> fail self#pos
|
|
(**
|
|
(**
|
|
Writes field access for writing (for `php.Syntax.setField()`)
|
|
Writes field access for writing (for `php.Syntax.setField()`)
|