317 |
* first dispatch is based on the tc7-code. The second |
* first dispatch is based on the tc7-code. The second |
318 |
* dispatch is based on the actual byte code that is extracted |
* dispatch is based on the actual byte code that is extracted |
319 |
* from the upper bits. |
* from the upper bits. |
320 |
* x1-1110-100: characters with x as their least significant bit |
* x1-1110-100: evaluator byte codes ('ilocs') |
321 |
* 10-1110-100: various constants ('flags') |
* x1-1111-100: characters with x as their least significant bit |
322 |
* x1-1111-100: evaluator byte codes ('ilocs') |
* 10-1111-100: various constants ('flags') |
323 |
* |
* |
324 |
* |
* |
325 |
* Summary of type codes on the heap |
* Summary of type codes on the heap |
493 |
|
|
494 |
enum scm_tags |
enum scm_tags |
495 |
{ |
{ |
496 |
scm_tc8_char = 0xf4, |
scm_tc8_iloc = 0xf4, |
497 |
scm_tc8_iloc = 0xfc |
scm_tc8_char = 0xfc, |
498 |
|
scm_tc9_flag = 0x17c |
499 |
}; |
}; |
500 |
|
|
501 |
#define SCM_ITAG8(X) (SCM_UNPACK (X) & 0xff) |
#define SCM_ITAG8(X) (SCM_UNPACK (X) & 0xff) |
502 |
#define SCM_MAKE_ITAG8(X, TAG) SCM_PACK (((X) << 8) + TAG) |
#define SCM_MAKE_ITAG8(X, TAG) SCM_PACK (((X) << 8) + TAG) |
503 |
#define SCM_ITAG8_DATA(X) (SCM_UNPACK (X) >> 8) |
#define SCM_ITAG8_DATA(X) (SCM_UNPACK (X) >> 8) |
504 |
|
|
505 |
|
#define SCM_ITAG9(X) (SCM_UNPACK (X) & 0x1ff) |
506 |
|
#define SCM_MAKE_ITAG9(X, TAG) SCM_PACK (((X) << 9) + TAG) |
507 |
|
#define SCM_ITAG9_DATA(X) (SCM_UNPACK (X) >> 9) |
508 |
|
|
509 |
|
|
510 |
|
|
511 |
/* Immediate Symbols, Special Symbols, Flags (various constants). |
/* Flags (various constants and special objects). The indices of the flags |
512 |
*/ |
* must agree with the declarations in print.c: iflagnames. */ |
513 |
|
|
514 |
/* SCM_ISYMP tests for ISPCSYM and ISYM */ |
#define SCM_IFLAGP(n) (SCM_ITAG9 (n) == scm_tc9_flag) |
515 |
#define SCM_ISYMP(n) ((0x187 & SCM_UNPACK (n)) == 4) |
#define SCM_MAKIFLAG(n) SCM_MAKE_ITAG9 ((n), scm_tc9_flag) |
516 |
|
#define SCM_IFLAGNUM(n) (SCM_ITAG9_DATA (n)) |
517 |
|
|
518 |
|
#define SCM_BOOL_F SCM_MAKIFLAG (0) |
519 |
|
#define SCM_BOOL_T SCM_MAKIFLAG (1) |
520 |
|
#define SCM_UNDEFINED SCM_MAKIFLAG (2) |
521 |
|
#define SCM_EOF_VAL SCM_MAKIFLAG (3) |
522 |
|
#define SCM_EOL SCM_MAKIFLAG (4) |
523 |
|
#define SCM_UNSPECIFIED SCM_MAKIFLAG (5) |
524 |
|
|
525 |
|
/* When a variable is unbound this is marked by the SCM_UNDEFINED |
526 |
|
* value. The following is an unbound value which can be handled on |
527 |
|
* the Scheme level, i.e., it can be stored in and retrieved from a |
528 |
|
* Scheme variable. This value is only intended to mark an unbound |
529 |
|
* slot in GOOPS. It is needed now, but we should probably rewrite |
530 |
|
* the code which handles this value in C so that SCM_UNDEFINED can be |
531 |
|
* used instead. It is not ideal to let this kind of unique and |
532 |
|
* strange values loose on the Scheme level. */ |
533 |
|
#define SCM_UNBOUND SCM_MAKIFLAG (6) |
534 |
|
|
535 |
|
/* The Elisp nil value. */ |
536 |
|
#define SCM_ELISP_NIL SCM_MAKIFLAG (7) |
537 |
|
|
538 |
|
|
539 |
|
#define SCM_UNBNDP(x) (SCM_EQ_P ((x), SCM_UNDEFINED)) |
540 |
|
|
541 |
|
|
542 |
|
/* Short instructions ('special symbols'), long instructions ('immediate |
543 |
|
* symbols'). The indices of the SCM_IM_ symbols must agree with the |
544 |
|
* declarations in print.c: scm_isymnames. */ |
545 |
|
|
|
/* SCM_IFLAGP tests for ISPCSYM, ISYM and IFLAG */ |
|
|
#define SCM_IFLAGP(n) ((0x87 & SCM_UNPACK (n)) == 4) |
|
|
#define SCM_ISYMNUM(n) (SCM_UNPACK (n) >> 9) |
|
|
#define SCM_ISYMCHARS(n) (scm_isymnames[SCM_ISYMNUM (n)]) |
|
546 |
#define SCM_MAKSPCSYM(n) SCM_PACK (((n) << 9) + ((n) << 3) + 4L) |
#define SCM_MAKSPCSYM(n) SCM_PACK (((n) << 9) + ((n) << 3) + 4L) |
547 |
#define SCM_MAKISYM(n) SCM_PACK (((n) << 9) + 0x6cL) |
#define SCM_MAKISYM(n) SCM_PACK (((n) << 9) + 0x6cL) |
|
#define SCM_MAKIFLAG(n) SCM_PACK (((n) << 9) + 0x174L) |
|
548 |
|
|
549 |
|
/* SCM_ISYMP tests for ISPCSYM and ISYM */ |
550 |
|
#define SCM_ISYMP(n) ((0x187 & SCM_UNPACK (n)) == 4) |
551 |
|
#define SCM_ISYMNUM(n) (SCM_UNPACK (n) >> 9) |
552 |
SCM_API char *scm_isymnames[]; /* defined in print.c */ |
SCM_API char *scm_isymnames[]; /* defined in print.c */ |
553 |
|
#define SCM_ISYMCHARS(n) (scm_isymnames[SCM_ISYMNUM (n)]) |
|
/* This table must agree with the declarations |
|
|
* in print.c: {Names of immediate symbols}. |
|
|
* |
|
|
* These are used only in eval but their values |
|
|
* have to be allocated here. |
|
|
*/ |
|
554 |
|
|
555 |
/* Evaluator bytecodes (short instructions): These are uniquely identified by |
/* Evaluator bytecodes (short instructions): These are uniquely identified by |
556 |
* their tc7 value. This makes it possible for the evaluator to dispatch on |
* their tc7 value. This makes it possible for the evaluator to dispatch on |
557 |
* them in one step. However, the type system allows for at most 13 short |
* them in one step. However, the type system allows for at most 13 short |
558 |
* instructions. Consequently, the most frequent instructions are chosen to |
* instructions. Consequently, the most frequent instructions are chosen to |
559 |
* be represented as short instructions. */ |
* be represented as short instructions. These constants are used only in |
560 |
|
* eval but their values have to be allocated here. */ |
561 |
|
|
562 |
#define SCM_IM_AND SCM_MAKSPCSYM (0) |
#define SCM_IM_AND SCM_MAKSPCSYM (0) |
563 |
#define SCM_IM_BEGIN SCM_MAKSPCSYM (1) |
#define SCM_IM_BEGIN SCM_MAKSPCSYM (1) |
573 |
#define SCM_IM_QUOTE SCM_MAKSPCSYM (11) |
#define SCM_IM_QUOTE SCM_MAKSPCSYM (11) |
574 |
#define SCM_IM_SET_X SCM_MAKSPCSYM (12) |
#define SCM_IM_SET_X SCM_MAKSPCSYM (12) |
575 |
|
|
576 |
|
|
577 |
/* Evaluator bytecodes (long instructions): All these share a common tc7 |
/* Evaluator bytecodes (long instructions): All these share a common tc7 |
578 |
* value. Thus, the evaluator needs to dispatch on them in two steps. */ |
* value. Thus, the evaluator needs to dispatch on them in two steps. These |
579 |
|
* constants are used only in eval but their values have to be allocated |
580 |
|
* here. */ |
581 |
|
|
582 |
/* Evaluator bytecode for (define ...) statements. We make it a long |
/* Evaluator bytecode for (define ...) statements. We make it a long |
583 |
* instruction since the executor will see this bytecode only for a very |
* instruction since the evaluator will see this bytecode only for a very |
584 |
* limited number of times, namely once for every top-level and internal |
* limited number of times, namely once for every top-level and internal |
585 |
* definition: Top-level definitions are only executed once and internal |
* definition: Top-level definitions are only executed once and internal |
586 |
* definitions are converted to letrec expressions. */ |
* definitions are converted to letrec expressions. */ |
588 |
|
|
589 |
#define SCM_IM_APPLY SCM_MAKISYM (14) |
#define SCM_IM_APPLY SCM_MAKISYM (14) |
590 |
#define SCM_IM_CONT SCM_MAKISYM (15) |
#define SCM_IM_CONT SCM_MAKISYM (15) |
591 |
#define SCM_BOOL_F SCM_MAKIFLAG (16) |
#define SCM_IM_DISPATCH SCM_MAKISYM (16) |
592 |
#define SCM_BOOL_T SCM_MAKIFLAG (17) |
#define SCM_IM_SLOT_REF SCM_MAKISYM (17) |
593 |
#define SCM_UNDEFINED SCM_MAKIFLAG (18) |
#define SCM_IM_SLOT_SET_X SCM_MAKISYM (18) |
594 |
#define SCM_EOF_VAL SCM_MAKIFLAG (19) |
#define SCM_IM_DELAY SCM_MAKISYM (19) |
595 |
#define SCM_EOL SCM_MAKIFLAG (20) |
#define SCM_IM_FUTURE SCM_MAKISYM (20) |
596 |
#define SCM_UNSPECIFIED SCM_MAKIFLAG (21) |
#define SCM_IM_CALL_WITH_VALUES SCM_MAKISYM (21) |
|
#define SCM_IM_DISPATCH SCM_MAKISYM (22) |
|
|
#define SCM_IM_SLOT_REF SCM_MAKISYM (23) |
|
|
#define SCM_IM_SLOT_SET_X SCM_MAKISYM (24) |
|
597 |
|
|
598 |
/* Multi-language support */ |
/* Multi-language support */ |
599 |
|
|
600 |
#define SCM_IM_NIL_COND SCM_MAKISYM (25) |
#define SCM_IM_NIL_COND SCM_MAKISYM (22) |
601 |
#define SCM_IM_BIND SCM_MAKISYM (26) |
#define SCM_IM_BIND SCM_MAKISYM (23) |
|
|
|
|
#define SCM_IM_DELAY SCM_MAKISYM (27) |
|
|
#define SCM_IM_FUTURE SCM_MAKISYM (28) |
|
|
#define SCM_IM_CALL_WITH_VALUES SCM_MAKISYM (29) |
|
|
|
|
|
/* When a variable is unbound this is marked by the SCM_UNDEFINED |
|
|
* value. The following is an unbound value which can be handled on |
|
|
* the Scheme level, i.e., it can be stored in and retrieved from a |
|
|
* Scheme variable. This value is only intended to mark an unbound |
|
|
* slot in GOOPS. It is needed now, but we should probably rewrite |
|
|
* the code which handles this value in C so that SCM_UNDEFINED can be |
|
|
* used instead. It is not ideal to let this kind of unique and |
|
|
* strange values loose on the Scheme level. |
|
|
*/ |
|
|
#define SCM_UNBOUND SCM_MAKIFLAG (30) |
|
|
|
|
|
#define SCM_UNBNDP(x) (SCM_EQ_P ((x), SCM_UNDEFINED)) |
|
|
|
|
|
/* The Elisp nil value. */ |
|
|
#define SCM_ELISP_NIL SCM_MAKIFLAG (31) |
|
602 |
|
|
603 |
|
|
604 |
|
|