mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-25 08:08:47 +00:00
fix: do not fix extra root if it points to lama stack; uncomment extra roots registration; rise error if binary operation is done over pointers
This commit is contained in:
parent
8bc173762d
commit
ce0b369958
3 changed files with 134 additions and 43 deletions
31
src/X86.ml
31
src/X86.ml
|
|
@ -306,9 +306,32 @@ let compile cmd env imports code =
|
|||
| _ -> [Mov (v, eax); Mov (eax, I (0, x)); Mov (eax, x)]
|
||||
)
|
||||
|
||||
| BINOP op ->
|
||||
| BINOP op ->
|
||||
let x, y, env' = env#pop2 in
|
||||
env'#push y,
|
||||
(match op with
|
||||
|"<" | "<=" | "==" | "!=" | ">=" | ">" ->
|
||||
[Push (eax);
|
||||
Push (edx);
|
||||
Mov (y, eax);
|
||||
Binop("&&", L(1), eax);
|
||||
Mov (x, edx);
|
||||
Binop("&&", L(1), edx);
|
||||
Binop("cmp", eax, edx);
|
||||
CJmp ("nz", "_ERROR2");
|
||||
Pop (edx);
|
||||
Pop (eax)]
|
||||
(* | "+" | "-" | "*" | "/" -> *)
|
||||
| _ ->
|
||||
[Mov (y, eax);
|
||||
Binop("&&", L(1), eax);
|
||||
Binop("cmp", L(0), eax);
|
||||
CJmp ("z", "_ERROR");
|
||||
Mov (x, eax);
|
||||
Binop("&&", L(1), eax);
|
||||
Binop("cmp", L(0), eax);
|
||||
CJmp ("z", "_ERROR")]
|
||||
| _ -> []) @
|
||||
(match op with
|
||||
| "/" ->
|
||||
[Mov (y, eax);
|
||||
|
|
@ -443,6 +466,12 @@ let compile cmd env imports code =
|
|||
Binop ("test", eax, eax);
|
||||
CJmp ("z", "_continue");
|
||||
Ret;
|
||||
Label ("_ERROR");
|
||||
Call "Lbinoperror";
|
||||
Ret;
|
||||
Label ("_ERROR2");
|
||||
Call "Lbinoperror2";
|
||||
Ret;
|
||||
Label "_continue";
|
||||
Mov (L 1, M "_init");
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue