From e074e454d5f8b5bc5dc45dccab1d138c5cd4ab0c Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Tue, 15 Nov 2022 20:30:53 +0100 Subject: ok simplify the refs back --- app/Compiler.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/Compiler.hs') diff --git a/app/Compiler.hs b/app/Compiler.hs index e9bd7f4..1adefc3 100644 --- a/app/Compiler.hs +++ b/app/Compiler.hs @@ -32,7 +32,7 @@ variablizePrlg :: Int -> [Int] -> PrlgInt -> PrlgInt variablizePrlg void vs (CallI id ps) = CallI id $ map (variablizePrlg void vs) ps variablizePrlg void vs (LiteralI i) - | i == void = VoidI i + | i == void = VoidI | Just idx <- elemIndex i vs = VarI idx i | otherwise = LiteralI i @@ -50,8 +50,8 @@ compileGoal x = compileArg x compileArg :: PrlgInt -> Code compileArg (CallI x args) = U (Struct x) : concatMap compileArg args compileArg (LiteralI x) = [U (Atom x)] -compileArg (VarI x i) = [U (LocalRef x $ Just i)] -compileArg (VoidI i) = [U (VoidRef $ Just i)] +compileArg (VarI x i) = [U (LocalRef x i)] +compileArg (VoidI) = [U VoidRef] seqGoals :: [Code] -> Code seqGoals [] = [NoGoal] -- cgit v1.2.3