-- SaffronDeclarationCompileImpl.mesa -- Copyright Ó 1987 by Xerox Corporation. All rights reserved. -- Generated by Rauen.pa at September 1, 1988 6:38:46 pm PDT -- using ThreeCasabaFour [1.2] of June 1, 1987 6:00:00 pm PDT DIRECTORY SaffronAG7aDef, SaffronAG7bDef, SaffronPGDef, SaffronAG3Def, SaffronAG5Def, SaffronAG4Def, ThreeC4Support, SaffronBaseDef, SaffronATDef; SaffronDeclarationCompileImpl: CEDAR PROGRAM IMPORTS SaffronPGDef, ThreeC4Support, SaffronBaseDef, SaffronATDef EXPORTS SaffronAG7aDef, SaffronAG7bDef, SaffronAG3Def, SaffronAG5Def, SaffronAG4Def= BEGIN OPEN SaffronAG7aDef, SaffronAG7bDef, SaffronPGDef, SaffronAG3Def, SaffronAG5Def, SaffronAG4Def, ThreeC4Support, SaffronBaseDef, SaffronATDef; OptDecListabsentProdCompile: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode] RETURNS[temp0: ContextTreeNode, temp1: ProgramFragmentNode, temp2: ProgramGraphNode] = BEGIN tree: OptDecListNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; temp2 _ FakeDamageProgramGraph[pg]; temp1 _ MakePGNoOp[]; temp0 _ FakeDamageContextTree[contextTree]; END END; OptDecListpresentProdCompile: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode] RETURNS[temp0: ContextTreeNode, temp1: ProgramFragmentNode, temp2: ProgramGraphNode] = BEGIN tree: OptDecListNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: OptDecListpresentProdData _ NARROW[tree.data]; [temp0, temp1, temp2] _ treeData.DecList.procs.Compile[treeData.DecList, contextTree, pg, cs]; END END; DecListoneProdCompile: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode] RETURNS[temp0: ContextTreeNode, temp1: ProgramFragmentNode, temp2: ProgramGraphNode] = BEGIN tree: DecListNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: DecListoneProdData _ NARROW[tree.data]; [temp0, temp1, temp2] _ treeData.Declaration.procs.Compile[treeData.Declaration, contextTree, pg, cs]; END END; DecListmanyProdCompile: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode] RETURNS[temp0: ContextTreeNode, temp1: ProgramFragmentNode, temp2: ProgramGraphNode] = BEGIN tree: DecListNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: DecListmanyProdData _ NARROW[tree.data]; BEGIN pf3: ProgramFragmentNode; contextTree2: ContextTreeNode; pf2: ProgramFragmentNode; pg2: ProgramGraphNode; contextTree1: ContextTreeNode; pf1: ProgramFragmentNode; pg1: ProgramGraphNode; [contextTree1, pf1, pg1] _ treeData.DecListhead.procs.Compile[treeData.DecListhead, contextTree, pg, cs]; [contextTree2, pf2, pg2] _ treeData.DecListtail.procs.Compile[treeData.DecListtail, contextTree1, pg1, cs]; pf3 _ ConcatProgramFragments[pf1, pf2]; temp2 _ pg2; temp1 _ pf3; temp0 _ contextTree2; END; END END; DeclarationopaquetypeProdCompile: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode] RETURNS[temp0: ContextTreeNode, temp1: ProgramFragmentNode, temp2: ProgramGraphNode] = BEGIN tree: DeclarationNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: DeclarationopaquetypeProdData _ NARROW[tree.data]; temp2 _ FakeDamageProgramGraph[pg]; temp1 _ MakePGNoOp[]; temp0 _ FakeDamageContextTree[contextTree]; END END; DeclarationtypeProdCompile: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode] RETURNS[temp0: ContextTreeNode, temp1: ProgramFragmentNode, temp2: ProgramGraphNode] = BEGIN tree: DeclarationNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: DeclarationtypeProdData _ NARROW[tree.data]; temp2 _ FakeDamageProgramGraph[pg]; temp1 _ MakePGNoOp[]; temp0 _ FakeDamageContextTree[contextTree]; END END; DeclarationvalueProdCompile: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode] RETURNS[temp0: ContextTreeNode, temp1: ProgramFragmentNode, temp2: ProgramGraphNode] = BEGIN tree: DeclarationNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: DeclarationvalueProdData _ NARROW[tree.data]; BEGIN pf: ProgramFragmentNode; contextTree1: ContextTreeNode; initialValue: ValueNode; pg1: ProgramGraphNode; targetType: TypeGraphNodeNode; anyCorrespondingField: FieldNode; anyCorrespondingField _ FindAFieldCorrespondingToDeclaration[contextTree, DeclarationPTreeVal[tree]]; targetType _ FieldType[anyCorrespondingField]; [contextTree1, initialValue, pg1] _ treeData.Initialization.procs.CompileInitialization[treeData.Initialization, contextTree, pg, cs, targetType]; IF IsTrash[initialValue] THEN {pf _ MakePGNoOp[]; } ELSE {BEGIN pushInitialValue: ProgramFragmentNode; storeInitialValue: ProgramFragmentNode; storeInitialValue _ treeData.IdentList.procs.MakeCodeToStoreTOSInVariousLocalFrameSlots[treeData.IdentList, contextTree1]; pushInitialValue _ Code[initialValue]; pf _ ConcatProgramFragments[pushInitialValue, storeInitialValue]; END; }; temp2 _ pg1; temp1 _ pf; temp0 _ contextTree1; END; END END; InitializationemptyProdCompileInitialization: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode, targetType: TypeGraphNodeNode] RETURNS[temp0: ContextTreeNode, temp1: ValueNode, temp2: ProgramGraphNode] = BEGIN tree: InitializationNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; temp2 _ FakeDamageProgramGraph[pg]; temp1 _ CompileDefaultInitialization[targetType]; temp0 _ FakeDamageContextTree[contextTree]; END END; InitializationbindingProdCompileInitialization: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode, targetType: TypeGraphNodeNode] RETURNS[temp0: ContextTreeNode, temp1: ValueNode, temp2: ProgramGraphNode] = BEGIN tree: InitializationNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: InitializationbindingProdData _ NARROW[tree.data]; [temp0, temp1, temp2] _ treeData.InitialValue.procs.CompileInitialization[treeData.InitialValue, contextTree, pg, cs, targetType]; END END; InitializationassignmentProdCompileInitialization: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode, targetType: TypeGraphNodeNode] RETURNS[temp0: ContextTreeNode, temp1: ValueNode, temp2: ProgramGraphNode] = BEGIN tree: InitializationNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: InitializationassignmentProdData _ NARROW[tree.data]; [temp0, temp1, temp2] _ treeData.InitialValue.procs.CompileInitialization[treeData.InitialValue, contextTree, pg, cs, targetType]; END END; InitialValuetrashProdCompileInitialization: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode, targetType: TypeGraphNodeNode] RETURNS[temp0: ContextTreeNode, temp1: ValueNode, temp2: ProgramGraphNode] = BEGIN tree: InitialValueNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; temp2 _ FakeDamageProgramGraph[pg]; temp1 _ MakeTrash[targetType]; temp0 _ FakeDamageContextTree[contextTree]; END END; InitialValuecodeProdCompileInitialization: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode, targetType: TypeGraphNodeNode] RETURNS[temp0: ContextTreeNode, temp1: ValueNode, temp2: ProgramGraphNode] = BEGIN tree: InitialValueNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; BEGIN err: BOOLEAN; err _ Error["CompileInitialization for InitialValue.code not yet implemented."]; temp2 _ FakeDamageProgramGraph[pg]; temp1 _ MakeTrash[targetType]; temp0 _ FakeDamageContextTree[contextTree]; END; END END; InitialValueexpProdCompileInitialization: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode, targetType: TypeGraphNodeNode] RETURNS[temp0: ContextTreeNode, temp1: ValueNode, temp2: ProgramGraphNode] = BEGIN tree: InitialValueNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: InitialValueexpProdData _ NARROW[tree.data]; BEGIN value: ValueNode; contextTree1: ContextTreeNode; pg1: ProgramGraphNode; pg1 _ FakeDamageProgramGraph[pg]; [value, contextTree1] _ treeData.Exp.procs.CompileExpression[treeData.Exp, contextTree, cs, targetType]; temp2 _ pg1; temp1 _ value; temp0 _ contextTree1; END; END END; InitialValueblockProdCompileInitialization: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode, targetType: TypeGraphNodeNode] RETURNS[temp0: ContextTreeNode, temp1: ValueNode, temp2: ProgramGraphNode] = BEGIN tree: InitialValueNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: InitialValueblockProdData _ NARROW[tree.data]; BEGIN pg2: ProgramGraphNode; value: ValueNode; procedureGraph: ProcedureGraphNode; contextTree1: ContextTreeNode; blockCode: ProgramFragmentNode; pg1: ProgramGraphNode; [contextTree1, blockCode, pg1] _ treeData.Block.procs.CompileFrameBlock[treeData.Block, targetType, contextTree, pg, cs]; procedureGraph _ MakeProcedureGraph[blockCode]; value _ MakeTransferValue[targetType, procedureGraph]; pg2 _ AddSubroutineProcedureGraphToProgramGraph[procedureGraph, pg1]; temp2 _ pg2; temp1 _ value; temp0 _ contextTree1; END; END END; InitialValuemachinecodeProdCompileInitialization: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode, pg: ProgramGraphNode, cs: CompilerStateNode, targetType: TypeGraphNodeNode] RETURNS[temp0: ContextTreeNode, temp1: ValueNode, temp2: ProgramGraphNode] = BEGIN tree: InitialValueNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: InitialValuemachinecodeProdData _ NARROW[tree.data]; BEGIN err: BOOLEAN; err _ Error["CompileInitialization for InitialValue.machinecode not yet implemented."]; temp2 _ FakeDamageProgramGraph[pg]; temp1 _ MakeTrash[targetType]; temp0 _ FakeDamageContextTree[contextTree]; END; END END; IdentListoneProdMakeCodeToStoreTOSInVariousLocalFrameSlots: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode] RETURNS[temp0: ProgramFragmentNode] = BEGIN tree: IdentListNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: IdentListoneProdData _ NARROW[tree.data]; temp0 _ treeData.Ident.procs.MakeCodeToStoreTOSInVariousLocalFrameSlots[treeData.Ident, contextTree]; END END; IdentListmanyProdMakeCodeToStoreTOSInVariousLocalFrameSlots: PUBLIC PROC[ref: REF ANY, ct: ContextTreeNode] RETURNS[temp0: ProgramFragmentNode] = BEGIN tree: IdentListNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: IdentListmanyProdData _ NARROW[tree.data]; BEGIN pf4: ProgramFragmentNode; pf3: ProgramFragmentNode; pf2: ProgramFragmentNode; pf1: ProgramFragmentNode; pf1 _ treeData.IdentListhead.procs.MakeCodeToStoreTOSInVariousLocalFrameSlots[treeData.IdentListhead, ct]; pf2 _ MakePGNoOp[]; pf3 _ treeData.IdentListtail.procs.MakeCodeToStoreTOSInVariousLocalFrameSlots[treeData.IdentListtail, ct]; pf4 _ ConcatProgramFragments[ConcatProgramFragments[pf1, pf2], pf3]; temp0 _ pf4; END; END END; IdentidProdMakeCodeToStoreTOSInVariousLocalFrameSlots: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode] RETURNS[temp0: ProgramFragmentNode] = BEGIN tree: IdentNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: IdentidProdData _ NARROW[tree.data]; BEGIN pf: ProgramFragmentNode; pfd: ParameterizedFieldDescriptorNode; tgn: TypeGraphNodeNode; [pfd, tgn] _ GetPathToName[contextTree, treeData.Id]; pf _ MakePGStoreLocal[pfd]; temp0 _ pf; END; END END; IdentidpositionProdMakeCodeToStoreTOSInVariousLocalFrameSlots: PUBLIC PROC[ref: REF ANY, contextTree: ContextTreeNode] RETURNS[temp0: ProgramFragmentNode] = BEGIN tree: IdentNode_ NARROW[ref]; BEGIN ENABLE ThreeC4Support.GetSourceInfo => RESUME[tree.position, tree.length]; treeData: IdentidpositionProdData _ NARROW[tree.data]; BEGIN pf: ProgramFragmentNode; pfd: ParameterizedFieldDescriptorNode; tgn: TypeGraphNodeNode; [pfd, tgn] _ GetPathToName[contextTree, treeData.Id]; pf _ MakePGStoreLocal[pfd]; temp0 _ pf; END; END END; END..