adalisp_genesis 1
adalisp_genesis 2
adalisp_genesis 3 with Ada.Text_IO; use Ada.Text_IO;
adalisp_genesis 4
adalisp_genesis 5 package body Evaler is
adalisp_genesis 6
adalisp_genesis 7
adalisp_genesis 8 ALU_Acc : Long_Integer := 0;
adalisp_genesis 9
adalisp_genesis 10
adalisp_genesis 11 procedure Apply_ALU_Func(Func : in ALUFunc;
adalisp_genesis 12 Args : in MemPtr;
adalisp_genesis 13 Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 14 P, CarP : MemPtr;
adalisp_genesis 15 begin
adalisp_genesis 16
adalisp_genesis 17
adalisp_genesis 18
adalisp_genesis 19
adalisp_genesis 20
adalisp_genesis 21
adalisp_genesis 22
adalisp_genesis 23
adalisp_genesis 24
adalisp_genesis 25
adalisp_genesis 26 P := Args;
adalisp_genesis 27 case Func is
adalisp_genesis 28 when ALU_Add =>
adalisp_genesis 29
adalisp_genesis 30 ALU_Acc := 0;
adalisp_genesis 31 when ALU_Sub =>
adalisp_genesis 32
adalisp_genesis 33 pragma Assert(P /= 0, "- needs at least 1 argument");
adalisp_genesis 34 CarP := Get_Car(AMem(P));
adalisp_genesis 35 P := Get_Cdr(AMem(P));
adalisp_genesis 36
adalisp_genesis 37
adalisp_genesis 38
adalisp_genesis 39 if (P = 0) then
adalisp_genesis 40 ALU_Acc := -Get_Fixnum(AMem(CarP));
adalisp_genesis 41 else
adalisp_genesis 42 ALU_Acc := Get_Fixnum(AMem(CarP));
adalisp_genesis 43 end if;
adalisp_genesis 44 when ALU_Mul =>
adalisp_genesis 45
adalisp_genesis 46 ALU_Acc := 1;
adalisp_genesis 47 when ALU_Div =>
adalisp_genesis 48
adalisp_genesis 49 pragma Assert(P /= 0, "/ needs at least 1 argument");
adalisp_genesis 50 CarP := Get_Car(AMem(P));
adalisp_genesis 51 P := Get_Cdr(AMem(P));
adalisp_genesis 52
adalisp_genesis 53
adalisp_genesis 54
adalisp_genesis 55
adalisp_genesis 56 if (P = 0) then
adalisp_genesis 57 ALU_Acc := 1 / Get_Fixnum(AMem(CarP));
adalisp_genesis 58 else
adalisp_genesis 59 ALU_Acc := Get_Fixnum(AMem(CarP));
adalisp_genesis 60 end if;
adalisp_genesis 61 end case;
adalisp_genesis 62
adalisp_genesis 63
adalisp_genesis 64 while P /= 0 loop
adalisp_genesis 65
adalisp_genesis 66 CarP := Get_Car(AMem(P));
adalisp_genesis 67 pragma Assert(AMem(CarP).T = Fixnum,
adalisp_genesis 68 "Expected a number.");
adalisp_genesis 69 case Func is
adalisp_genesis 70 when ALU_Add =>
adalisp_genesis 71 ALU_Acc := ALU_Acc + Get_Fixnum(AMem(CarP));
adalisp_genesis 72 when ALU_Sub =>
adalisp_genesis 73 ALU_Acc := ALU_Acc - Get_Fixnum(AMem(CarP));
adalisp_genesis 74 when ALU_Mul =>
adalisp_genesis 75 ALU_Acc := ALU_Acc * Get_Fixnum(AMem(CarP));
adalisp_genesis 76 when ALU_Div =>
adalisp_genesis 77 pragma Assert(Get_Fixnum(AMem(CarP)) /= 0,
adalisp_genesis 78 "Division by zero!");
adalisp_genesis 79 ALU_Acc := ALU_Acc / Get_Fixnum(AMem(CarP));
adalisp_genesis 80 end case;
adalisp_genesis 81
adalisp_genesis 82
adalisp_genesis 83 P := Get_Cdr(AMem(P));
adalisp_genesis 84 end loop;
adalisp_genesis 85
adalisp_genesis 86 Alloc_Fixnum(ALU_Acc, OutP);
adalisp_genesis 87 end Apply_ALU_Func;
adalisp_genesis 88
adalisp_genesis 89
adalisp_genesis 90 procedure Apply_UPred(Pred : in UPred;
adalisp_genesis 91 Args : in MemPtr;
adalisp_genesis 92 Env : in MemPtr;
adalisp_genesis 93 OutP : out MemPtr) is
adalisp_genesis 94 P : MemPtr := Args;
adalisp_genesis 95 ArgP : MemPtr;
adalisp_genesis 96 begin
adalisp_genesis 97
adalisp_genesis 98
adalisp_genesis 99
adalisp_genesis 100
adalisp_genesis 101
adalisp_genesis 102 pragma Assert(P /= 0, "Function requires 1 argument.");
adalisp_genesis 103 ArgP := Get_Car(AMem(P));
adalisp_genesis 104 P := Get_Cdr(AMem(P));
adalisp_genesis 105 pragma Assert(P = 0, "Function requires 1 argument.");
adalisp_genesis 106
adalisp_genesis 107
adalisp_genesis 108 case Pred is
adalisp_genesis 109 when UPred_Pair =>
adalisp_genesis 110
adalisp_genesis 111
adalisp_genesis 112 if ArgP = 0 then
adalisp_genesis 113 Alloc_Bool(False, OutP);
adalisp_genesis 114 else
adalisp_genesis 115 Alloc_Bool(AMem(ArgP).T = Cons, OutP);
adalisp_genesis 116 end if;
adalisp_genesis 117 when UPred_Bool =>
adalisp_genesis 118
adalisp_genesis 119
adalisp_genesis 120 if ArgP = 0 then
adalisp_genesis 121 Alloc_Bool(False, OutP);
adalisp_genesis 122 else
adalisp_genesis 123 Alloc_Bool(AMem(ArgP).T = Bool, OutP);
adalisp_genesis 124 end if;
adalisp_genesis 125 when UPred_Num =>
adalisp_genesis 126
adalisp_genesis 127
adalisp_genesis 128 if ArgP = 0 then
adalisp_genesis 129 Alloc_Bool(False, OutP);
adalisp_genesis 130 else
adalisp_genesis 131 Alloc_Bool(AMem(ArgP).T = Fixnum, OutP);
adalisp_genesis 132 end if;
adalisp_genesis 133 when UPred_Sym =>
adalisp_genesis 134
adalisp_genesis 135
adalisp_genesis 136 if ArgP = 0 then
adalisp_genesis 137 Alloc_Bool(False, OutP);
adalisp_genesis 138 else
adalisp_genesis 139 Alloc_Bool(AMem(ArgP).T = Symbol, OutP);
adalisp_genesis 140 end if;
adalisp_genesis 141 when UPred_Nil =>
adalisp_genesis 142
adalisp_genesis 143
adalisp_genesis 144 Alloc_Bool(ArgP = 0, OutP);
adalisp_genesis 145 when UPred_List =>
adalisp_genesis 146
adalisp_genesis 147
adalisp_genesis 148
adalisp_genesis 149
adalisp_genesis 150 loop
adalisp_genesis 151 exit when ArgP = 0;
adalisp_genesis 152 exit when AMem(ArgP).T /= Cons;
adalisp_genesis 153 ArgP := Get_Cdr(AMem(ArgP));
adalisp_genesis 154 end loop;
adalisp_genesis 155
adalisp_genesis 156
adalisp_genesis 157 Alloc_Bool(ArgP = 0, OutP);
adalisp_genesis 158 end case;
adalisp_genesis 159 end Apply_UPred;
adalisp_genesis 160
adalisp_genesis 161
adalisp_genesis 162 procedure Apply_AndOr(Cond : in AndOr;
adalisp_genesis 163 Args : in MemPtr;
adalisp_genesis 164 Env : in MemPtr;
adalisp_genesis 165 OutP : out MemPtr) is
adalisp_genesis 166 P, ArgP : MemPtr;
adalisp_genesis 167 ReachedEnd : Boolean := False;
adalisp_genesis 168 begin
adalisp_genesis 169
adalisp_genesis 170
adalisp_genesis 171
adalisp_genesis 172
adalisp_genesis 173
adalisp_genesis 174
adalisp_genesis 175
adalisp_genesis 176
adalisp_genesis 177 P := Args;
adalisp_genesis 178 if P = 0 then
adalisp_genesis 179
adalisp_genesis 180
adalisp_genesis 181
adalisp_genesis 182 ReachedEnd := True;
adalisp_genesis 183 Alloc_Bool(Cond = AndOr_And, ArgP);
adalisp_genesis 184 end if;
adalisp_genesis 185 loop
adalisp_genesis 186
adalisp_genesis 187 if P = 0 then
adalisp_genesis 188 ReachedEnd := True;
adalisp_genesis 189 exit;
adalisp_genesis 190 end if;
adalisp_genesis 191
adalisp_genesis 192
adalisp_genesis 193
adalisp_genesis 194 ArgP := Get_Car(AMem(P));
adalisp_genesis 195 Eval(ArgP, Env, ArgP);
adalisp_genesis 196
adalisp_genesis 197 exit when Cond = AndOr_And and Boolean_Value(ArgP) = False;
adalisp_genesis 198 exit when Cond = AndOr_Or and Boolean_Value(ArgP) = True;
adalisp_genesis 199
adalisp_genesis 200
adalisp_genesis 201 P := Get_Cdr(AMem(P));
adalisp_genesis 202 end loop;
adalisp_genesis 203
adalisp_genesis 204
adalisp_genesis 205
adalisp_genesis 206
adalisp_genesis 207 case Cond is
adalisp_genesis 208 when AndOr_And =>
adalisp_genesis 209 if ReachedEnd then
adalisp_genesis 210 OutP := ArgP;
adalisp_genesis 211 else
adalisp_genesis 212 Alloc_Bool(False, OutP);
adalisp_genesis 213 end if;
adalisp_genesis 214 when AndOr_Or =>
adalisp_genesis 215 if ReachedEnd then
adalisp_genesis 216 Alloc_Bool(False, OutP);
adalisp_genesis 217 else
adalisp_genesis 218 OutP := ArgP;
adalisp_genesis 219 end if;
adalisp_genesis 220 end case;
adalisp_genesis 221 end Apply_AndOr;
adalisp_genesis 222
adalisp_genesis 223
adalisp_genesis 224 procedure Apply_QuoteB(Args : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 225 begin
adalisp_genesis 226
adalisp_genesis 227
adalisp_genesis 228
adalisp_genesis 229
adalisp_genesis 230
adalisp_genesis 231 OutP := (if Args = 0 then 0 else Get_Car(AMem(Args)));
adalisp_genesis 232 end Apply_QuoteB;
adalisp_genesis 233
adalisp_genesis 234
adalisp_genesis 235 procedure Apply_EvalB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 236 Arg : MemPtr;
adalisp_genesis 237 begin
adalisp_genesis 238
adalisp_genesis 239
adalisp_genesis 240
adalisp_genesis 241
adalisp_genesis 242 pragma Assert(Args /= 0, "Eval needs at least 1 argument.");
adalisp_genesis 243 Arg := Get_Car(AMem(Args));
adalisp_genesis 244
adalisp_genesis 245 Eval(Arg, Env, OutP);
adalisp_genesis 246 end Apply_EvalB;
adalisp_genesis 247
adalisp_genesis 248
adalisp_genesis 249 procedure Apply_IfB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 250 P : MemPtr := Args;
adalisp_genesis 251 PredP : MemPtr;
adalisp_genesis 252 PredVal : Boolean;
adalisp_genesis 253 begin
adalisp_genesis 254
adalisp_genesis 255
adalisp_genesis 256
adalisp_genesis 257
adalisp_genesis 258
adalisp_genesis 259
adalisp_genesis 260
adalisp_genesis 261
adalisp_genesis 262
adalisp_genesis 263
adalisp_genesis 264
adalisp_genesis 265
adalisp_genesis 266
adalisp_genesis 267 if P = 0 then
adalisp_genesis 268 OutP := 0;
adalisp_genesis 269 return;
adalisp_genesis 270 end if;
adalisp_genesis 271
adalisp_genesis 272
adalisp_genesis 273
adalisp_genesis 274 PredP := Get_Car(AMem(P));
adalisp_genesis 275 Eval(PredP, Env, PredP);
adalisp_genesis 276 PredVal := Boolean_Value(PredP);
adalisp_genesis 277
adalisp_genesis 278
adalisp_genesis 279 P := Get_Cdr(AMem(P));
adalisp_genesis 280
adalisp_genesis 281
adalisp_genesis 282
adalisp_genesis 283
adalisp_genesis 284 if not PredVal and P /= 0 then
adalisp_genesis 285 P := Get_Cdr(AMem(P));
adalisp_genesis 286 elsif P = 0 then
adalisp_genesis 287 OutP := 0;
adalisp_genesis 288 return;
adalisp_genesis 289 end if;
adalisp_genesis 290
adalisp_genesis 291 P := Get_Car(AMem(P));
adalisp_genesis 292 Eval(P, Env, OutP);
adalisp_genesis 293 end Apply_IfB;
adalisp_genesis 294
adalisp_genesis 295
adalisp_genesis 296 procedure Apply_ConsB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 297 P : MemPtr := Args;
adalisp_genesis 298 CarP, CdrP : MemPtr;
adalisp_genesis 299 begin
adalisp_genesis 300
adalisp_genesis 301
adalisp_genesis 302 pragma Assert(P /= 0, "Cons needs exactly 2 arguments.");
adalisp_genesis 303
adalisp_genesis 304 CarP := Get_Car(AMem(P));
adalisp_genesis 305
adalisp_genesis 306 P := Get_Cdr(AMem(P));
adalisp_genesis 307 pragma Assert(P /= 0, "Cons needs exactly 2 arguments.");
adalisp_genesis 308 CdrP := Get_Car(AMem(P));
adalisp_genesis 309
adalisp_genesis 310
adalisp_genesis 311 P := Get_Cdr(AMem(P));
adalisp_genesis 312 pragma Assert(P = 0, "Cons needs exactly 2 arguments.");
adalisp_genesis 313
adalisp_genesis 314
adalisp_genesis 315 Alloc_Cons(CarP, CdrP, OutP);
adalisp_genesis 316 end Apply_ConsB;
adalisp_genesis 317
adalisp_genesis 318
adalisp_genesis 319 procedure Apply_CarB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 320 P : MemPtr := Args;
adalisp_genesis 321 ConsP : MemPtr;
adalisp_genesis 322 begin
adalisp_genesis 323
adalisp_genesis 324
adalisp_genesis 325 pragma Assert(P /= 0, "car needs exactly 1 argument.");
adalisp_genesis 326
adalisp_genesis 327 ConsP := Get_Car(AMem(P));
adalisp_genesis 328 pragma Assert (AMem(ConsP).T = Cons, "Expected pair.");
adalisp_genesis 329 OutP := Get_Car(AMem(ConsP));
adalisp_genesis 330
adalisp_genesis 331
adalisp_genesis 332 P := Get_Cdr(AMem(P));
adalisp_genesis 333 pragma Assert (P = 0, "car needs exactly 1 argument.");
adalisp_genesis 334 end Apply_CarB;
adalisp_genesis 335
adalisp_genesis 336
adalisp_genesis 337 procedure Apply_CdrB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 338 P : MemPtr := Args;
adalisp_genesis 339 ConsP : MemPtr;
adalisp_genesis 340 begin
adalisp_genesis 341
adalisp_genesis 342
adalisp_genesis 343 pragma Assert(P /= 0, "cdr needs exactly 1 argument.");
adalisp_genesis 344
adalisp_genesis 345 ConsP := Get_Car(AMem(P));
adalisp_genesis 346 pragma Assert (AMem(ConsP).T = Cons, "Expected pair.");
adalisp_genesis 347 OutP := Get_Cdr(AMem(ConsP));
adalisp_genesis 348
adalisp_genesis 349
adalisp_genesis 350 P := Get_Cdr(AMem(P));
adalisp_genesis 351 pragma Assert (P = 0, "cdr needs exactly 1 argument.");
adalisp_genesis 352 end Apply_CdrB;
adalisp_genesis 353
adalisp_genesis 354
adalisp_genesis 355 procedure Apply_ListB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 356 begin
adalisp_genesis 357
adalisp_genesis 358
adalisp_genesis 359
adalisp_genesis 360
adalisp_genesis 361
adalisp_genesis 362 OutP := Args;
adalisp_genesis 363 end Apply_ListB;
adalisp_genesis 364
adalisp_genesis 365
adalisp_genesis 366 procedure Apply_ApplyB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 367 P : MemPtr := Args;
adalisp_genesis 368 OpP, ArgsP, LastArgP : MemPtr;
adalisp_genesis 369 begin
adalisp_genesis 370
adalisp_genesis 371
adalisp_genesis 372
adalisp_genesis 373
adalisp_genesis 374
adalisp_genesis 375
adalisp_genesis 376 pragma Assert(P /= 0, "apply needs at least 1 argument.");
adalisp_genesis 377
adalisp_genesis 378
adalisp_genesis 379 OpP := Get_Car(AMem(P));
adalisp_genesis 380
adalisp_genesis 381
adalisp_genesis 382
adalisp_genesis 383
adalisp_genesis 384 P := Get_Cdr(AMem(P));
adalisp_genesis 385
adalisp_genesis 386 if P = 0 then goto DoApply; end if;
adalisp_genesis 387
adalisp_genesis 388
adalisp_genesis 389
adalisp_genesis 390 ArgsP := 0;
adalisp_genesis 391 while P /= 0 loop
adalisp_genesis 392 exit when AMem(P).T /= Cons;
adalisp_genesis 393 Alloc_Cons(Get_Car(AMem(P)), ArgsP, ArgsP);
adalisp_genesis 394 P := Get_Cdr(AMem(P));
adalisp_genesis 395 end loop;
adalisp_genesis 396
adalisp_genesis 397 LastArgP := Get_Car(AMem(ArgsP));
adalisp_genesis 398 ArgsP := Get_Cdr(AMem(ArgsP));
adalisp_genesis 399
adalisp_genesis 400 Rev_In_Place(ArgsP, LastArgP, P);
adalisp_genesis 401
adalisp_genesis 402 <<DoApply>>
adalisp_genesis 403
adalisp_genesis 404 Apply_Func(OpP, P, Env, True, OutP);
adalisp_genesis 405 end Apply_ApplyB;
adalisp_genesis 406
adalisp_genesis 407
adalisp_genesis 408 procedure Apply_DefineB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 409 P : MemPtr := Args;
adalisp_genesis 410 SymP, ValP : MemPtr;
adalisp_genesis 411 begin
adalisp_genesis 412
adalisp_genesis 413
adalisp_genesis 414
adalisp_genesis 415
adalisp_genesis 416
adalisp_genesis 417
adalisp_genesis 418
adalisp_genesis 419
adalisp_genesis 420 SymP := Get_Car(AMem(P));
adalisp_genesis 421 pragma Assert (SymP /= 0, "Define: expected symbol for arg 1!");
adalisp_genesis 422 pragma Assert (AMem(SymP).T = Symbol,
adalisp_genesis 423 "Define: expected symbol for arg 1!");
adalisp_genesis 424
adalisp_genesis 425
adalisp_genesis 426 P := Get_Cdr(AMem(P));
adalisp_genesis 427 ValP := (if P = 0 then 0 else Get_Car(AMem(P)));
adalisp_genesis 428
adalisp_genesis 429
adalisp_genesis 430 Eval(ValP, Env, ValP);
adalisp_genesis 431
adalisp_genesis 432 Bind_Env(SymP, ValP, Global_Env, P);
adalisp_genesis 433
adalisp_genesis 434 OutP := Get_Car(AMem(P));
adalisp_genesis 435 end Apply_DefineB;
adalisp_genesis 436
adalisp_genesis 437
adalisp_genesis 438 procedure Apply_SetB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 439 P : MemPtr := Args;
adalisp_genesis 440 SymP, ValP : MemPtr;
adalisp_genesis 441 BindingP : MemPtr;
adalisp_genesis 442 begin
adalisp_genesis 443
adalisp_genesis 444
adalisp_genesis 445
adalisp_genesis 446
adalisp_genesis 447 pragma Assert(P /= 0, "set! requires at least 1 argument.");
adalisp_genesis 448
adalisp_genesis 449 SymP := Get_Car(AMem(P));
adalisp_genesis 450
adalisp_genesis 451 Lookup_Env_Or_Global(SymP, Env, BindingP);
adalisp_genesis 452
adalisp_genesis 453 pragma Assert(BindingP /= 0, "set! got an unbound variable.");
adalisp_genesis 454
adalisp_genesis 455
adalisp_genesis 456 P := Get_Cdr(AMem(P));
adalisp_genesis 457 ValP := (if P = 0 then 0 else Get_Car(AMem(P)));
adalisp_genesis 458
adalisp_genesis 459 Eval(ValP, Env, ValP);
adalisp_genesis 460
adalisp_genesis 461 Set_Cdr(AMem(BindingP), ValP);
adalisp_genesis 462
adalisp_genesis 463 OutP := ValP;
adalisp_genesis 464 end Apply_SetB;
adalisp_genesis 465
adalisp_genesis 466
adalisp_genesis 467 procedure Apply_EqnB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 468 P : MemPtr := Args;
adalisp_genesis 469 Fst, Other : MemPtr;
adalisp_genesis 470 Result : MemPtr;
adalisp_genesis 471 begin
adalisp_genesis 472
adalisp_genesis 473
adalisp_genesis 474
adalisp_genesis 475 pragma Assert(P /= 0, "= requires at least 2 arguments");
adalisp_genesis 476
adalisp_genesis 477 Fst := Get_Car(AMem(P));
adalisp_genesis 478 pragma Assert(AMem(Fst).T = Fixnum, "Expected numeric arguments.");
adalisp_genesis 479
adalisp_genesis 480 P := Get_Cdr(AMem(P));
adalisp_genesis 481 pragma Assert(P /= 0, "= requires at least 2 arguments");
adalisp_genesis 482
adalisp_genesis 483
adalisp_genesis 484
adalisp_genesis 485 Alloc_Bool(True, Result);
adalisp_genesis 486
adalisp_genesis 487 while P /= 0 loop
adalisp_genesis 488
adalisp_genesis 489 Other := Get_Car(AMem(P));
adalisp_genesis 490 pragma Assert(AMem(Other).T = Fixnum, "Expected numeric arguments.");
adalisp_genesis 491
adalisp_genesis 492 if AMem(Fst).Data /= AMem(Other).Data then
adalisp_genesis 493 Set_Bool(AMem(Result), False);
adalisp_genesis 494 end if;
adalisp_genesis 495
adalisp_genesis 496 P := Get_Cdr(AMem(P));
adalisp_genesis 497 end loop;
adalisp_genesis 498
adalisp_genesis 499 OutP := Result;
adalisp_genesis 500 end Apply_EqnB;
adalisp_genesis 501
adalisp_genesis 502
adalisp_genesis 503 procedure Apply_EqB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 504 P : MemPtr := Args;
adalisp_genesis 505 P1, P2 : MemPtr;
adalisp_genesis 506 begin
adalisp_genesis 507
adalisp_genesis 508
adalisp_genesis 509
adalisp_genesis 510 pragma Assert(P /= 0, "eq? requires 2 arguments.");
adalisp_genesis 511 P1 := Get_Car(AMem(P));
adalisp_genesis 512 P := Get_Cdr(AMem(P));
adalisp_genesis 513
adalisp_genesis 514
adalisp_genesis 515 pragma Assert(P /= 0, "eq? requires 2 arguments.");
adalisp_genesis 516 P2 := Get_Car(AMem(P));
adalisp_genesis 517 P := Get_Cdr(AMem(P));
adalisp_genesis 518 pragma Assert(P = 0, "eq? requires 2 arguments.");
adalisp_genesis 519
adalisp_genesis 520
adalisp_genesis 521
adalisp_genesis 522
adalisp_genesis 523
adalisp_genesis 524
adalisp_genesis 525
adalisp_genesis 526
adalisp_genesis 527
adalisp_genesis 528
adalisp_genesis 529 if P1 /= 0 and P2 /= 0 then
adalisp_genesis 530 if AMem(P1).T = Bool and AMem(P2).T = Bool then
adalisp_genesis 531 Alloc_Bool(AMem(P1).Data = AMem(P2).Data, OutP);
adalisp_genesis 532 else
adalisp_genesis 533 Alloc_Bool(P1 = P2, OutP);
adalisp_genesis 534 end if;
adalisp_genesis 535 else
adalisp_genesis 536 Alloc_Bool(P1 = P2, OutP);
adalisp_genesis 537 end if;
adalisp_genesis 538 end Apply_EqB;
adalisp_genesis 539
adalisp_genesis 540
adalisp_genesis 541 procedure Apply_EqvB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 542 P : MemPtr := Args;
adalisp_genesis 543 Val1, Val2 : MemPtr;
adalisp_genesis 544 Result : Boolean;
adalisp_genesis 545 begin
adalisp_genesis 546
adalisp_genesis 547
adalisp_genesis 548
adalisp_genesis 549
adalisp_genesis 550
adalisp_genesis 551
adalisp_genesis 552 pragma Assert(P /= 0, "eqv? requires 2 arguments.");
adalisp_genesis 553 Val1 := Get_Car(AMem(P));
adalisp_genesis 554 P := Get_Cdr(AMem(P));
adalisp_genesis 555
adalisp_genesis 556
adalisp_genesis 557 pragma Assert(P /= 0, "eqv? requires 2 arguments.");
adalisp_genesis 558 Val2 := Get_Car(AMem(P));
adalisp_genesis 559 P := Get_Cdr(AMem(P));
adalisp_genesis 560 pragma Assert(P = 0, "eqv? requires 2 arguments.");
adalisp_genesis 561
adalisp_genesis 562
adalisp_genesis 563
adalisp_genesis 564
adalisp_genesis 565
adalisp_genesis 566 if Val1 = 0 then
adalisp_genesis 567 Result := Val2 = 0;
adalisp_genesis 568 else
adalisp_genesis 569 Result := AMem(Val1).Data = AMem(Val2).Data;
adalisp_genesis 570 end if;
adalisp_genesis 571
adalisp_genesis 572 Alloc_Bool(Result, OutP);
adalisp_genesis 573 end Apply_EqvB;
adalisp_genesis 574
adalisp_genesis 575
adalisp_genesis 576 procedure Apply_NotB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 577 P : MemPtr := Args;
adalisp_genesis 578 Val : MemPtr;
adalisp_genesis 579 begin
adalisp_genesis 580
adalisp_genesis 581
adalisp_genesis 582
adalisp_genesis 583
adalisp_genesis 584
adalisp_genesis 585
adalisp_genesis 586 pragma Assert (P /= 0, "not requires 1 argument.");
adalisp_genesis 587 Val := Get_Car(AMem(P));
adalisp_genesis 588 P := Get_Cdr(AMem(P));
adalisp_genesis 589 pragma Assert (P = 0, "not requires 1 argument.");
adalisp_genesis 590
adalisp_genesis 591
adalisp_genesis 592 Alloc_Bool(not Boolean_Value(Val), OutP);
adalisp_genesis 593 end Apply_NotB;
adalisp_genesis 594
adalisp_genesis 595
adalisp_genesis 596 procedure Apply_LambdaB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 597 begin
adalisp_genesis 598
adalisp_genesis 599
adalisp_genesis 600
adalisp_genesis 601
adalisp_genesis 602
adalisp_genesis 603
adalisp_genesis 604
adalisp_genesis 605 Alloc_Closure(Args, Env, OutP);
adalisp_genesis 606 end Apply_LambdaB;
adalisp_genesis 607
adalisp_genesis 608
adalisp_genesis 609 procedure Apply_LetB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 610 BndsP, CodeP : MemPtr;
adalisp_genesis 611 ArgsP, ValuesP, ClosureP : MemPtr;
adalisp_genesis 612 begin
adalisp_genesis 613
adalisp_genesis 614
adalisp_genesis 615
adalisp_genesis 616
adalisp_genesis 617
adalisp_genesis 618
adalisp_genesis 619
adalisp_genesis 620
adalisp_genesis 621
adalisp_genesis 622
adalisp_genesis 623
adalisp_genesis 624
adalisp_genesis 625
adalisp_genesis 626
adalisp_genesis 627
adalisp_genesis 628
adalisp_genesis 629
adalisp_genesis 630
adalisp_genesis 631
adalisp_genesis 632
adalisp_genesis 633
adalisp_genesis 634
adalisp_genesis 635
adalisp_genesis 636
adalisp_genesis 637
adalisp_genesis 638
adalisp_genesis 639
adalisp_genesis 640
adalisp_genesis 641 if Args = 0 then
adalisp_genesis 642
adalisp_genesis 643 OutP := 0;
adalisp_genesis 644 return;
adalisp_genesis 645 end if;
adalisp_genesis 646
adalisp_genesis 647
adalisp_genesis 648 BndsP := Get_Car(AMem(Args));
adalisp_genesis 649 CodeP := Get_Cdr(AMem(Args));
adalisp_genesis 650 ArgsP := 0; ValuesP := 0;
adalisp_genesis 651
adalisp_genesis 652
adalisp_genesis 653 while BndsP /= 0 loop
adalisp_genesis 654 declare
adalisp_genesis 655 BndP : MemPtr := Get_Car(AMem(BndsP));
adalisp_genesis 656 SymP, ValP : MemPtr;
adalisp_genesis 657 begin
adalisp_genesis 658 pragma Assert(BndP /= 0, "Bad syntax of let spec.");
adalisp_genesis 659 pragma Assert(AMem(BndP).T = Cons, "Bad syntax of let spec.");
adalisp_genesis 660
adalisp_genesis 661
adalisp_genesis 662 SymP := Get_Car(AMem(BndP));
adalisp_genesis 663 ValP := Get_Cdr(AMem(BndP));
adalisp_genesis 664
adalisp_genesis 665 pragma Assert (ValP /= 0, "Bad syntax of binding in let.");
adalisp_genesis 666
adalisp_genesis 667 ValP := Get_Car(AMem(ValP));
adalisp_genesis 668 Eval(ValP, Env, ValP);
adalisp_genesis 669
adalisp_genesis 670 Alloc_Cons(SymP, ArgsP, ArgsP);
adalisp_genesis 671 Alloc_Cons(ValP, ValuesP, ValuesP);
adalisp_genesis 672
adalisp_genesis 673 BndsP := Get_Cdr(AMem(BndsP));
adalisp_genesis 674 end;
adalisp_genesis 675 end loop;
adalisp_genesis 676
adalisp_genesis 677
adalisp_genesis 678 Alloc_Cons(ArgsP, CodeP, CodeP);
adalisp_genesis 679
adalisp_genesis 680 Apply_LambdaB(CodeP, Env, ClosureP);
adalisp_genesis 681
adalisp_genesis 682 Apply_Closure(ClosureP, ValuesP, Env, OutP);
adalisp_genesis 683 end Apply_LetB;
adalisp_genesis 684
adalisp_genesis 685
adalisp_genesis 686 procedure Apply_ReverseB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 687 P : MemPtr := Args;
adalisp_genesis 688 List : MemPtr;
adalisp_genesis 689 begin
adalisp_genesis 690
adalisp_genesis 691
adalisp_genesis 692
adalisp_genesis 693 pragma Assert (P /= 0, "reverse requires 1 argument.");
adalisp_genesis 694 List := Get_Car(AMem(P));
adalisp_genesis 695 P := Get_Cdr(AMem(P));
adalisp_genesis 696 pragma Assert (P = 0, "reverse requires 1 argument.");
adalisp_genesis 697
adalisp_genesis 698
adalisp_genesis 699 Rev_Append(0, List, OutP);
adalisp_genesis 700 end Apply_ReverseB;
adalisp_genesis 701
adalisp_genesis 702
adalisp_genesis 703 procedure Apply_AppendB(Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 704 Lists : MemPtr := Args;
adalisp_genesis 705 Acc : MemPtr := 0;
adalisp_genesis 706 begin
adalisp_genesis 707
adalisp_genesis 708
adalisp_genesis 709
adalisp_genesis 710
adalisp_genesis 711
adalisp_genesis 712
adalisp_genesis 713
adalisp_genesis 714
adalisp_genesis 715 if Lists = 0 then
adalisp_genesis 716 OutP := 0;
adalisp_genesis 717 return;
adalisp_genesis 718 end if;
adalisp_genesis 719
adalisp_genesis 720
adalisp_genesis 721
adalisp_genesis 722 while Get_Cdr(AMem(Lists)) /= 0 loop
adalisp_genesis 723
adalisp_genesis 724 Rev_Append(Acc, Get_Car(AMem(Lists)), Acc);
adalisp_genesis 725
adalisp_genesis 726 Lists := Get_Cdr(AMem(Lists));
adalisp_genesis 727 end loop;
adalisp_genesis 728
adalisp_genesis 729
adalisp_genesis 730
adalisp_genesis 731 Rev_In_Place(Acc, Get_Car(AMem(Lists)), Acc);
adalisp_genesis 732 OutP := Acc;
adalisp_genesis 733 end Apply_AppendB;
adalisp_genesis 734
adalisp_genesis 735
adalisp_genesis 736 procedure Apply_Closure(Op, Args, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 737 EArgs : MemPtr := Args;
adalisp_genesis 738 CArgs, CCode, CEnv : MemPtr;
adalisp_genesis 739 begin
adalisp_genesis 740
adalisp_genesis 741
adalisp_genesis 742
adalisp_genesis 743
adalisp_genesis 744
adalisp_genesis 745
adalisp_genesis 746
adalisp_genesis 747
adalisp_genesis 748
adalisp_genesis 749
adalisp_genesis 750
adalisp_genesis 751
adalisp_genesis 752
adalisp_genesis 753
adalisp_genesis 754
adalisp_genesis 755 CEnv := Get_Closure_Env(AMem(Op));
adalisp_genesis 756 CCode := Get_Closure_Code(AMem(Op));
adalisp_genesis 757
adalisp_genesis 758 if CCode = 0 then
adalisp_genesis 759 CArgs := 0;
adalisp_genesis 760 else
adalisp_genesis 761 CArgs := Get_Car(AMem(CCode));
adalisp_genesis 762 CCode := Get_Cdr(AMem(CCode));
adalisp_genesis 763 end if;
adalisp_genesis 764
adalisp_genesis 765
adalisp_genesis 766 if CArgs = 0 then goto DoEval; end if;
adalisp_genesis 767
adalisp_genesis 768
adalisp_genesis 769
adalisp_genesis 770
adalisp_genesis 771 if AMem(CArgs).T = Symbol then
adalisp_genesis 772
adalisp_genesis 773 Alloc_Cons(CArgs, EArgs, CArgs);
adalisp_genesis 774 Alloc_Cons(CArgs, CEnv, CEnv);
adalisp_genesis 775 elsif AMem(CArgs).T = Cons then
adalisp_genesis 776
adalisp_genesis 777
adalisp_genesis 778 while CArgs /= 0 loop
adalisp_genesis 779 declare
adalisp_genesis 780 ArgP, ValP, BindingP : MemPtr;
adalisp_genesis 781 begin
adalisp_genesis 782
adalisp_genesis 783 pragma Assert(EArgs /= 0,
adalisp_genesis 784 "Not enough arguments.");
adalisp_genesis 785
adalisp_genesis 786 ArgP := Get_Car(AMem(CArgs));
adalisp_genesis 787 ValP := Get_Car(AMem(EArgs));
adalisp_genesis 788
adalisp_genesis 789 if ArgP /= 0 then
adalisp_genesis 790 if AMem(ArgP).T = Symbol then
adalisp_genesis 791 Alloc_Cons(ArgP, ValP, BindingP);
adalisp_genesis 792 Alloc_Cons(BindingP, CEnv, CEnv);
adalisp_genesis 793 end if;
adalisp_genesis 794 end if;
adalisp_genesis 795
adalisp_genesis 796 CArgs := Get_Cdr(AMem(CArgs));
adalisp_genesis 797 EArgs := Get_Cdr(AMem(EArgs));
adalisp_genesis 798 end;
adalisp_genesis 799 end loop;
adalisp_genesis 800 else
adalisp_genesis 801 pragma Assert(False, "Expected symbol or cons.");
adalisp_genesis 802 end if;
adalisp_genesis 803
adalisp_genesis 804 <<DoEval>>
adalisp_genesis 805
adalisp_genesis 806 while CCode /= 0 loop
adalisp_genesis 807 declare
adalisp_genesis 808 E : MemPtr;
adalisp_genesis 809 begin
adalisp_genesis 810
adalisp_genesis 811 E := Get_Car(AMem(CCode));
adalisp_genesis 812
adalisp_genesis 813 Eval(E, CEnv, OutP);
adalisp_genesis 814
adalisp_genesis 815 CCode := Get_Cdr(AMem(CCode));
adalisp_genesis 816 end;
adalisp_genesis 817 end loop;
adalisp_genesis 818 end Apply_Closure;
adalisp_genesis 819
adalisp_genesis 820
adalisp_genesis 821 procedure Apply_Func(Op, Args, Env : in MemPtr;
adalisp_genesis 822 Meta : in Boolean;
adalisp_genesis 823 OutP : out MemPtr) is
adalisp_genesis 824
adalisp_genesis 825
adalisp_genesis 826
adalisp_genesis 827
adalisp_genesis 828 Applicative_OrderP : constant array(BuiltinID) of Boolean :=
adalisp_genesis 829 (QuoteB | IfB | DefineB | SetB | AndB | OrB | LambdaB |
adalisp_genesis 830 LetB => False,
adalisp_genesis 831 others => True);
adalisp_genesis 832
adalisp_genesis 833 BID : BuiltinID;
adalisp_genesis 834 EvaledArgs : MemPtr;
adalisp_genesis 835 begin
adalisp_genesis 836 pragma Assert(Op /= 0, "NIL op!");
adalisp_genesis 837
adalisp_genesis 838
adalisp_genesis 839 if AMem(Op).T = Builtin then
adalisp_genesis 840 BID := Get_Builtin(AMem(Op));
adalisp_genesis 841
adalisp_genesis 842
adalisp_genesis 843
adalisp_genesis 844
adalisp_genesis 845
adalisp_genesis 846 if Applicative_OrderP(BID) and (not Meta) then
adalisp_genesis 847 Eval_List(Args, Env, EvaledArgs);
adalisp_genesis 848 else
adalisp_genesis 849 EvaledArgs := Args;
adalisp_genesis 850 end if;
adalisp_genesis 851
adalisp_genesis 852 case BID is
adalisp_genesis 853 when AddB => Apply_ALU_Func(ALU_Add, EvaledArgs, Env, OutP);
adalisp_genesis 854 when SubB => Apply_ALU_Func(ALU_Sub, EvaledArgs, Env, OutP);
adalisp_genesis 855 when MulB => Apply_ALU_Func(ALU_Mul, EvaledArgs, Env, OutP);
adalisp_genesis 856 when DivB => Apply_ALU_Func(ALU_Div, EvaledArgs, Env, OutP);
adalisp_genesis 857 when QuoteB => Apply_QuoteB(EvaledArgs, OutP);
adalisp_genesis 858 when EvalB => Apply_EvalB(EvaledArgs, Env, OutP);
adalisp_genesis 859 when IfB => Apply_IfB(EvaledArgs, Env, OutP);
adalisp_genesis 860 when ConsB => Apply_ConsB(EvaledArgs, Env, OutP);
adalisp_genesis 861 when CarB => Apply_CarB(EvaledArgs, Env, OutP);
adalisp_genesis 862 when CdrB => Apply_CdrB(EvaledArgs, Env, OutP);
adalisp_genesis 863 when ListB => Apply_ListB(EvaledArgs, Env, OutP);
adalisp_genesis 864 when ApplyB => Apply_ApplyB(EvaledArgs, Env, OutP);
adalisp_genesis 865 when DefineB => Apply_DefineB(EvaledArgs, Env, OutP);
adalisp_genesis 866 when SetB => Apply_SetB(EvaledArgs, Env, OutP);
adalisp_genesis 867 when EqnB => Apply_EqnB(EvaledArgs, Env, OutP);
adalisp_genesis 868 when EqB => Apply_EqB(EvaledArgs, Env, OutP);
adalisp_genesis 869 when EqvB => Apply_EqvB(EvaledArgs, Env, OutP);
adalisp_genesis 870 when PairPB => Apply_UPred(UPred_Pair, EvaledArgs, Env, OutP);
adalisp_genesis 871 when BooleanPB => Apply_UPred(UPred_Bool, EvaledArgs, Env, OutP);
adalisp_genesis 872 when NumberPB => Apply_UPred(UPred_Num, EvaledArgs, Env, OutP);
adalisp_genesis 873 when SymbolPB => Apply_UPred(UPred_Sym, EvaledArgs, Env, OutP);
adalisp_genesis 874 when NullPB => Apply_UPred(UPred_Nil, EvaledArgs, Env, OutP);
adalisp_genesis 875 when ListPB => Apply_UPred(UPred_List, EvaledArgs, Env, OutP);
adalisp_genesis 876 when AndB => Apply_AndOr(AndOr_And, EvaledArgs, Env, OutP);
adalisp_genesis 877 when OrB => Apply_AndOr(AndOr_Or, EvaledArgs, Env, OutP);
adalisp_genesis 878 when NotB => Apply_NotB(EvaledArgs, Env, OutP);
adalisp_genesis 879 when LambdaB => Apply_LambdaB(Args, Env, OutP);
adalisp_genesis 880 when LetB => Apply_LetB(Args, Env, OutP);
adalisp_genesis 881 when ReverseB => Apply_ReverseB(EvaledArgs, Env, OutP);
adalisp_genesis 882 when AppendB => Apply_AppendB(EvaledArgs, Env, OutP);
adalisp_genesis 883 end case;
adalisp_genesis 884 elsif AMem(Op).T = Closure then
adalisp_genesis 885
adalisp_genesis 886
adalisp_genesis 887 if not Meta then
adalisp_genesis 888 Eval_List(Args, Env, EvaledArgs);
adalisp_genesis 889 else
adalisp_genesis 890 EvaledArgs := Args;
adalisp_genesis 891 end if;
adalisp_genesis 892
adalisp_genesis 893 Apply_Closure(Op, EvaledArgs, Env, OutP);
adalisp_genesis 894 else
adalisp_genesis 895 OutP := 0;
adalisp_genesis 896 pragma Assert(False, "Trying to apply a non-function.");
adalisp_genesis 897 end if;
adalisp_genesis 898 end Apply_Func;
adalisp_genesis 899
adalisp_genesis 900
adalisp_genesis 901 procedure Eval_List(List, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 902 LP : MemPtr := List;
adalisp_genesis 903 Result : MemPtr := 0;
adalisp_genesis 904 Default : MemPtr := 0;
adalisp_genesis 905 begin
adalisp_genesis 906
adalisp_genesis 907 while LP /= 0 loop
adalisp_genesis 908 declare
adalisp_genesis 909 TempP : MemPtr;
adalisp_genesis 910 begin
adalisp_genesis 911
adalisp_genesis 912 exit when AMem(LP).T /= Cons;
adalisp_genesis 913
adalisp_genesis 914 Eval(Get_Car(AMem(LP)), Env, TempP);
adalisp_genesis 915
adalisp_genesis 916 Alloc_Cons(TempP, Result, Result);
adalisp_genesis 917
adalisp_genesis 918 LP := Get_Cdr(AMem(LP));
adalisp_genesis 919 end;
adalisp_genesis 920 end loop;
adalisp_genesis 921
adalisp_genesis 922
adalisp_genesis 923 if LP /= 0 then
adalisp_genesis 924 if AMem(LP).T /= Cons then
adalisp_genesis 925 Eval(LP, Env, Default);
adalisp_genesis 926 end if;
adalisp_genesis 927 end if;
adalisp_genesis 928
adalisp_genesis 929
adalisp_genesis 930 Rev_In_Place(Result, Default, OutP);
adalisp_genesis 931 end Eval_List;
adalisp_genesis 932
adalisp_genesis 933
adalisp_genesis 934 procedure Eval(InP, Env : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 935 TempP, OpP, ArgsP : MemPtr;
adalisp_genesis 936 begin
adalisp_genesis 937
adalisp_genesis 938 if (InP = 0) then
adalisp_genesis 939 OutP := 0;
adalisp_genesis 940 return;
adalisp_genesis 941 end if;
adalisp_genesis 942
adalisp_genesis 943
adalisp_genesis 944 case AMem(InP).T is
adalisp_genesis 945 when Free =>
adalisp_genesis 946 pragma Assert(False, "Trying to eval free cell!");
adalisp_genesis 947 when Cons =>
adalisp_genesis 948
adalisp_genesis 949 TempP := Get_Car(AMem(InP));
adalisp_genesis 950 Eval(TempP, Env, OpP);
adalisp_genesis 951
adalisp_genesis 952 ArgsP := Get_Cdr(AMem(InP));
adalisp_genesis 953
adalisp_genesis 954 Apply_Func(OpP, ArgsP, Env, False, OutP);
adalisp_genesis 955 when Bool | Fixnum | Char | Builtin | Closure =>
adalisp_genesis 956
adalisp_genesis 957 OutP := InP;
adalisp_genesis 958 when Symbol =>
adalisp_genesis 959
adalisp_genesis 960 Lookup_Env_Or_Global(InP, Env, TempP);
adalisp_genesis 961
adalisp_genesis 962 if TempP = 0 then
adalisp_genesis 963 Put("Not found: "); Dump_Cell(InP);
adalisp_genesis 964 pragma Assert(False, "No binding for symbol.");
adalisp_genesis 965 end if;
adalisp_genesis 966 OutP := Get_Cdr(AMem(TempP));
adalisp_genesis 967 end case;
adalisp_genesis 968 end Eval;
adalisp_genesis 969
adalisp_genesis 970
adalisp_genesis 971 procedure Rev_Append(A, B : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 972 Acc : MemPtr := A;
adalisp_genesis 973 P : MemPtr := B;
adalisp_genesis 974 begin
adalisp_genesis 975 while P /= 0 loop
adalisp_genesis 976 exit when AMem(P).T /= Cons;
adalisp_genesis 977 Alloc_Cons(Get_Car(AMem(P)), Acc, Acc);
adalisp_genesis 978 P := Get_Cdr(AMem(P));
adalisp_genesis 979 end loop;
adalisp_genesis 980
adalisp_genesis 981 pragma Assert (P = 0, "Non-list argument to append");
adalisp_genesis 982
adalisp_genesis 983 OutP := Acc;
adalisp_genesis 984 end Rev_Append;
adalisp_genesis 985
adalisp_genesis 986 procedure Rev_In_Place(List, Default : in MemPtr; OutP : out MemPtr) is
adalisp_genesis 987 P : MemPtr := List;
adalisp_genesis 988 Result : MemPtr := Default;
adalisp_genesis 989 Temp : MemPtr;
adalisp_genesis 990 begin
adalisp_genesis 991 while P /= 0 loop
adalisp_genesis 992 Temp := Get_Cdr(AMem(P));
adalisp_genesis 993 Set_Cdr(AMem(P), Result);
adalisp_genesis 994 Result := P;
adalisp_genesis 995 P := Temp;
adalisp_genesis 996 end loop;
adalisp_genesis 997
adalisp_genesis 998 OutP := Result;
adalisp_genesis 999 end Rev_In_Place;
adalisp_genesis 1000
adalisp_genesis 1001
adalisp_genesis 1002 function Boolean_Value(P : MemPtr) return Boolean is
adalisp_genesis 1003 begin
adalisp_genesis 1004
adalisp_genesis 1005
adalisp_genesis 1006 if P = 0 then
adalisp_genesis 1007 return True;
adalisp_genesis 1008 elsif AMem(P).T = Bool then
adalisp_genesis 1009 return Get_Bool(AMem(P));
adalisp_genesis 1010 else
adalisp_genesis 1011 return True;
adalisp_genesis 1012 end if;
adalisp_genesis 1013 end Boolean_Value;
adalisp_genesis 1014 end Evaler;