wowwww
authorMart Lubbers <mart@martlubbers.net>
Thu, 26 May 2016 14:28:39 +0000 (16:28 +0200)
committerMart Lubbers <mart@martlubbers.net>
Thu, 26 May 2016 14:28:39 +0000 (16:28 +0200)
examples/test.spl
gen.icl

index bb74407..c230ff3 100644 (file)
@@ -18,8 +18,13 @@ foldr(f, acc, l){
        }
 }
 
+times(x, y){
+       return x * y;
+}
+
 main(){
        [Int] l1 = 1 : 2 : 3 : 4 : 5 : [];
-       var c = foldr(plus, 0, l1);
-       var d = map(plus(1), l1);
+       var c = foldr(times, 1, l1);
+       print(c);
+//     var d = map(plus(1), l1);
 }
diff --git a/gen.icl b/gen.icl
index a0333a2..3b32540 100644 (file)
--- a/gen.icl
+++ b/gen.icl
@@ -174,8 +174,10 @@ instance g Expr where
                Just (ADDR t arity) = tell [Instr "ldl" [Lit t] ""] >>| mapM_ g fs >>| pure ()
                Just (LAB l _ fn) = tell 
                        [Instr "ldc" [Lit fn] ""
+                       ,Instr "sth" [] ""
                        ,Instr "ldc" [Lit 0] ""
-                       ,Instr "stmh" [Lit 2] ""]
+                       ,Instr "sth" [] ""
+                       ,Instr "ajs" [Lit -1] ""]
     g (FunExpr _ k es fs) = getAdressbook >>= \ab->case 'Map'.get k ab of
                //Identifier points to function
                Just (LAB l arity fn) = if (arity <> (length es))
@@ -292,18 +294,6 @@ instance g Expr where
                                ,Instr "sub" [] ""
                                ,Instr "str" [Raw "SP"] ""
                                ,Instr "ldr" [Raw "RR"] ""
-                               //RR is nu goed
-//                             ,Instr "ajs" [Lit $ ~ (length es)] ""
-//                             ,Instr "ldl" [Lit t] ""
-//                             ,Instr "ldr" [Raw "RR"] "END OF HIGHERORDERFUNCALL"
-       //                      ,Instr "ldl" [Lit t] ""
-       //                      ,Instr "ldh" [Lit $ 1] ""
-       //                      ,Instr "neg" [] ""
-       //                      ,Instr "ldr" [Raw "SP"] ""
-       //                      ,Instr "add" [] ""
-       //                      ,Instr "ldc" [Lit arity] ""
-       //                      ,Instr "sub" [] ""
-       //                      ,Instr "str" [Raw "SP"] ""
                                ]
                        )
                Nothing = liftT (Left $ Error "Undefined function!!!")