|
@@ -900,14 +900,6 @@ and gen_value ctx e =
|
|
|
)
|
|
|
in
|
|
|
match e.eexpr with
|
|
|
- | TBinop((OpAssignOp(_)|OpAssign),e1,e2) ->
|
|
|
- spr ctx "(function()";
|
|
|
- gen_expr ctx e;
|
|
|
- semicolon ctx;
|
|
|
- spr ctx " return ";
|
|
|
- gen_expr ctx e1;
|
|
|
- semicolon ctx;
|
|
|
- spr ctx " end)()";
|
|
|
| TConst _
|
|
|
| TLocal _
|
|
|
| TArray _
|
|
@@ -1004,8 +996,8 @@ and gen_value ctx e =
|
|
|
v()
|
|
|
|
|
|
and gen_tbinop ctx op e1 e2 =
|
|
|
- (match op with
|
|
|
- | Ast.OpAssign ->
|
|
|
+ (match op, e1.eexpr with
|
|
|
+ | Ast.OpAssign, _ ->
|
|
|
let iife_assign = ctx.iife_assign in
|
|
|
if iife_assign then spr ctx "(function() ";
|
|
|
(match e2.eexpr with
|
|
@@ -1024,20 +1016,30 @@ and gen_tbinop ctx op e1 e2 =
|
|
|
gen_value ctx e1;
|
|
|
spr ctx " end)()";
|
|
|
end;
|
|
|
- | Ast.OpAssignOp(op2) ->
|
|
|
- spr ctx "(function() "; gen_value ctx e1;
|
|
|
- spr ctx " = "; gen_tbinop ctx op2 e1 e2;
|
|
|
- spr ctx " return "; gen_value ctx e1;
|
|
|
- spr ctx " end)()";
|
|
|
- | Ast.OpXor | Ast.OpAnd | Ast.OpShl | Ast.OpShr | Ast.OpUShr | Ast.OpOr ->
|
|
|
+ | Ast.OpAssignOp(op2), TArray(e3,e4) ->
|
|
|
+ spr ctx "(function() "; newline ctx;
|
|
|
+ spr ctx "_idx = "; gen_value ctx e4; semicolon ctx; newline ctx;
|
|
|
+ gen_value ctx e3; spr ctx "[_idx] = ";
|
|
|
+ gen_value ctx e3; spr ctx "[_idx] ";
|
|
|
+ print ctx " %s " (Ast.s_binop op2);
|
|
|
+ gen_value ctx e2; newline ctx;
|
|
|
+ spr ctx " return ";
|
|
|
+ gen_value ctx e3; spr ctx "[_idx]"; newline ctx;
|
|
|
+ spr ctx " end)()";
|
|
|
+ | Ast.OpAssignOp(op2),_ ->
|
|
|
+ spr ctx "(function() "; gen_value ctx e1;
|
|
|
+ spr ctx " = "; gen_tbinop ctx op2 e1 e2;
|
|
|
+ spr ctx " return "; gen_value ctx e1;
|
|
|
+ spr ctx " end)()";
|
|
|
+ | Ast.OpXor,_ | Ast.OpAnd,_ | Ast.OpShl,_ | Ast.OpShr,_ | Ast.OpUShr,_ | Ast.OpOr,_ ->
|
|
|
gen_bitop ctx op e1 e2;
|
|
|
- | Ast.OpMod ->
|
|
|
- spr ctx "_G.math.fmod(";
|
|
|
- gen_expr ctx e1;
|
|
|
- spr ctx ", ";
|
|
|
- gen_expr ctx e2;
|
|
|
- spr ctx ")";
|
|
|
- | Ast.OpAdd when (is_string_expr e1 || is_string_expr e2) ->
|
|
|
+ | Ast.OpMod,_ ->
|
|
|
+ spr ctx "_G.math.fmod(";
|
|
|
+ gen_expr ctx e1;
|
|
|
+ spr ctx ", ";
|
|
|
+ gen_expr ctx e2;
|
|
|
+ spr ctx ")";
|
|
|
+ | Ast.OpAdd,_ when (is_string_expr e1 || is_string_expr e2) ->
|
|
|
spr ctx "Std.string(";
|
|
|
gen_value ctx e1;
|
|
|
spr ctx ") ";
|