next up previous contents
Next: 11. Virtual Machine Up: QScheme Documentation Previous: 9. Data types   Contents

Subsections

10. Internal representation of scheme objects

All Scheme object is either a pointer to a cell or an immediate small integer

10.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 asumptions 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 odd, which means that bit 0 is always 0.

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

10.2 Immediate small integer

Immediate small integer 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.

10.3 Other Objects

10.3.1 Procedures

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 current bindings.

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

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

10.3.2 Numbers


next up previous contents
Next: 11. Virtual Machine Up: QScheme Documentation Previous: 9. Data types   Contents
Daniel Crettol
1999-07-19