From 9498270f46646c34cba3885a2e455b08daf9c324 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 30 Jun 2016 21:18:07 +0200 Subject: Descriptors, Program --- Program.icl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Program.icl (limited to 'Program.icl') diff --git a/Program.icl b/Program.icl new file mode 100644 index 0000000..4a34ec6 --- /dev/null +++ b/Program.icl @@ -0,0 +1,30 @@ +implementation module ABC.Program + +import StdEnv + +import ABC.Machine +import ABC.Misc + +pc_init :: InstrId +pc_init = 0 + +pc_next :: InstrId -> InstrId +pc_next i = i + 1 + +pc_halt :: InstrId -> InstrId +pc_halt _ = -1 + +pc_end :: InstrId -> Bool +pc_end i = i < 0 + +:: Location = I Instruction +:: ProgramStore :== [Location] + +ps_get :: InstrId ProgramStore -> Instruction +ps_get 0 [I p:_] = p +ps_get _ [] = abortn "ps_get: index too large" +ps_get i [_:ps] = ps_get (i-1) ps + +ps_init :: [Instruction] -> ProgramStore +ps_init [] = [] +ps_init [i:is] = [I i:ps_init is] -- cgit v1.2.3