|
@@ -561,61 +561,37 @@ and gen_expr ?(local=true) ctx e =
|
|
ctx.iife_assign <- false;
|
|
ctx.iife_assign <- false;
|
|
| TUnop ((Increment|Decrement) as op,unop_flag, e) ->
|
|
| TUnop ((Increment|Decrement) as op,unop_flag, e) ->
|
|
spr ctx "(function() ";
|
|
spr ctx "(function() ";
|
|
- (match unop_flag with
|
|
|
|
- | Ast.Prefix ->
|
|
|
|
- (match e.eexpr with
|
|
|
|
- |TArray(e1,e2) ->
|
|
|
|
- spr ctx "local _idx = ";
|
|
|
|
- gen_value ctx e2;
|
|
|
|
- spr ctx " local ret =";
|
|
|
|
- gen_value ctx e1; spr ctx "[_idx]";
|
|
|
|
- gen_value ctx e1; spr ctx "[_idx] = ret";
|
|
|
|
- (match op with
|
|
|
|
- |Increment -> spr ctx " +"
|
|
|
|
- |Decrement -> spr ctx " -"
|
|
|
|
- |_-> print ctx " %s" (Ast.s_unop op));
|
|
|
|
- spr ctx " 1 return ";
|
|
|
|
- gen_value ctx e1; spr ctx "[_idx]";
|
|
|
|
- spr ctx "end)()";
|
|
|
|
- | _ ->
|
|
|
|
- gen_value ctx e;
|
|
|
|
- spr ctx " = ";
|
|
|
|
- gen_value ctx e;
|
|
|
|
- (match op with
|
|
|
|
- |Increment -> spr ctx " +"
|
|
|
|
- |Decrement -> spr ctx " -"
|
|
|
|
- |_-> print ctx " %s" (Ast.s_unop op));
|
|
|
|
- spr ctx " 1 return ";
|
|
|
|
- gen_value ctx e;
|
|
|
|
- spr ctx " end)()";
|
|
|
|
- );
|
|
|
|
- | Ast.Postfix ->
|
|
|
|
- (match e.eexpr with
|
|
|
|
- |TArray(e1,e2) ->
|
|
|
|
- spr ctx "local _idx = ";
|
|
|
|
- gen_value ctx e2;
|
|
|
|
- spr ctx " local ret =";
|
|
|
|
|
|
+ (match e.eexpr, unop_flag with
|
|
|
|
+ | TArray(e1,e2), _ ->
|
|
|
|
+ spr ctx "local _idx = ";
|
|
|
|
+ gen_value ctx e2;
|
|
|
|
+ spr ctx " local _ =";
|
|
|
|
+ gen_value ctx e1; spr ctx "[_idx]";
|
|
|
|
+ gen_value ctx e1; spr ctx "[_idx] = _";
|
|
|
|
+ | _, Ast.Prefix ->
|
|
|
|
+ gen_value ctx e;
|
|
|
|
+ spr ctx " = ";
|
|
|
|
+ gen_value ctx e;
|
|
|
|
+ | _, Ast.Postfix ->
|
|
|
|
+ spr ctx "local _ = ";
|
|
|
|
+ gen_value ctx e; spr ctx "; ";
|
|
|
|
+ gen_value ctx e;
|
|
|
|
+ spr ctx " = ";
|
|
|
|
+ gen_value ctx e);
|
|
|
|
+ (match op with
|
|
|
|
+ |Increment -> spr ctx " + 1;"
|
|
|
|
+ |Decrement -> spr ctx " - 1;"
|
|
|
|
+ |_-> print ctx " %s 1;" (Ast.s_unop op));
|
|
|
|
+ spr ctx " return ";
|
|
|
|
+ (match unop_flag, e.eexpr with
|
|
|
|
+ | Ast.Prefix, TArray(e1,e2) ->
|
|
gen_value ctx e1; spr ctx "[_idx]";
|
|
gen_value ctx e1; spr ctx "[_idx]";
|
|
- gen_value ctx e1; spr ctx "[_idx] = ret";
|
|
|
|
- (match op with
|
|
|
|
- |Increment -> spr ctx " +"
|
|
|
|
- |Decrement -> spr ctx " -"
|
|
|
|
- |_-> print ctx " %s" (Ast.s_unop op));
|
|
|
|
- spr ctx " 1 return ret end)()";
|
|
|
|
- | _ ->
|
|
|
|
- spr ctx "local _ = ";
|
|
|
|
- gen_value ctx e;
|
|
|
|
- newline ctx;
|
|
|
|
|
|
+ | Ast.Prefix, _ ->
|
|
gen_value ctx e;
|
|
gen_value ctx e;
|
|
- spr ctx " = ";
|
|
|
|
- gen_value ctx e;
|
|
|
|
- (match op with
|
|
|
|
- |Increment -> spr ctx " +"
|
|
|
|
- |Decrement -> spr ctx " -"
|
|
|
|
- |_-> print ctx " %s" (Ast.s_unop op));
|
|
|
|
- spr ctx " 1 return _ end)()";
|
|
|
|
- );
|
|
|
|
- )
|
|
|
|
|
|
+ | Ast.Postfix, _ ->
|
|
|
|
+ spr ctx "_");
|
|
|
|
+ semicolon ctx;
|
|
|
|
+ spr ctx " end)()";
|
|
| TUnop (Not,unop_flag,e) ->
|
|
| TUnop (Not,unop_flag,e) ->
|
|
spr ctx "not ";
|
|
spr ctx "not ";
|
|
gen_value ctx e;
|
|
gen_value ctx e;
|