next up previous contents
Next: 12 Virtual Machine Up: QScheme Documentation Previous: 10 Data types *REVIEW*   Contents

Subsections

11 Internal representation of QScheme objects

Every QScheme object is either a pointer to a cell or an immediate small integer.

11.1 QScheme cells

All non immediate QScheme objects are stored in a heap, which is simply an array of Sobject

structure. A Sobject structure contains the following fields:

QScheme expects that following assumptions are strictly verified:

  1. The size of the Sobject structure must be a multiple of 2.
  2. The heap starts on an address which is a multiple of 2.
Because of this, the pointers to Scheme object are always even, which means that bit 0 is always 0.

If a type needs more data than the 2 pointers space provided by a cell, it has to allocate more space in the system heap by using the scm_must_alloc and scm_free functions.

11.2 Immediate small integers

Immediate small integers have bit 0 set to 1. The other bits of the word contain the true integer value. So on a machine where pointer are on 32 bits, the immediate number are coded on 31 bits.

11.3 Other Objects

11.3.1 Procedures

A procedure is implemented as follow:

<proc>     = [ <envFrame> | <code> ]

<envFrame> = <next> <nslots> <bindings>

<code>     = <envList> <size> <nargs> <optargs> <code-slot> ...

The envFrame pointer points to an Environment Frame which is cloned at runtime to contain the current bindings.

The envList is a pointer to the symbolic representation of the environment as built at compilation time. The compile-time environment is a list of localvar symbols.

<localvar> = [ <symbol> | <depth> <ofs> ]

11.3.2 Numbers

*REVIEW*

*** Yes, numbers ... ***


next up previous contents
Next: 12 Virtual Machine Up: QScheme Documentation Previous: 10 Data types *REVIEW*   Contents
Daniel Crettol 2000-06-12