This commit is contained in:
aarne
2004-09-18 09:24:51 +00:00
parent 6ec3a53d3c
commit 3a1f403a01
5 changed files with 220 additions and 37 deletions

View File

@@ -4,25 +4,40 @@ concrete ImperJVM of Imper = open Prelude, Precedence, ResImper in {
flags lexer=codevars ; unlexer=code ; startcat=Stm ;
lincat
Stm = SS ;
Stm = Instr ;
Typ = SS ;
Exp = SS ;
Var = SS ;
lin
Decl typ cont = ss [] ; ----
Assign t x exp = statement (exp.s ++ t.s ++ "_store" ++ x.s) ;
Return t exp = statement (exp.s ++ t.s ++ "_return") ;
While exp loop = statement ("TEST:" ++ exp.s ++ "ifzero_goto" ++
"END" ++ ";" ++ loop.s ++ "END") ;
Block stm = stm ;
Next stm cont = ss (stm.s ++ cont.s) ;
Decl typ cont = instrc (
"alloc_" ++ typ.s ++ cont.$0
) cont ;
Assign t x exp = instrc (
exp.s ++
t.s ++ "_store" ++ x.s
) ;
Return t exp = instr (
exp.s ++
t.s ++ "_return") ;
While exp loop = instrc (
"TEST:" ++ exp.s ++
"ifzero_goto" ++ "END" ++ ";" ++
loop.s ++
"END"
) ;
Block stm = instrc stm.s ;
End = ss [] ** {s3 = []} ;
EVar t x = statement (t.s ++ "_load" ++ x.s) ;
EInt n = statement ("i_push" ++ n.s) ;
EFloat a b = statement ("f_push" ++ a.s ++ "." ++ b.s) ;
EAddI x y = statement (x.s ++ y.s ++ "iadd") ;
EAddF x y = statement (x.s ++ y.s ++ "fadd") ;
EVar t x = instr (t.s ++ "_load" ++ x.s) ;
EInt n = instr ("ipush" ++ n.s) ;
EFloat a b = instr ("fpush" ++ a.s ++ "." ++ b.s) ;
EAddI = binop "iadd" ;
EAddF = binop "fadd" ;
EMulI = binop "imul" ;
EMulF = binop "fmul" ;
ELtI = binop ("call" ++ "ilt") ;
ELtF = binop ("call" ++ "flt") ;
TInt = ss "i" ;
TFloat = ss "f" ;