Skip to content

Commit

Permalink
rename Reg.Const to Reg.ValConst
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Mar 20, 2024
1 parent 0a04880 commit d873a26
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Backend/C/Translation/FromReg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ fromRegInstr bNoStack info = \case

fromValue :: Reg.Value -> Expression
fromValue = \case
Reg.Const c -> fromConst c
Reg.ValConst c -> fromConst c
Reg.CRef Reg.ConstrField {..} ->
case _constrFieldMemRep of
Reg.MemRepConstr ->
Expand Down
8 changes: 4 additions & 4 deletions src/Juvix/Compiler/Casm/Translation/FromReg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ fromReg tab = uncurry Result $ run $ runLabelInfoBuilderWithNextId (Reg.getNextS

goValue :: Reg.Value -> ([Instruction], Value)
goValue = \case
Reg.Const c -> ([], Imm $ goConst c)
Reg.ValConst c -> ([], Imm $ goConst c)
Reg.CRef x -> ([mkAssignAp (goConstrField x)], Ref $ MemRef Ap (-1))
Reg.VRef x -> ([], Ref $ goVarRef x)

goRValue :: Reg.Value -> RValue
goRValue = \case
Reg.Const c -> Val $ Imm $ goConst c
Reg.ValConst c -> Val $ Imm $ goConst c
Reg.CRef x -> goConstrField x
Reg.VRef x -> Val $ Ref $ goVarRef x

Expand Down Expand Up @@ -162,8 +162,8 @@ fromReg tab = uncurry Result $ run $ runLabelInfoBuilderWithNextId (Reg.getNextS

goBinop :: Address -> Reg.InstrBinop -> Sem r [Instruction]
goBinop addr x@Reg.InstrBinop {..} = case _instrBinopArg1 of
Reg.Const c1 -> case _instrBinopArg2 of
Reg.Const c2 -> case Reg.evalBinop' _instrBinopOpcode c1 c2 of
Reg.ValConst c1 -> case _instrBinopArg2 of
Reg.ValConst c2 -> case Reg.evalBinop' _instrBinopOpcode c1 c2 of
Left err -> error err
Right c ->
return [mkAssign res (Val $ Imm $ goConst c)]
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Core/Language/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import GHC.Show qualified as Show
import Juvix.Compiler.Core.Info (Info, IsInfo, Key)
import Juvix.Compiler.Core.Language.Builtins (BuiltinDataTag (..), builtinConstrArgsNum)
import Juvix.Extra.Serialize
import Juvix.Prelude hiding (Const)
import Juvix.Prelude
import Prettyprinter

type Location = Interval
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Reg/Extra/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ overValueRefs f = \case

goValue :: Value -> Value
goValue = \case
Const c -> Const c
ValConst c -> ValConst c
CRef x -> CRef $ goConstrField x
VRef x -> VRef $ f x

Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Reg/Extra/Info.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ computeStringMap strs = snd . run . execState (HashMap.size strs, strs) . mapM g

goVal :: (Member (State (Int, HashMap Text Int)) r) => Value -> Sem r ()
goVal = \case
Const (ConstString str) ->
ValConst (ConstString str) ->
modify'
( \(sid :: Int, sstrs) ->
if
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Reg/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ runFunction hout infoTable args0 info0 = do

readValue :: Args -> Vars s -> Value -> ST s Val
readValue args tmps = \case
Const c -> return $ constantToValue c
ValConst c -> return $ constantToValue c
CRef r -> readConstrRef args tmps r
VRef r -> readVarRef args tmps r

Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Reg/Language.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ where
import Juvix.Compiler.Reg.Language.Base

data Value
= Const Constant
= ValConst Constant
| CRef ConstrField
| VRef VarRef

Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Reg/Pretty/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ instance PrettyCode ConstrField where

instance PrettyCode Value where
ppCode = \case
Const x -> Tree.ppCode x
ValConst x -> Tree.ppCode x
CRef x -> ppCode x
VRef x -> ppCode x

Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Reg/Transformation/InitBranchVars.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ initBranchVars = mapT (const goFun)
Assign
InstrAssign
{ _instrAssignResult = vref,
_instrAssignValue = Const ConstVoid
_instrAssignValue = ValConst ConstVoid
}

checkInitialized :: InfoTable -> Bool
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Reg/Translation/FromAsm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fromAsmInstr funInfo tab si Asm.CmdInstr {..} =

mkValue :: Asm.Value -> Value
mkValue = \case
Asm.Constant c -> Const c
Asm.Constant c -> ValConst c
Asm.Ref mv -> case mv of
Asm.DRef dref -> VRef $ mkVar dref
Asm.ConstrRef Asm.Field {..} ->
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Reg/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ varTmp = do
value ::
(Members '[Reader ParserSig, InfoTableBuilder, State LocalParams] r) =>
ParsecS r Value
value = (Const <$> constant) <|> varOrConstrRef
value = (ValConst <$> constant) <|> varOrConstrRef

varOrConstrRef ::
(Members '[Reader ParserSig, InfoTableBuilder, State LocalParams] r) =>
Expand Down

0 comments on commit d873a26

Please sign in to comment.