<> <> <> <> <> DIRECTORY Alloc USING [Base, Notifier], Literals USING [LTIndex, LTNull, STIndex], PrincOps USING [MaxFrameSize], SourceMap USING [Loc], Symbols USING [BTIndex, ContextLevel, HTIndex, ISEIndex, ISENull, lZ, RecordSEIndex], SymbolSegment USING [Tables], Table USING [Selector]; CodeDefs: DEFINITIONS = { OPEN Symbols; Byte: TYPE = [0..256); bitsPerWord: NAT = 16; OpWordCount: TYPE = CARDINAL; -- size of operands for builtins Base: TYPE = Alloc.Base; Limit: CARDINAL = 77777B; Lexeme: TYPE = MACHINE DEPENDENT RECORD [ lexvalue(0): SELECT lextag(0): * FROM se => [lexsei(1): ISEIndex], literal => [ index(1): SELECT littag(1: 0..0): * FROM word => [lexlti(1: 1..15): Literals.LTIndex], string => [lexsti(1: 1..15): Literals.STIndex] ENDCASE], bdo => [lexbdoi(1): VarIndex], stack => [lexsti(1): StackIndex] ENDCASE]; NullLex: Lexeme.se = Lexeme[se[Symbols.ISENull]]; MoveDirection: TYPE = {load, store}; VarSpace: TYPE = {faddr, frame, frameup, caddr, code, link, linkup, stack, const, pdesc}; VarTag: TYPE = {o, bo, bdo, ind}; VarComponent: TYPE = RECORD [ wSize: CARDINAL _ 0 | TRASH, bSize: [0..bitsPerWord) _ 0 | TRASH, space: SELECT tag: VarSpace FROM frame => [ immutable: BOOL _ FALSE, level: ContextLevel _ lZ, wd: CARDINAL _ 0, bd: [0..bitsPerWord) _ 0], code => [ bd: [0..bitsPerWord) _ 0, wd: CARDINAL _ 0, lti: Literals.LTIndex _ Literals.LTNull], faddr => [wd: CARDINAL, level: ContextLevel], frameup => [ level: ContextLevel _ lZ, pwSize: [1..2] _ 1, immutable: BOOL _ FALSE, wd: CARDINAL _ 0, delta: [0..PrincOps.MaxFrameSize) _ 0], caddr, link => [wd: CARDINAL], linkup => [ wd: CARDINAL, delta: [0..PrincOps.MaxFrameSize) _ 0], stack => [ bd: [0..bitsPerWord) _ 0, wd: CARDINAL _ 0, sti: StackIndex], const => [bd: [0..bitsPerWord) _ 0, d1, d2: UNSPECIFIED _ TRASH], pdesc => [ep: CARDINAL] ENDCASE]; VarItem: TYPE = RECORD [ -- not many around simultaneously free: BOOL _ FALSE, -- required by allocator body: SELECT tag: VarTag FROM o => [var: VarComponent], bo => [offset, base: VarComponent], bdo => [offset, base, disp: VarComponent], ind => [ offset, base, index: VarComponent, simple: BOOL, packinfo: SELECT packtag: * FROM packed => [grain: [1..bitsPerWord)], notPacked => [eWords: [0..PrincOps.MaxFrameSize)] ENDCASE] ENDCASE]; VarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem; OVarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem.o; BoVarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem.bo; BdoVarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem.bdo; IndVarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem.ind; VarNull: VarIndex = VarIndex.FIRST; RelativePC: TYPE = [0..177777B]; CCInfoType: TYPE = {generating, binding, coding}; CodeChunkType: TYPE = {code, label, jump, other}; CCItem: TYPE = RECORD [ free: BOOL, flink, blink: CCIndex, ccvalue: SELECT cctag: CodeChunkType FROM code => [ realinst: BOOL, inst: Byte, isize: [0..7], fill: [0..3], parameters: ARRAY [1..1) OF WORD], label => [ labelseen: BOOL, labelinfo: SELECT OVERLAID CCInfoType FROM generating => [fillword, jumplist: JumpCCIndex], binding => [minPC, maxPC: RelativePC], coding => [fillword, pc: RelativePC], ENDCASE], jump => [ jsize: [0..7], jparam: Byte, fixedup, completed: BOOL, forward: BOOL, jtype: JumpType, destlabel: LabelCCIndex, jumpinfo: SELECT OVERLAID CCInfoType FROM generating => [fillword, thread: JumpCCIndex], binding => [minPC, maxPC: RelativePC], coding => [fillword, pc: RelativePC] ENDCASE], other => [obody: SELECT otag: * FROM table => [ btab: BOOL, tablecodebytes: [0..7], taboffset: INTEGER], markbody => [ start: BOOL, index: BTIndex], relSource => [relLoc: RelSourceLoc], -- relative to proc body absSource => [loc: SourceMap.Loc] ENDCASE] ENDCASE]; RelSourceLoc: TYPE = [0..7777B]; CCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem; CCNull: CCIndex = CCIndex.FIRST; JumpCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.jump; JumpCCNull: JumpCCIndex = LOOPHOLE[CCNull]; LabelCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.label; LabelCCNull: LabelCCIndex = LOOPHOLE[CCNull]; CodeCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.code; CodeCCNull: CodeCCIndex = LOOPHOLE[CCNull]; OtherCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.other; TableCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.other.table; TableCCNull: TableCCIndex = LOOPHOLE[CCNull]; CJItem: TYPE = RECORD [ inst: CCIndex, variant: SELECT tag:* FROM fallIn => [lc: LabelCCIndex], jumpIn => [jc: JumpCCIndex] ENDCASE]; CompareClass: TYPE = {word, byte}; JumpType: TYPE = { JumpE, JumpN, JumpL, JumpGE, JumpG, JumpLE, UJumpL, UJumpGE, UJumpG, UJumpLE, ZJumpE, ZJumpN, Jump, JumpA, JumpC, JumpCA, JumpRet, NILJumpE, NILJumpN, PAIRJumpL, PAIRJumpG, BYTEJumpE, BYTEJumpN, BITJumpE, BITJumpN}; LabelInfoRecord: TYPE = RECORD [ free: BOOL _ FALSE, thread: LabelInfoIndex, catchLevel: [0..37777b], body: SELECT tag:* FROM named => [hti: HTIndex, cci: LabelCCIndex], loop => [exit, loop: LabelCCIndex], stmt => [retry, continue: LabelCCIndex] ENDCASE]; LabelInfoIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO LabelInfoRecord; NamedLabelInfoIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO LabelInfoRecord.named; LabelInfoNull: LabelInfoIndex = LabelInfoIndex.FIRST; StackIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO StackItem; StackNull: StackIndex = StackIndex.FIRST; StackItem: TYPE = RECORD [ free: BOOL _ FALSE, uplink, downlink: StackIndex _ StackNull, data: SELECT tag:* FROM mark => [label: LabelCCIndex], onStack => [ alsoLink: BOOL _ FALSE, tLevel: Symbols.ContextLevel _ lZ, tOffset: TempAddr _ TRASH], inTemp => [ tLevel: Symbols.ContextLevel, tOffset: TempAddr], inLink => [link: Byte] ENDCASE]; <> <> StackPos: TYPE = [0..16); StackLocRec: TYPE = RECORD [SELECT tag:* FROM onStack => [depth: CARDINAL], inTemp => [ tSize: TempSize, tLevel: Symbols.ContextLevel, tOffset: TempAddr], inLink => [link: [0..256)], mixed => [] ENDCASE]; <> <> <<>> <> <<>> <> <> <> <> <> EvalStackSize: CARDINAL = 14; MaxParmsInStack: CARDINAL = EvalStackSize - 3; TempAddr: TYPE = [0..PrincOps.MaxFrameSize); TempSize: TYPE = [0..PrincOps.MaxFrameSize); TempStateRecord: TYPE = RECORD[pendtemplist, heaplist: ISEIndex]; FrameStateRecord: TYPE = RECORD[ pendtemplist, heaplist: ISEIndex, tempctxlvl: ContextLevel, firstTemp, tempstart, framesz: INTEGER]; CaseCVState: TYPE = {single, singleLoaded, multi, none}; StoreOptions: TYPE = RECORD [ expr: BOOL _ FALSE, init: BOOL _ FALSE, counted: BOOL _ FALSE, composite: BOOL _ FALSE]; ConsDestination: TYPE = RECORD [ bd: [0..bitsPerWord) _ TRASH, bSize: [0..bitsPerWord) _ TRASH, inFrame: BOOL _ FALSE, -- can store directly into frame fLevel: Symbols.ContextLevel _ TRASH, pLength: [1..2] _ 1, ignoreSafen: BOOL _ FALSE, fOffset: CARDINAL _ TRASH, -- offset of first word of record pLoaded: BOOL _ FALSE, -- pointer already on virtual stack pSti: StackIndex _ TRASH, -- the sti of the pointer if pLoaded pDelta: INTEGER _ 0, -- word offset into record of pointer pLink: BOOL _ FALSE, -- pointer also in a link pLevel: Symbols.ContextLevel _ lZ, -- if not lZ, then ptr is in temp pOffset: TempAddr _ TRASH, -- frame offset of temp or link remaining: CARDINAL _ 0, wSize: CARDINAL _ TRASH, options: StoreOptions _ []]; StatementStateRecord: TYPE = RECORD [ retLabel, comRetLabel: LabelCCIndex, outRecord: RecordSEIndex, pendtemplist: ISEIndex, stkPtr: UNSPECIFIED, inlineFileLoc: SourceMap.Loc]; ChunkIndex: TYPE = Base RELATIVE POINTER [0..Limit); codeType: Table.Selector = SymbolSegment.Tables.LAST+1; AddressNotify, CallsNotify, ConstructorNotify, CountingNotify, CrossJumpNotify, DJumpsNotify, ExpressionNotify, FinalNotify, FlowNotify, FlowExpressionNotify, OutCodeNotify, PeepholeNotify, StatementNotify, SelectionNotify, StoreNotify, TempNotify, VarBasicsNotify, VarMoveNotify, VarUtilsNotify: Alloc.Notifier; }.