From 4d28c7632e83aed413c22001ec0821971f58f14d Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Fri, 5 Sep 2014 11:53:02 +0000 Subject: the code for def rules now uses proper graph update to preserve lazyness --- src/runtime/haskell/PGF/Binary.hs | 14 ++++++++------ src/runtime/haskell/PGF/ByteCode.hs | 5 ++++- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/runtime/haskell') diff --git a/src/runtime/haskell/PGF/Binary.hs b/src/runtime/haskell/PGF/Binary.hs index 2064e9a3b..64707f386 100644 --- a/src/runtime/haskell/PGF/Binary.hs +++ b/src/runtime/haskell/PGF/Binary.hs @@ -153,12 +153,14 @@ instance Binary Instr where put (SET_VALUE n) = putWord8 14 >> put n put (SET_ARG_VAR n) = putWord8 15 >> put n put (SET_FREE_VAR n) = putWord8 16 >> put n - put (PUSH_VALUE n) = putWord8 17 >> put n - put (PUSH_ARG_VAR n) = putWord8 18 >> put n - put (PUSH_FREE_VAR n)= putWord8 19 >> put n - put (TAIL_CALL id) = putWord8 20 >> put id - put (FAIL ) = putWord8 21 - put (RET n) = putWord8 22 >> put n + put (SET_PAD ) = putWord8 17 + put (PUSH_VALUE n) = putWord8 18 >> put n + put (PUSH_ARG_VAR n) = putWord8 19 >> put n + put (PUSH_FREE_VAR n)= putWord8 20 >> put n + put (TAIL_CALL id) = putWord8 21 >> put id + put (FAIL ) = putWord8 22 + put (UPDATE ) = putWord8 23 + put (RET n) = putWord8 24 >> put n instance Binary Type where diff --git a/src/runtime/haskell/PGF/ByteCode.hs b/src/runtime/haskell/PGF/ByteCode.hs index 2e317d4c0..158de0358 100644 --- a/src/runtime/haskell/PGF/ByteCode.hs +++ b/src/runtime/haskell/PGF/ByteCode.hs @@ -23,12 +23,13 @@ data Instr | SET_VALUE {-# UNPACK #-} !Int | SET_ARG_VAR {-# UNPACK #-} !Int | SET_FREE_VAR {-# UNPACK #-} !Int + | SET_PAD | PUSH_VALUE {-# UNPACK #-} !Int | PUSH_ARG_VAR {-# UNPACK #-} !Int | PUSH_FREE_VAR {-# UNPACK #-} !Int | TAIL_CALL CId - | UPDATE | FAIL + | UPDATE | RET {-# UNPACK #-} !Int ppCode :: Int -> [[Instr]] -> Doc @@ -52,11 +53,13 @@ ppInstr (PUT_FLT d ) = text "PUT_FLT " <+> double d ppInstr (SET_VALUE n) = text "SET_VALUE " <+> int n ppInstr (SET_ARG_VAR n) = text "SET_ARG_VAR " <+> int n ppInstr (SET_FREE_VAR n) = text "SET_FREE_VAR " <+> int n +ppInstr (SET_PAD ) = text "SET_PAD" ppInstr (PUSH_VALUE n) = text "PUSH_VALUE " <+> int n ppInstr (PUSH_ARG_VAR n) = text "PUSH_ARG_VAR " <+> int n ppInstr (PUSH_FREE_VAR n) = text "PUSH_FREE_VAR" <+> int n ppInstr (TAIL_CALL id) = text "TAIL_CALL " <+> ppCId id ppInstr (FAIL ) = text "FAIL" +ppInstr (UPDATE ) = text "UPDATE" ppInstr (RET n) = text "RET " <+> int n ppLabel l = text (let s = show l in replicate (3-length s) '0' ++ s) -- cgit v1.2.3