summaryrefslogtreecommitdiff
path: root/examples/gfcc/ImperJVM.gf
diff options
context:
space:
mode:
authoraarne <unknown>2004-09-18 09:24:51 +0000
committeraarne <unknown>2004-09-18 09:24:51 +0000
commit3a1f403a0146f4717b210373167640a07f0248dd (patch)
treeaf1fe17319c7dd20117b9b842c01b52b35fe96fd /examples/gfcc/ImperJVM.gf
parent6ec3a53d3cd1666696430d25e1d0c746f3c7dde8 (diff)
doc
Diffstat (limited to 'examples/gfcc/ImperJVM.gf')
-rw-r--r--examples/gfcc/ImperJVM.gf41
1 files changed, 28 insertions, 13 deletions
diff --git a/examples/gfcc/ImperJVM.gf b/examples/gfcc/ImperJVM.gf
index 10457fbfe..9acbfa263 100644
--- a/examples/gfcc/ImperJVM.gf
+++ b/examples/gfcc/ImperJVM.gf
@@ -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" ;