Download Forth 7 Cross Compiler - MicroProcessor Engineering Ltd.

Transcript
Chapter 19: Compilation in detail
109
19 Compilation in detail
This chapter provides more detail on how to get the best out of the compiler. Topics covered
include:
∙ Special compilation behaviour
∙ Special interpretation behaviour
∙ Structures
∙ Defining words
19.1 Special compilation behaviour
Many ANS standard words are treated as special cases during compilation, either because
the VFX code generator produces optimised code rather than a call to a target word, or
because the word is normally IMMEDIATE and is executed during compilation.
The full list can be seen by typing:
COMPILERS
19.2 Special interpretation behaviour
Some words are only available during interpretation (outside a colon definition), or are
treated specially during interpretation. The special behaviour may be required because:
∙ the words mimic target behaviour, usually by dealing with target memory,
∙ they are defining words,
∙ they are compiler directives,
∙ because they are made available for execution during interpretation.
The full list can be seen by typing:
INTERPRETERS
19.3 Structures
A named structure is defined using the following template. When the name of a structure
is executed its size is returned.
If you have many fields of the same size, you can define your own field types.
Size FIELD-TYPE <field-type-name>
The template for a structure is:
STRUCT <struct-name>
size1 FIELD <field-name1>
size2 FIELD <field-name3>
<field-type-name> <field-name3>
...
END-STRUCT