summaryrefslogtreecommitdiff
path: root/examples/gfcc/JVM.hs
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2010-03-02 19:27:34 +0000
committeraarne <aarne@chalmers.se>2010-03-02 19:27:34 +0000
commitdbe5a210b7d4a7940d9ffc76d862f6be2526bb37 (patch)
treec0479e1a30bce75252235d158b79b96d5cd32b33 /examples/gfcc/JVM.hs
parente4748e998453b979af46983a079f2ec3d307ada4 (diff)
cleaned up gfcc ; added gfcc script
Diffstat (limited to 'examples/gfcc/JVM.hs')
-rw-r--r--examples/gfcc/JVM.hs20
1 files changed, 0 insertions, 20 deletions
diff --git a/examples/gfcc/JVM.hs b/examples/gfcc/JVM.hs
deleted file mode 100644
index 380570049..000000000
--- a/examples/gfcc/JVM.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-module JVM where
-
-mkJVM :: String -> String
-mkJVM = unlines . reverse . fst . foldl trans ([],([],0)) . lines where
- trans (code,(env,v)) s = case words s of
- ".method":f:ns -> ((".method " ++ f ++ concat ns):code,([],0))
- "alloc":t:x:_ -> (code, ((x,v):env, v + size t))
- ".limit":"locals":ns -> chCode (".limit locals " ++ show (length ns - 1))
- t:"_load" :x:_ -> chCode (t ++ "load " ++ look x)
- t:"_store":x:_ -> chCode (t ++ "store " ++ look x)
- t:"_return":_ -> chCode (t ++ "return")
- "goto":ns -> chCode ("goto " ++ concat ns)
- "ifzero":ns -> chCode ("ifzero " ++ concat ns)
- _ -> chCode s
- where
- chCode c = (c:code,(env,v))
- look x = maybe (x ++ show env) show $ lookup x env
- size t = case t of
- "d" -> 2
- _ -> 1