Permalink
Browse files

Fixed scoping bug, and make sure dummy values are initialised

darcs-hash:20080623111158-6ac22-ce5aafde7e210478f46bf3a1734068242138e6d4.gz
  • Loading branch information...
1 parent 5d8a31b commit 56561a3883aacb05cdceb6842174baa2bde0a471 eb committed Jun 23, 2008
Showing with 8 additions and 4 deletions.
  1. +3 −2 Epic/Bytecode.lhs
  2. +2 −1 Epic/CodegenC.lhs
  3. +1 −1 Makefile
  4. +2 −0 evm/closure.c
View
@@ -37,6 +37,7 @@ at this stage.
> | EVAL TmpVar
> -- | LET TmpVar Local TmpVar
> | RETURN TmpVar
+> | DRETURN -- return dummy value
> | ERROR String -- Fatal error, exit
> deriving Show
@@ -125,8 +126,8 @@ place.
> do loc <- new_locals 1
> reg' <- new_tmp
> valcode <- ecomp Middle val reg' vs
-> scopecode <- ecomp tcall scope reg vs
-> return $ valcode ++ (ASSIGN loc reg'):scopecode
+> scopecode <- ecomp tcall scope reg (vs+1)
+> return $ valcode ++ (ASSIGN vs reg'):scopecode
> ecomp tcall (Error str) reg vs = return [ERROR str]
> ecomp tcall Impossible reg vs = return [ERROR "The impossible happened."]
> ecomp tcall (ForeignCall ty fn argtypes) reg vs = do
View
@@ -140,6 +140,7 @@
> ecode ++ "}"
> cg (EVAL v) = return $ "EVAL((VAL)"++tmp v++");"
> cg (RETURN t) = return $ "return "++tmp t++";"
+> cg DRETURN = return $ "return NULL;"
> cg (ERROR s) = return $ "ERROR("++show s++");"
> -- cg x = return $ "NOP; // not done " ++ show x
@@ -200,7 +201,7 @@
> foreignArgs [x] = foreignArg x
> foreignArgs (x:xs) = foreignArg x ++ ", " ++ foreignArgs xs
-> castFrom t TyUnit x = x
+> castFrom t TyUnit x = tmp t ++ " = NULL; " ++ x
> castFrom t TyString rest = tmp t ++ " = MKSTR((char*)(" ++ rest ++ "))"
> castFrom t TyInt rest = tmp t ++ " = MKINT((int)(" ++ rest ++ "))"
> castFrom t TyBigInt rest = tmp t ++ " = MKBIGINT((mpz_t*)(" ++ rest ++ "))"
View
@@ -32,7 +32,7 @@ test:
make -C tests
epic: .PHONY configure package install
- cd compiler; ghc $(GHCOPTS) --make Main.lhs -o epic -package epic
+ cd compiler; ghc $(GHCOPTS) Main.lhs -o epic -package epic
epic_install: epic
install compiler/epic $(PREFIX)/bin
View
@@ -521,6 +521,8 @@ inline VAL CLOSURE_APPLY5(VAL f, VAL a1, VAL a2, VAL a3, VAL a4, VAL a5)
}
void DO_EVAL(VAL x) {
+ if (x==NULL) return; // dummy value we'll never inspect, leave it alone.
+
VAL result;
// VAL x = (VAL)(*xin);
fun* fn;

0 comments on commit 56561a3

Please sign in to comment.