adalisp_genesis 1
adalisp_genesis 2
adalisp_genesis 3
adalisp_genesis 4
adalisp_genesis 5 package LispM is
adalisp_genesis 6
adalisp_genesis 7 Mem_Size : constant := 2**23;
adalisp_genesis 8
adalisp_genesis 9
adalisp_genesis 10 type MWord is mod 2 ** 64;
adalisp_genesis 11 for MWord'Size use 64;
adalisp_genesis 12
adalisp_genesis 13
adalisp_genesis 14 type Tag is (Free, Builtin, Cons, Bool, Fixnum, Char, Symbol, Closure);
adalisp_genesis 15 type MemPtr is range 0 .. Mem_Size;
adalisp_genesis 16
adalisp_genesis 17
adalisp_genesis 18
adalisp_genesis 19 type BuiltinID is (AddB, SubB, MulB, DivB, QuoteB, EvalB, IfB,
adalisp_genesis 20 ConsB, CarB, CdrB, ListB, ApplyB, DefineB, SetB,
adalisp_genesis 21 EqnB, EqB, EqvB, PairPB, BooleanPB, NumberPB, SymbolPB,
adalisp_genesis 22 NullPB, ListPB, AndB, OrB, NotB, LambdaB, LetB,
adalisp_genesis 23 ReverseB, AppendB);
adalisp_genesis 24
adalisp_genesis 25
adalisp_genesis 26
adalisp_genesis 27
adalisp_genesis 28
adalisp_genesis 29
adalisp_genesis 30
adalisp_genesis 31
adalisp_genesis 32
adalisp_genesis 33
adalisp_genesis 34
adalisp_genesis 35
adalisp_genesis 36
adalisp_genesis 37
adalisp_genesis 38
adalisp_genesis 39
adalisp_genesis 40
adalisp_genesis 41
adalisp_genesis 42
adalisp_genesis 43
adalisp_genesis 44
adalisp_genesis 45
adalisp_genesis 46
adalisp_genesis 47
adalisp_genesis 48
adalisp_genesis 49
adalisp_genesis 50
adalisp_genesis 51 type Cell is record
adalisp_genesis 52 T : Tag;
adalisp_genesis 53 Data : MWord;
adalisp_genesis 54 end record;
adalisp_genesis 55
adalisp_genesis 56
adalisp_genesis 57 type Mem is array (MemPtr range 1 .. Mem_Size) of Cell;
adalisp_genesis 58
adalisp_genesis 59
adalisp_genesis 60
adalisp_genesis 61
adalisp_genesis 62 Heap_End : MemPtr := 0;
adalisp_genesis 63
adalisp_genesis 64
adalisp_genesis 65 Sym_Table : MemPtr := 0;
adalisp_genesis 66
adalisp_genesis 67
adalisp_genesis 68 Quote_Sym : MemPtr := 0;
adalisp_genesis 69
adalisp_genesis 70
adalisp_genesis 71
adalisp_genesis 72
adalisp_genesis 73
adalisp_genesis 74 Global_Env : MemPtr := 0;
adalisp_genesis 75
adalisp_genesis 76
adalisp_genesis 77 AMem : Mem := (others => (T => Free, Data => 0));
adalisp_genesis 78
adalisp_genesis 79
adalisp_genesis 80 function Get_Builtin(C : Cell) return BuiltinID;
adalisp_genesis 81 function Get_Car(C : Cell) return MemPtr;
adalisp_genesis 82 function Get_Cdr(C : Cell) return MemPtr;
adalisp_genesis 83 function Get_Bool(C : Cell) return Boolean;
adalisp_genesis 84 function Get_Fixnum(C : Cell) return Long_Integer;
adalisp_genesis 85 function Get_Char(C : Cell) return Character;
adalisp_genesis 86 function Get_Symbol(C : Cell) return MemPtr;
adalisp_genesis 87 function Get_Closure_Code(C : Cell) return MemPtr;
adalisp_genesis 88 function Get_Closure_Env(C : Cell) return MemPtr;
adalisp_genesis 89 procedure Set_Builtin(C : in out Cell; B : in BuiltinID);
adalisp_genesis 90 procedure Set_Car(C : in out Cell; Car : in MemPtr);
adalisp_genesis 91 procedure Set_Cdr(C : in out Cell; Cdr : in MemPtr);
adalisp_genesis 92 procedure Set_Bool(C : in out Cell; Value : in Boolean);
adalisp_genesis 93 procedure Set_Fixnum(C : in out Cell; Value : in Long_Integer);
adalisp_genesis 94 procedure Set_Char(C : in out Cell; Value : in Character);
adalisp_genesis 95 procedure Set_Symbol(C : in out Cell; Name : in MemPtr);
adalisp_genesis 96 procedure Set_Closure_Code(C : in out Cell; Code : in MemPtr);
adalisp_genesis 97 procedure Set_Closure_Env(C : in out Cell; Env : in MemPtr);
adalisp_genesis 98
adalisp_genesis 99
adalisp_genesis 100
adalisp_genesis 101
adalisp_genesis 102 procedure Alloc_Cell(C : in Cell; P : out MemPtr);
adalisp_genesis 103
adalisp_genesis 104 procedure Alloc_Builtin(B : BuiltinID; P : out MemPtr);
adalisp_genesis 105 procedure Alloc_Cons(Car, Cdr : in MemPtr; P : out MemPtr);
adalisp_genesis 106 procedure Alloc_Bool(Value : in Boolean; P : out MemPtr);
adalisp_genesis 107 procedure Alloc_Fixnum(Value : in Long_Integer; P : out MemPtr);
adalisp_genesis 108 procedure Alloc_Char(Value : in Character; P : out MemPtr);
adalisp_genesis 109 procedure Alloc_Symbol(Name : in MemPtr; P : out MemPtr);
adalisp_genesis 110 procedure Alloc_Closure(Code, Env : in MemPtr; P : out MemPtr);
adalisp_genesis 111
adalisp_genesis 112
adalisp_genesis 113
adalisp_genesis 114
adalisp_genesis 115
adalisp_genesis 116 procedure Dump_Cell(P : in MemPtr);
adalisp_genesis 117
adalisp_genesis 118
adalisp_genesis 119 procedure Dump_Cons(P : in MemPtr);
adalisp_genesis 120
adalisp_genesis 121
adalisp_genesis 122 procedure Dump_Longint(N : in Long_Integer);
adalisp_genesis 123
adalisp_genesis 124
adalisp_genesis 125 procedure Dump_BuiltinID(BID : in BuiltinID);
adalisp_genesis 126
adalisp_genesis 127
adalisp_genesis 128 procedure Dump_String(P : in MemPtr);
adalisp_genesis 129
adalisp_genesis 130
adalisp_genesis 131
adalisp_genesis 132 procedure Init_Builtin_Bindings;
adalisp_genesis 133
adalisp_genesis 134
adalisp_genesis 135 function Name_EqualP(Sym1, Sym2 : MemPtr) return Boolean;
adalisp_genesis 136
adalisp_genesis 137
adalisp_genesis 138
adalisp_genesis 139 procedure Lookup_Symbol(Name : in MemPtr; Sym : out MemPtr);
adalisp_genesis 140
adalisp_genesis 141
adalisp_genesis 142
adalisp_genesis 143
adalisp_genesis 144 procedure Lookup_Or_Create_Symbol(Name : in MemPtr;
adalisp_genesis 145 Sym : out MemPtr);
adalisp_genesis 146
adalisp_genesis 147
adalisp_genesis 148
adalisp_genesis 149 procedure Lookup_Env(Sym, Env : in MemPtr; Binding : out MemPtr);
adalisp_genesis 150
adalisp_genesis 151 procedure Lookup_Env_Or_Global(Sym, Env : in MemPtr;
adalisp_genesis 152 Binding : out MemPtr);
adalisp_genesis 153
adalisp_genesis 154
adalisp_genesis 155 procedure Bind_Env(Sym, Value : in MemPtr;
adalisp_genesis 156 Env : in out MemPtr; Binding : out MemPtr);
adalisp_genesis 157 end LispM;