From 8291939287baa496d368855c0bea1e6f30a8612d Mon Sep 17 00:00:00 2001 From: pimjager Date: Mon, 23 May 2016 16:19:24 +0200 Subject: [PATCH] fixed read --- examples/codeGen.spl | 2 +- gen.icl | 5 +++-- sem.icl | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/codeGen.spl b/examples/codeGen.spl index 7e78897..3c64c1a 100644 --- a/examples/codeGen.spl +++ b/examples/codeGen.spl @@ -28,7 +28,7 @@ isE(x) :: [a] -> Bool { test() { var x =print(5); - var f = read; + //var f = read; var y = read(); print(True); print('a'); diff --git a/gen.icl b/gen.icl index 53a1de7..5183804 100644 --- a/gen.icl +++ b/gen.icl @@ -42,7 +42,7 @@ labelStream = ["lbl_" +++ toString i\\i<-[1..]] defaultAddressBook :: Addressbook defaultAddressBook = extend "1printint" (LAB "1printint" 1) $ extend "1printchar" (LAB "1printchar" 1) - $ extend "1readchar" (LAB "1readchar" 0) + $ extend "read" (LAB "read" 0) $ extend "1readint" (LAB "1readint" 0) $ extend "isEmpty" (LAB "isempty" 1) 'Map'.newMap @@ -77,7 +77,7 @@ programContext = [Lab "1printint" ,Instr "str" [Raw "RR"] "" ,Instr "unlink" [] "" ,Instr "ret" [] "" - ,Lab "1readchar" + ,Lab "read" ,Instr "link" [Lit 0] "" ,Instr "trap" [Lit 11] "read char" ,Instr "str" [Raw "RR"] "" @@ -92,6 +92,7 @@ programContext = [Lab "1printint" ,Instr "str" [Raw "RR"] "" ,Instr "unlink" [] "" ,Instr "ret" [] "" + ,Lab "read" ] //helper functions for the gen monad diff --git a/sem.icl b/sem.icl index 9eafed1..f87e5bb 100644 --- a/sem.icl +++ b/sem.icl @@ -225,7 +225,7 @@ instance infer Expr where infer e2 >>= \(s2, t2, e2_) -> pure (compose s2 s1, TupleType (t1,t2), TupleExpr p (e1_,e2_)) - FunExpr p f args fs = //todo: fix print + FunExpr p f args fs = lookup f >>= \expected -> let accST = (\(s,ts,es) e->infer e >>= \(s_,et,e_)-> pure (compose s_ s,ts++[et],es++[e_])) in foldM accST (zero,[],[]) args >>= \(s1, argTs, args_)-> -- 2.20.1