macross/slinkyExpressions.h
Michael Steil 98a36557e4 Initial commit from macross.tar.gz
MD5 (macross.tar.gz) = 4ecb4a6e015b11fef043fe78d1eedb61
2014-05-03 22:20:34 -07:00

148 lines
4.0 KiB
C

/*
slinkyExpressions.h -- Expression definitions for the Slinky linker
Chip Morningstar -- Lucasfilm Ltd.
6-November-1985
*/
/*
Expressions are stored in the object file in a compact parse-tree
representation. We just read this directly and interpret it on-the-fly
without much sophistication. Function definitions include whole
statements, but the principle is the same.
The basic form of a syntactic entity is:
+---------+-------------+
| tagByte | bodyOfThing |
+---------+-------------+
where 'tabByte' encodes how 'bodyOfThing' is to be interpreted.
These are the possible 'thing's, as encoded by the 'tagByte's
+------+
identifier: | sym# | 'sym#' is an index into the symbol entries
+------+ of the object file when the expression is
in the object file too, and then 'sym#' is converted
to a pointer to symbol structure when the symbol
itself is read in.
+-------+-------+------+------+-----+
functionCall: | func# | argCt | expr | expr | ... | 'argCt' is a
+-------+-------+------+------+-----+ single byte
argument count (which means that a function may have
no more than 255 arguments if it is to be used
externally) and this is how many 'expr's there are.
+-----+
number: | num | 'num' is just a 4-byte number.
+-----+
+----+
conditionCode: | cc | 'cc' is a single byte condition code.
+----+
+------+
subexpression: | expr |
+------+
+----+------+
unop: | op | expr | 'op' is a 1-byte operation number.
+----+------+
+----+------+------+
binop: | op | expr | expr |
+----+------+------+
+----+------+
preop: | op | expr |
+----+------+
+----+------+
postop: | op | expr |
+----+------+
here: empty body.
+---+---+---+---+-----+----+
string: | a | b | c | d | ... | \0 | Typical 'C' string.
+---+---+---+---+-----+----+
+------+------+
array: | sym# | expr |
+------+------+
+-----+
value: | num |
+-----+
null: empty body. Encodes null expression *or* statement.
+-------+-------+-----+-----+
block: | thing | thing | ... | end | 'end' acts as a
+-------+-------+-----+-----+ termination symbol.
+------+------+
mdefine: | sym# | expr | 'expr' can be null.
+------+------+
+------+------+
mvar: | sym# | expr | 'expr' can be null.
+------+------+
+------+-------+-------+
mif: | expr | block | block | either 'block' can be null.
+------+-------+-------+
+------+------+------+-------+
mfor: | expr | expr | expr | block |
+------+------+------+-------+
+------+-------+
mwhile: | expr | block |
+------+-------+
+------+-------+
mdoWhile: | expr | block |
+------+-------+
+------+-------+
mdoUntil: | expr | block |
+------+-------+
+------+
freturn: | expr |
+------+
+------+
perform: | expr |
+------+
+-------+
group: | block |
+-------+
+------+--------+
assert: | expr | string |
+------+--------+
+------+--------+--------+-----+-----+
mswitch: | expr | clause | clause | ... | end |
+------+--------+--------+-----+-----+
+------+------+-----+-------+
clause: | expr | expr | ... | block |
+------+------+-----+-------+
end: empty body.
*/
#define IDENTIFIER_TAG 0x00
#define FUNCTION_CALL_TAG 0x01
#define NUMBER_TAG 0x02
#define CONDITION_CODE_TAG 0x03
#define SUBEXPRESSION_TAG 0x04
#define UNOP_TAG 0x05
#define BINOP_TAG 0x06
#define PREOP_TAG 0x07
#define POSTOP_TAG 0x08
#define HERE_TAG 0x09
#define STRING_TAG 0x0A
#define ARRAY_TAG 0x0B
#define VALUE_TAG 0x0C
#define NULL_TAG 0x0D
#define BLOCK_TAG 0x0E
#define MDEFINE_TAG 0x0F
#define MVARIABLE_TAG 0x10
#define MIF_TAG 0x11
#define MFOR_TAG 0x12
#define MWHILE_TAG 0x13
#define MDOWHILE_TAG 0x14
#define MDOUNTIL_TAG 0x15
#define PERFORM_TAG 0x16
#define GROUP_TAG 0x17
#define ASSERT_TAG 0x18
#define MSWITCH_TAG 0x19
#define CLAUSE_TAG 0x1A
#define END_TAG 0x1B
#define FRETURN_TAG 0x1C
#define BUILTIN_FUNCTION_CALL_TAG 0x1D
#define RELOCATABLE_TAG 0x1E