RiscAssemblerDoitImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Generated by hederman.pa at July 15, 1987 4:53:09 pm PDT
using ThreeCasabaFour [1.2] of June 1, 1987 6:00:00 pm PDT
DIRECTORY
RiscAssemblerAGDef,
RiscAssemblerBaseDef,
RiscAssembler,
RiscAssemblerATDef,
ThreeC4Support,
RedBlackTree;
RiscAssemblerDoitImpl: CEDAR PROGRAM IMPORTS RiscAssemblerBaseDef, RiscAssembler, ThreeC4Support EXPORTS RiscAssemblerAGDef=
BEGIN
OPEN RiscAssemblerAGDef, RiscAssemblerBaseDef, RiscAssembler, RiscAssemblerATDef, ThreeC4Support, RedBlackTree;
ProgramlistProdAssemble: PUBLIC PROC[ref: REF ANY] RETURNS[temp0: EncodingSequence, temp1: Table, temp2: INT] =
BEGIN
tree: ProgramNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: ProgramlistProdData ← NARROW[tree.data];
BEGIN
codeBody: EncodingSequence;
symbolTable: Table;
nextAddress: INT;
initialAddress: INT;
initialTable: Table;
initialTable ← InitialSymbolTable[];
initialAddress ← CodeOrigin[];
[symbolTable, nextAddress] ← treeData.List.procs.SymbolTable[treeData.List, initialTable, initialAddress];
codeBody ← treeData.List.procs.CodeSequence[treeData.List, symbolTable];
temp2 ← nextAddress;
temp1 ← symbolTable;
temp0 ← codeBody;
END;
END
END;
ListstatementProdCodeSequence: PUBLIC PROC[ref: REF ANY, symbolTable: Table] RETURNS[temp0: EncodingSequence] =
BEGIN
tree: ListNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: ListstatementProdData ← NARROW[tree.data];
temp0 ← treeData.Statement.procs.CodeSequence[treeData.Statement, symbolTable];
END
END;
ListstatementProdSymbolTable: PUBLIC PROC[ref: REF ANY, initialTable: Table, initialAddress: INT] RETURNS[temp0: Table, temp1: INT] =
BEGIN
tree: ListNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: ListstatementProdData ← NARROW[tree.data];
[temp0, temp1] ← treeData.Statement.procs.SymbolTable[treeData.Statement, initialTable, initialAddress];
END
END;
ListdangleProdCodeSequence: PUBLIC PROC[ref: REF ANY, symbolTable: Table] RETURNS[temp0: EncodingSequence] =
BEGIN
tree: ListNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: ListdangleProdData ← NARROW[tree.data];
temp0 ← treeData.Statement.procs.CodeSequence[treeData.Statement, symbolTable];
END
END;
ListdangleProdSymbolTable: PUBLIC PROC[ref: REF ANY, initialTable: Table, initialAddress: INT] RETURNS[temp0: Table, temp1: INT] =
BEGIN
tree: ListNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: ListdangleProdData ← NARROW[tree.data];
[temp0, temp1] ← treeData.Statement.procs.SymbolTable[treeData.Statement, initialTable, initialAddress];
END
END;
ListconsProdCodeSequence: PUBLIC PROC[ref: REF ANY, symbolTable: Table] RETURNS[temp0: EncodingSequence] =
BEGIN
tree: ListNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: ListconsProdData ← NARROW[tree.data];
BEGIN
rest: EncodingSequence;
first: EncodingSequence;
first ← treeData.Statement.procs.CodeSequence[treeData.Statement, symbolTable];
rest ← treeData.List.procs.CodeSequence[treeData.List, symbolTable];
temp0 ← CodeConcat[first, rest];
END;
END
END;
ListconsProdSymbolTable: PUBLIC PROC[ref: REF ANY, initialTable: Table, initialAddress: INT] RETURNS[temp0: Table, temp1: INT] =
BEGIN
tree: ListNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: ListconsProdData ← NARROW[tree.data];
BEGIN
newTable: Table;
nextAddress: INT;
[newTable, nextAddress] ← treeData.Statement.procs.SymbolTable[treeData.Statement, initialTable, initialAddress];
[temp0, temp1] ← treeData.List.procs.SymbolTable[treeData.List, newTable, nextAddress];
END;
END
END;
StatementlabelProdCodeSequence: PUBLIC PROC[ref: REF ANY, symbolTable: Table] RETURNS[temp0: EncodingSequence] =
BEGIN
tree: StatementNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: StatementlabelProdData ← NARROW[tree.data];
temp0 ← treeData.Statement.procs.CodeSequence[treeData.Statement, symbolTable];
END
END;
StatementlabelProdSymbolTable: PUBLIC PROC[ref: REF ANY, initialTable: Table, initialAddress: INT] RETURNS[temp0: Table, temp1: INT] =
BEGIN
tree: StatementNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: StatementlabelProdData ← NARROW[tree.data];
BEGIN
newTable: Table;
entry: LabelInstance;
nextAddress: INT;
definedAt: INT;
len: INT;
len ← treeData.Label.length;
definedAt ← treeData.Label.position;
nextAddress ← Succ[initialAddress];
entry ← treeData.Label.procs.NotePosition[treeData.Label, initialAddress, definedAt];
newTable ← SymbolConcat[initialTable, entry];
[temp0, temp1] ← treeData.Statement.procs.SymbolTable[treeData.Statement, newTable, nextAddress];
END;
END
END;
StatementopProdCodeSequence: PUBLIC PROC[ref: REF ANY, symbolTable: Table] RETURNS[temp0: EncodingSequence] =
BEGIN
tree: StatementNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: StatementopProdData ← NARROW[tree.data];
BEGIN
segment: Encoding;
segment ← treeData.Op.procs.Instruction[treeData.Op];
temp0 ← InstructionSequence[segment];
END;
END
END;
StatementopProdSymbolTable: PUBLIC PROC[ref: REF ANY, initialTable: Table, initialAddress: INT] RETURNS[temp0: Table, temp1: INT] =
BEGIN
tree: StatementNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: StatementopProdData ← NARROW[tree.data];
BEGIN
newTable: Table;
nextAddress: INT;
nextAddress ← Succ[initialAddress];
newTable ← SymbolCopy[initialTable];
temp1 ← nextAddress;
temp0 ← newTable;
END;
END
END;
StatementoprandProdCodeSequence: PUBLIC PROC[ref: REF ANY, symbolTable: Table] RETURNS[temp0: EncodingSequence] =
BEGIN
tree: StatementNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: StatementoprandProdData ← NARROW[tree.data];
BEGIN
segment: Encoding;
label: LabelInstance;
label ← treeData.Rand.procs.Index[treeData.Rand, symbolTable];
segment ← treeData.Op.procs.InstructionRand[treeData.Op, label];
temp0 ← InstructionSequence[segment];
END;
END
END;
StatementoprandProdSymbolTable: PUBLIC PROC[ref: REF ANY, initialTable: Table, initialAddress: INT] RETURNS[temp0: Table, temp1: INT] =
BEGIN
tree: StatementNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: StatementoprandProdData ← NARROW[tree.data];
BEGIN
newTable: Table;
nextAddress: INT;
nextAddress ← Succ[initialAddress];
newTable ← SymbolCopy[initialTable];
temp1 ← nextAddress;
temp0 ← newTable;
END;
END
END;
LabelidProdNotePosition: PUBLIC PROC[ref: REF ANY, address: INT, definedAt: INT] RETURNS[temp0: LabelInstance] =
BEGIN
tree: LabelNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: LabelidProdData ← NARROW[tree.data];
temp0 ← NewLabel[treeData.id, address, definedAt];
END
END;
OpnoopProdInstructionRand: PUBLIC PROC[ref: REF ANY, index: LabelInstance] RETURNS[temp0: Encoding] =
BEGIN
tree: OpNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
temp0 ← CodeRandFirewall[Opcode.noop, index];
END
END;
OpnoopProdInstruction: PUBLIC PROC[ref: REF ANY] RETURNS[temp0: Encoding] =
BEGIN
tree: OpNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
temp0 ← Code[Opcode.noop];
END
END;
OpgotoProdInstructionRand: PUBLIC PROC[ref: REF ANY, index: LabelInstance] RETURNS[temp0: Encoding] =
BEGIN
tree: OpNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
temp0 ← CodeRand[Opcode.goto, index];
END
END;
OpgotoProdInstruction: PUBLIC PROC[ref: REF ANY] RETURNS[temp0: Encoding] =
BEGIN
tree: OpNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
temp0 ← CodeFirewall[Opcode.goto];
END
END;
RandidProdIndex: PUBLIC PROC[ref: REF ANY, symbolTable: Table] RETURNS[temp0: LabelInstance] =
BEGIN
tree: RandNode← NARROW[ref];
BEGIN
ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length];
treeData: RandidProdData ← NARROW[tree.data];
temp0 ← SymbolIndex[symbolTable, treeData.id];
END
END;
END..