DIRECTORY
Basics USING [Comparison],
RedBlackTree,
Rope USING [Compare, ROPE],
RiscAssemblerTokenDef USING [idNode],
RiscAssembler,
RiscAssemblerBaseDef;
RiscAssemblerBaseImpl:
CEDAR
MONITOR
IMPORTS RedBlackTree, Rope
EXPORTS RiscAssemblerBaseDef ~ {
OPEN RiscAssemblerTokenDef, RiscAssembler, RiscAssemblerBaseDef;
ROPE: TYPE ~ Rope.ROPE;
Table: TYPE ~ RedBlackTree.Table;
FIREWALL: PUBLIC SIGNAL ~ CODE;
CodeConcat:
PUBLIC
PROC [left: EncodingSequence, right: EncodingSequence]
RETURNS [list: EncodingSequence] ~ {
list ← NIL;
};
InstructionSequence:
PUBLIC
PROC [instr: Encoding]
RETURNS [list: EncodingSequence] ~ {
list ← LIST[instr];
};
Code:
PUBLIC
PROC [op: Opcode]
RETURNS [instr: Encoding] ~ {
instr ← op.ORD;
};
CodeFirewall:
PUBLIC
PROC [op: Opcode]
RETURNS [instr: Encoding] ~ {
instr ← op.ORD;
SIGNAL FIREWALL;
};
CodeRand:
PUBLIC
PROC [op: Opcode, label: LabelInstance]
RETURNS [instr: Encoding] ~ {
instr ← op.ORD;
};
CodeRandFirewall:
PUBLIC
PROC [op: Opcode, label: LabelInstance]
RETURNS [instr: Encoding] ~ {
instr ← op.ORD;
SIGNAL FIREWALL;
};
SymbolCopy:
PUBLIC
PROC [in: Table]
RETURNS [out: Table] ~ {
out ← in;
};
SymbolConcat:
PUBLIC
PROC [t: Table, entry: LabelInstance]
RETURNS [new: Table] ~ {
have to cons up nodes with values!
RedBlackTree.Insert[t, entry, entry.text];
new ← t;
};
CodeOrigin:
PUBLIC
PROC
RETURNS [origin:
INT] ~ {
origin ← 1;
};
InitialSymbolTable:
PUBLIC
PROC
RETURNS [t: Table] ~ {
t ← RedBlackTree.Create[GetKey, Compare];
};
NewLabel:
PUBLIC
PROC [id: idNode, address:
INT, definedAt:
INT]
RETURNS [l: LabelInstance] ~ {
l ← NEW[EntryObject ← [id.text, address, definedAt]];
};
SymbolIndex:
PUBLIC
PROC [t: Table, id: idNode]
RETURNS [l: LabelInstance] ~ {
data: RedBlackTree.UserData ~ RedBlackTree.Lookup[t, id.text];
l ← NARROW[data];
};
GetKey:
PROC [data: RedBlackTree.UserData]
RETURNS [key: RedBlackTree.Key] ~ {
id: idNode ~ NARROW[data];
key ← id.text;
};
Compare:
PROC [k: RedBlackTree.Key, data: RedBlackTree.UserData]
RETURNS [Basics.Comparison] ~ {
l: LabelInstance ~ NARROW[data];
left: ROPE ~ NARROW[k];
right: ROPE ~ l.text;
RETURN[Rope.Compare[left, right]];
};
}...