module Feldspar.Compiler.PluginArchitecture (
module Feldspar.Compiler.PluginArchitecture,
module Feldspar.Compiler.Imperative.Representation,
module Feldspar.Compiler.Imperative.Semantics,
module Feldspar.Compiler.PluginArchitecture.DefaultConvert
) where
import Feldspar.Compiler.Imperative.Representation
import Feldspar.Compiler.Imperative.Semantics
import Feldspar.Compiler.PluginArchitecture.DefaultConvert
foldlist :: (Default a, Combine a) => [a] -> a
foldlist ul = case ul of
[] -> defaultValue
otherwise -> foldl combine (head ul) (tail ul)
convertMaybeList :: Maybe [a] -> [a]
convertMaybeList ul = case ul of
Nothing -> []
Just x -> x
convertMaybe :: Maybe a -> [a]
convertMaybe ul = case ul of
Nothing -> []
Just x -> [x]
type Walker t construction = (TransformationPhase t) => t -> Downwards t -> construction (From t) -> (construction (To t), Upwards t)
class (TransformationPhase t) => Plugin t where
type ExternalInfo t
executePlugin :: t -> ExternalInfo t -> Procedure (From t) -> Procedure (To t)
class (SemanticInfo (From t), SemanticInfo (To t)
, ConvertAllInfos (From t) (To t)
, Combine (Upwards t), Default (Upwards t)) => TransformationPhase t where
type From t
type To t
type Downwards t
type Upwards t
executeTransformationPhase :: Walker t Procedure
executeTransformationPhase = walkProcedure
downwardsProcedure :: t -> Downwards t -> Procedure (From t) -> Downwards t
downwardsProcedure self = const
transformProcedure :: t -> Downwards t -> Procedure (From t) -> InfoFromProcedureParts t -> Procedure (To t)
transformProcedure self fromAbove originalProcedure fromBelow = originalProcedure {
inParameters = recursivelyTransformedInParameters fromBelow,
outParameters = recursivelyTransformedOutParameters fromBelow,
procedureBody = recursivelyTransformedProcedureBody fromBelow,
procedureSemInf = convert $ procedureSemInf originalProcedure
}
upwardsProcedure :: t -> Downwards t -> Procedure (From t) -> InfoFromProcedureParts t -> Procedure (To t) -> Upwards t
upwardsProcedure self fromAbove originalProcedure fromBelow transformedProcedure = foldlist ((upwardsInfoFromInParameters fromBelow) ++ (upwardsInfoFromOutParameters fromBelow) ++ [(upwardsInfoFromProcedureBody fromBelow)])
downwardsBlock :: t -> Downwards t -> Block (From t) -> Downwards t
downwardsBlock self = const
transformBlock :: t -> Downwards t -> Block (From t) -> InfoFromBlockParts t -> Block (To t)
transformBlock self fromAbove originalBlock fromBelow = originalBlock {
blockDeclarations = recursivelyTransformedBlockDeclarations fromBelow,
blockInstructions = recursivelyTransformedBlockInstructions fromBelow,
blockSemInf = convert $ blockSemInf originalBlock
}
upwardsBlock :: t -> Downwards t -> Block (From t) -> InfoFromBlockParts t -> Block (To t) -> Upwards t
upwardsBlock self fromAbove originalBlock fromBelow transformedBlock = foldlist ((upwardsInfoFromBlockDeclarations fromBelow) ++ [(upwardsInfoFromBlockInstructions fromBelow)])
downwardsProgram :: t -> Downwards t -> Program (From t) -> Downwards t
downwardsProgram self = const
transformProgram :: t -> Downwards t -> Program (From t) -> InfoFromProgramParts t -> Program (To t)
transformProgram self fromAbove originalProgram fromBelow = originalProgram {
programConstruction = recursivelyTransformedProgramConstruction fromBelow,
programSemInf = convert $ programSemInf originalProgram
}
upwardsProgram :: t -> Downwards t -> Program (From t) -> InfoFromProgramParts t -> Program (To t) -> Upwards t
upwardsProgram self fromAbove originalProgram fromBelow transformedProgram = foldlist ([(upwardsInfoFromProgramConstruction fromBelow)])
transformEmptyProgramInProgram :: t -> Downwards t -> Empty (From t) -> ProgramConstruction (To t)
transformEmptyProgramInProgram self fromAbove originalEmpty = EmptyProgram $ originalEmpty {
emptySemInf = convert $ emptySemInf originalEmpty
}
upwardsEmptyProgramInProgram :: t -> Downwards t -> Empty (From t) -> ProgramConstruction (To t) -> Upwards t
upwardsEmptyProgramInProgram self fromAbove originalEmpty transformedEmpty = defaultValue
downwardsPrimitiveProgramInProgram :: t -> Downwards t -> Primitive (From t) -> Downwards t
downwardsPrimitiveProgramInProgram self = const
transformPrimitiveProgramInProgram :: t -> Downwards t -> Primitive (From t) -> InfoFromPrimitiveParts t -> ProgramConstruction (To t)
transformPrimitiveProgramInProgram self fromAbove originalPrimitive fromBelow = PrimitiveProgram $ originalPrimitive {
primitiveInstruction = recursivelyTransformedPrimitiveInstruction fromBelow,
primitiveSemInf = convert $ primitiveSemInf originalPrimitive
}
upwardsPrimitiveProgramInProgram :: t -> Downwards t -> Primitive (From t) -> InfoFromPrimitiveParts t -> ProgramConstruction (To t) -> Upwards t
upwardsPrimitiveProgramInProgram self fromAbove originalPrimitive fromBelow transformedPrimitive = foldlist ([(upwardsInfoFromPrimitiveInstruction fromBelow)])
downwardsSequenceProgramInProgram :: t -> Downwards t -> Sequence (From t) -> Downwards t
downwardsSequenceProgramInProgram self = const
transformSequenceProgramInProgram :: t -> Downwards t -> Sequence (From t) -> InfoFromSequenceParts t -> ProgramConstruction (To t)
transformSequenceProgramInProgram self fromAbove originalSequence fromBelow = SequenceProgram $ originalSequence {
sequenceProgramList = recursivelyTransformedSequenceProgramList fromBelow,
sequenceSemInf = convert $ sequenceSemInf originalSequence
}
upwardsSequenceProgramInProgram :: t -> Downwards t -> Sequence (From t) -> InfoFromSequenceParts t -> ProgramConstruction (To t) -> Upwards t
upwardsSequenceProgramInProgram self fromAbove originalSequence fromBelow transformedSequence = foldlist ((upwardsInfoFromSequenceProgramList fromBelow))
downwardsBranchProgramInProgram :: t -> Downwards t -> Branch (From t) -> Downwards t
downwardsBranchProgramInProgram self = const
transformBranchProgramInProgram :: t -> Downwards t -> Branch (From t) -> InfoFromBranchParts t -> ProgramConstruction (To t)
transformBranchProgramInProgram self fromAbove originalBranch fromBelow = BranchProgram $ originalBranch {
branchConditionVariable = recursivelyTransformedBranchConditionVariable fromBelow,
thenBlock = recursivelyTransformedThenBlock fromBelow,
elseBlock = recursivelyTransformedElseBlock fromBelow,
branchSemInf = convert $ branchSemInf originalBranch
}
upwardsBranchProgramInProgram :: t -> Downwards t -> Branch (From t) -> InfoFromBranchParts t -> ProgramConstruction (To t) -> Upwards t
upwardsBranchProgramInProgram self fromAbove originalBranch fromBelow transformedBranch = foldlist ([(upwardsInfoFromBranchConditionVariable fromBelow)] ++ [(upwardsInfoFromThenBlock fromBelow)] ++ [(upwardsInfoFromElseBlock fromBelow)])
downwardsSequentialLoopProgramInProgram :: t -> Downwards t -> SequentialLoop (From t) -> Downwards t
downwardsSequentialLoopProgramInProgram self = const
transformSequentialLoopProgramInProgram :: t -> Downwards t -> SequentialLoop (From t) -> InfoFromSequentialLoopParts t -> ProgramConstruction (To t)
transformSequentialLoopProgramInProgram self fromAbove originalSequentialLoop fromBelow = SequentialLoopProgram $ originalSequentialLoop {
sequentialLoopCondition = recursivelyTransformedSequentialLoopCondition fromBelow,
conditionCalculation = recursivelyTransformedConditionCalculation fromBelow,
sequentialLoopCore = recursivelyTransformedSequentialLoopCore fromBelow,
sequentialLoopSemInf = convert $ sequentialLoopSemInf originalSequentialLoop
}
upwardsSequentialLoopProgramInProgram :: t -> Downwards t -> SequentialLoop (From t) -> InfoFromSequentialLoopParts t -> ProgramConstruction (To t) -> Upwards t
upwardsSequentialLoopProgramInProgram self fromAbove originalSequentialLoop fromBelow transformedSequentialLoop = foldlist ([(upwardsInfoFromSequentialLoopCondition fromBelow)] ++ [(upwardsInfoFromConditionCalculation fromBelow)] ++ [(upwardsInfoFromSequentialLoopCore fromBelow)])
downwardsParallelLoopProgramInProgram :: t -> Downwards t -> ParallelLoop (From t) -> Downwards t
downwardsParallelLoopProgramInProgram self = const
transformParallelLoopProgramInProgram :: t -> Downwards t -> ParallelLoop (From t) -> InfoFromParallelLoopParts t -> ProgramConstruction (To t)
transformParallelLoopProgramInProgram self fromAbove originalParallelLoop fromBelow = ParallelLoopProgram $ originalParallelLoop {
parallelLoopConditionVariable = recursivelyTransformedParallelLoopConditionVariable fromBelow,
numberOfIterations = recursivelyTransformedNumberOfIterations fromBelow,
parallelLoopCore = recursivelyTransformedParallelLoopCore fromBelow,
parallelLoopSemInf = convert $ parallelLoopSemInf originalParallelLoop
}
upwardsParallelLoopProgramInProgram :: t -> Downwards t -> ParallelLoop (From t) -> InfoFromParallelLoopParts t -> ProgramConstruction (To t) -> Upwards t
upwardsParallelLoopProgramInProgram self fromAbove originalParallelLoop fromBelow transformedParallelLoop = foldlist ([(upwardsInfoFromParallelLoopConditionVariable fromBelow)] ++ [(upwardsInfoFromNumberOfIterations fromBelow)] ++ [(upwardsInfoFromParallelLoopCore fromBelow)])
downwardsFormalParameter :: t -> Downwards t -> FormalParameter (From t) -> Downwards t
downwardsFormalParameter self = const
transformFormalParameter :: t -> Downwards t -> FormalParameter (From t) -> InfoFromFormalParameterParts t -> FormalParameter (To t)
transformFormalParameter self fromAbove originalFormalParameter fromBelow = originalFormalParameter {
formalParameterVariable = recursivelyTransformedFormalParameterVariable fromBelow,
formalParameterSemInf = convert $ formalParameterSemInf originalFormalParameter
}
upwardsFormalParameter :: t -> Downwards t -> FormalParameter (From t) -> InfoFromFormalParameterParts t -> FormalParameter (To t) -> Upwards t
upwardsFormalParameter self fromAbove originalFormalParameter fromBelow transformedFormalParameter = foldlist ([(upwardsInfoFromFormalParameterVariable fromBelow)])
downwardsLocalDeclaration :: t -> Downwards t -> LocalDeclaration (From t) -> Downwards t
downwardsLocalDeclaration self = const
transformLocalDeclaration :: t -> Downwards t -> LocalDeclaration (From t) -> InfoFromLocalDeclarationParts t -> LocalDeclaration (To t)
transformLocalDeclaration self fromAbove originalLocalDeclaration fromBelow = originalLocalDeclaration {
localVariable = recursivelyTransformedLocalVariable fromBelow,
localInitValue = recursivelyTransformedLocalInitValue fromBelow,
localDeclarationSemInf = convert $ localDeclarationSemInf originalLocalDeclaration
}
upwardsLocalDeclaration :: t -> Downwards t -> LocalDeclaration (From t) -> InfoFromLocalDeclarationParts t -> LocalDeclaration (To t) -> Upwards t
upwardsLocalDeclaration self fromAbove originalLocalDeclaration fromBelow transformedLocalDeclaration = foldlist ([(upwardsInfoFromLocalVariable fromBelow)] ++ convertMaybe (upwardsInfoFromLocalInitValue fromBelow))
downwardsExpression :: t -> Downwards t -> Expression (From t) -> Downwards t
downwardsExpression self = const
transformExpression :: t -> Downwards t -> Expression (From t) -> InfoFromExpressionParts t -> Expression (To t)
transformExpression self fromAbove originalExpression fromBelow = originalExpression {
expressionData = recursivelyTransformedExpressionData fromBelow,
expressionSemInf = convert $ expressionSemInf originalExpression
}
upwardsExpression :: t -> Downwards t -> Expression (From t) -> InfoFromExpressionParts t -> Expression (To t) -> Upwards t
upwardsExpression self fromAbove originalExpression fromBelow transformedExpression = foldlist ([(upwardsInfoFromExpressionData fromBelow)])
downwardsLeftValueExpressionInExpression :: t -> Downwards t -> LeftValue (From t) -> Downwards t
downwardsLeftValueExpressionInExpression self = const
transformLeftValueExpressionInExpression :: t -> Downwards t -> LeftValue (From t) -> InfoFromLeftValueParts t -> ExpressionData (To t)
transformLeftValueExpressionInExpression self fromAbove originalLeftValue fromBelow = LeftValueExpression $ originalLeftValue {
leftValueData = recursivelyTransformedLeftValueData fromBelow,
leftValueSemInf = convert $ leftValueSemInf originalLeftValue
}
upwardsLeftValueExpressionInExpression :: t -> Downwards t -> LeftValue (From t) -> InfoFromLeftValueParts t -> ExpressionData (To t) -> Upwards t
upwardsLeftValueExpressionInExpression self fromAbove originalLeftValue fromBelow transformedLeftValue = foldlist ([(upwardsInfoFromLeftValueData fromBelow)])
downwardsConstantExpressionInExpression :: t -> Downwards t -> Constant (From t) -> Downwards t
downwardsConstantExpressionInExpression self = const
transformConstantExpressionInExpression :: t -> Downwards t -> Constant (From t) -> InfoFromConstantParts t -> ExpressionData (To t)
transformConstantExpressionInExpression self fromAbove originalConstant fromBelow = ConstantExpression $ originalConstant {
constantData = recursivelyTransformedConstantData fromBelow,
constantSemInf = convert $ constantSemInf originalConstant
}
upwardsConstantExpressionInExpression :: t -> Downwards t -> Constant (From t) -> InfoFromConstantParts t -> ExpressionData (To t) -> Upwards t
upwardsConstantExpressionInExpression self fromAbove originalConstant fromBelow transformedConstant = foldlist ([(upwardsInfoFromConstantData fromBelow)])
downwardsFunctionCallExpressionInExpression :: t -> Downwards t -> FunctionCall (From t) -> Downwards t
downwardsFunctionCallExpressionInExpression self = const
transformFunctionCallExpressionInExpression :: t -> Downwards t -> FunctionCall (From t) -> InfoFromFunctionCallParts t -> ExpressionData (To t)
transformFunctionCallExpressionInExpression self fromAbove originalFunctionCall fromBelow = FunctionCallExpression $ originalFunctionCall {
actualParametersOfFunctionToCall = recursivelyTransformedActualParametersOfFunctionToCall fromBelow,
functionCallSemInf = convert $ functionCallSemInf originalFunctionCall
}
upwardsFunctionCallExpressionInExpression :: t -> Downwards t -> FunctionCall (From t) -> InfoFromFunctionCallParts t -> ExpressionData (To t) -> Upwards t
upwardsFunctionCallExpressionInExpression self fromAbove originalFunctionCall fromBelow transformedFunctionCall = foldlist ((upwardsInfoFromActualParametersOfFunctionToCall fromBelow))
downwardsConstant :: t -> Downwards t -> Constant (From t) -> Downwards t
downwardsConstant self = const
transformConstant :: t -> Downwards t -> Constant (From t) -> InfoFromConstantParts t -> Constant (To t)
transformConstant self fromAbove originalConstant fromBelow = originalConstant {
constantData = recursivelyTransformedConstantData fromBelow,
constantSemInf = convert $ constantSemInf originalConstant
}
upwardsConstant :: t -> Downwards t -> Constant (From t) -> InfoFromConstantParts t -> Constant (To t) -> Upwards t
upwardsConstant self fromAbove originalConstant fromBelow transformedConstant = foldlist ([(upwardsInfoFromConstantData fromBelow)])
transformIntConstantInConstant :: t -> Downwards t -> IntConstantType (From t) -> ConstantData (To t)
transformIntConstantInConstant self fromAbove originalIntConstantType = IntConstant $ originalIntConstantType {
intConstantSemInf = convert $ intConstantSemInf originalIntConstantType
}
upwardsIntConstantInConstant :: t -> Downwards t -> IntConstantType (From t) -> ConstantData (To t) -> Upwards t
upwardsIntConstantInConstant self fromAbove originalIntConstantType transformedIntConstantType = defaultValue
transformFloatConstantInConstant :: t -> Downwards t -> FloatConstantType (From t) -> ConstantData (To t)
transformFloatConstantInConstant self fromAbove originalFloatConstantType = FloatConstant $ originalFloatConstantType {
floatConstantSemInf = convert $ floatConstantSemInf originalFloatConstantType
}
upwardsFloatConstantInConstant :: t -> Downwards t -> FloatConstantType (From t) -> ConstantData (To t) -> Upwards t
upwardsFloatConstantInConstant self fromAbove originalFloatConstantType transformedFloatConstantType = defaultValue
transformBoolConstantInConstant :: t -> Downwards t -> BoolConstantType (From t) -> ConstantData (To t)
transformBoolConstantInConstant self fromAbove originalBoolConstantType = BoolConstant $ originalBoolConstantType {
boolConstantSemInf = convert $ boolConstantSemInf originalBoolConstantType
}
upwardsBoolConstantInConstant :: t -> Downwards t -> BoolConstantType (From t) -> ConstantData (To t) -> Upwards t
upwardsBoolConstantInConstant self fromAbove originalBoolConstantType transformedBoolConstantType = defaultValue
downwardsArrayConstantInConstant :: t -> Downwards t -> ArrayConstantType (From t) -> Downwards t
downwardsArrayConstantInConstant self = const
transformArrayConstantInConstant :: t -> Downwards t -> ArrayConstantType (From t) -> InfoFromArrayConstantParts t -> ConstantData (To t)
transformArrayConstantInConstant self fromAbove originalArrayConstantType fromBelow = ArrayConstant $ originalArrayConstantType {
arrayConstantValue = recursivelyTransformedArrayConstantValue fromBelow,
arrayConstantSemInf = convert $ arrayConstantSemInf originalArrayConstantType
}
upwardsArrayConstantInConstant :: t -> Downwards t -> ArrayConstantType (From t) -> InfoFromArrayConstantParts t -> ConstantData (To t) -> Upwards t
upwardsArrayConstantInConstant self fromAbove originalArrayConstantType fromBelow transformedArrayConstantType = foldlist ((upwardsInfoFromArrayConstantValue fromBelow))
downwardsLeftValue :: t -> Downwards t -> LeftValue (From t) -> Downwards t
downwardsLeftValue self = const
transformLeftValue :: t -> Downwards t -> LeftValue (From t) -> InfoFromLeftValueParts t -> LeftValue (To t)
transformLeftValue self fromAbove originalLeftValue fromBelow = originalLeftValue {
leftValueData = recursivelyTransformedLeftValueData fromBelow,
leftValueSemInf = convert $ leftValueSemInf originalLeftValue
}
upwardsLeftValue :: t -> Downwards t -> LeftValue (From t) -> InfoFromLeftValueParts t -> LeftValue (To t) -> Upwards t
upwardsLeftValue self fromAbove originalLeftValue fromBelow transformedLeftValue = foldlist ([(upwardsInfoFromLeftValueData fromBelow)])
transformVariableLeftValueInLeftValue :: t -> Downwards t -> Variable (From t) -> LeftValueData (To t)
transformVariableLeftValueInLeftValue self fromAbove originalVariable = VariableLeftValue $ originalVariable {
variableSemInf = convert $ variableSemInf originalVariable
}
upwardsVariableLeftValueInLeftValue :: t -> Downwards t -> Variable (From t) -> LeftValueData (To t) -> Upwards t
upwardsVariableLeftValueInLeftValue self fromAbove originalVariable transformedVariable = defaultValue
downwardsArrayElemReferenceLeftValueInLeftValue :: t -> Downwards t -> ArrayElemReference (From t) -> Downwards t
downwardsArrayElemReferenceLeftValueInLeftValue self = const
transformArrayElemReferenceLeftValueInLeftValue :: t -> Downwards t -> ArrayElemReference (From t) -> InfoFromArrayElemReferenceParts t -> LeftValueData (To t)
transformArrayElemReferenceLeftValueInLeftValue self fromAbove originalArrayElemReference fromBelow = ArrayElemReferenceLeftValue $ originalArrayElemReference {
arrayName = recursivelyTransformedArrayName fromBelow,
arrayIndex = recursivelyTransformedArrayIndex fromBelow,
arrayElemReferenceSemInf = convert $ arrayElemReferenceSemInf originalArrayElemReference
}
upwardsArrayElemReferenceLeftValueInLeftValue :: t -> Downwards t -> ArrayElemReference (From t) -> InfoFromArrayElemReferenceParts t -> LeftValueData (To t) -> Upwards t
upwardsArrayElemReferenceLeftValueInLeftValue self fromAbove originalArrayElemReference fromBelow transformedArrayElemReference = foldlist ([(upwardsInfoFromArrayName fromBelow)] ++ [(upwardsInfoFromArrayIndex fromBelow)])
downwardsInstruction :: t -> Downwards t -> Instruction (From t) -> Downwards t
downwardsInstruction self = const
transformInstruction :: t -> Downwards t -> Instruction (From t) -> InfoFromInstructionParts t -> Instruction (To t)
transformInstruction self fromAbove originalInstruction fromBelow = originalInstruction {
instructionData = recursivelyTransformedInstructionData fromBelow,
instructionSemInf = convert $ instructionSemInf originalInstruction
}
upwardsInstruction :: t -> Downwards t -> Instruction (From t) -> InfoFromInstructionParts t -> Instruction (To t) -> Upwards t
upwardsInstruction self fromAbove originalInstruction fromBelow transformedInstruction = foldlist ([(upwardsInfoFromInstructionData fromBelow)])
downwardsAssignmentInstructionInInstruction :: t -> Downwards t -> Assignment (From t) -> Downwards t
downwardsAssignmentInstructionInInstruction self = const
transformAssignmentInstructionInInstruction :: t -> Downwards t -> Assignment (From t) -> InfoFromAssignmentParts t -> InstructionData (To t)
transformAssignmentInstructionInInstruction self fromAbove originalAssignment fromBelow = AssignmentInstruction $ originalAssignment {
assignmentLhs = recursivelyTransformedAssignmentLhs fromBelow,
assignmentRhs = recursivelyTransformedAssignmentRhs fromBelow,
assignmentSemInf = convert $ assignmentSemInf originalAssignment
}
upwardsAssignmentInstructionInInstruction :: t -> Downwards t -> Assignment (From t) -> InfoFromAssignmentParts t -> InstructionData (To t) -> Upwards t
upwardsAssignmentInstructionInInstruction self fromAbove originalAssignment fromBelow transformedAssignment = foldlist ([(upwardsInfoFromAssignmentLhs fromBelow)] ++ [(upwardsInfoFromAssignmentRhs fromBelow)])
downwardsProcedureCallInstructionInInstruction :: t -> Downwards t -> ProcedureCall (From t) -> Downwards t
downwardsProcedureCallInstructionInInstruction self = const
transformProcedureCallInstructionInInstruction :: t -> Downwards t -> ProcedureCall (From t) -> InfoFromProcedureCallParts t -> InstructionData (To t)
transformProcedureCallInstructionInInstruction self fromAbove originalProcedureCall fromBelow = ProcedureCallInstruction $ originalProcedureCall {
actualParametersOfProcedureToCall = recursivelyTransformedActualParametersOfProcedureToCall fromBelow,
procedureCallSemInf = convert $ procedureCallSemInf originalProcedureCall
}
upwardsProcedureCallInstructionInInstruction :: t -> Downwards t -> ProcedureCall (From t) -> InfoFromProcedureCallParts t -> InstructionData (To t) -> Upwards t
upwardsProcedureCallInstructionInInstruction self fromAbove originalProcedureCall fromBelow transformedProcedureCall = foldlist ((upwardsInfoFromActualParametersOfProcedureToCall fromBelow))
downwardsActualParameter :: t -> Downwards t -> ActualParameter (From t) -> Downwards t
downwardsActualParameter self = const
transformActualParameter :: t -> Downwards t -> ActualParameter (From t) -> InfoFromActualParameterParts t -> ActualParameter (To t)
transformActualParameter self fromAbove originalActualParameter fromBelow = originalActualParameter {
actualParameterData = recursivelyTransformedActualParameterData fromBelow,
actualParameterSemInf = convert $ actualParameterSemInf originalActualParameter
}
upwardsActualParameter :: t -> Downwards t -> ActualParameter (From t) -> InfoFromActualParameterParts t -> ActualParameter (To t) -> Upwards t
upwardsActualParameter self fromAbove originalActualParameter fromBelow transformedActualParameter = foldlist ([(upwardsInfoFromActualParameterData fromBelow)])
downwardsInputActualParameterInActualParameter :: t -> Downwards t -> Expression (From t) -> Downwards t
downwardsInputActualParameterInActualParameter self = const
transformInputActualParameterInActualParameter :: t -> Downwards t -> Expression (From t) -> InfoFromExpressionParts t -> ActualParameterData (To t)
transformInputActualParameterInActualParameter self fromAbove originalExpression fromBelow = InputActualParameter $ originalExpression {
expressionData = recursivelyTransformedExpressionData fromBelow,
expressionSemInf = convert $ expressionSemInf originalExpression
}
upwardsInputActualParameterInActualParameter :: t -> Downwards t -> Expression (From t) -> InfoFromExpressionParts t -> ActualParameterData (To t) -> Upwards t
upwardsInputActualParameterInActualParameter self fromAbove originalExpression fromBelow transformedExpression = foldlist ([(upwardsInfoFromExpressionData fromBelow)])
downwardsOutputActualParameterInActualParameter :: t -> Downwards t -> LeftValue (From t) -> Downwards t
downwardsOutputActualParameterInActualParameter self = const
transformOutputActualParameterInActualParameter :: t -> Downwards t -> LeftValue (From t) -> InfoFromLeftValueParts t -> ActualParameterData (To t)
transformOutputActualParameterInActualParameter self fromAbove originalLeftValue fromBelow = OutputActualParameter $ originalLeftValue {
leftValueData = recursivelyTransformedLeftValueData fromBelow,
leftValueSemInf = convert $ leftValueSemInf originalLeftValue
}
upwardsOutputActualParameterInActualParameter :: t -> Downwards t -> LeftValue (From t) -> InfoFromLeftValueParts t -> ActualParameterData (To t) -> Upwards t
upwardsOutputActualParameterInActualParameter self fromAbove originalLeftValue fromBelow transformedLeftValue = foldlist ([(upwardsInfoFromLeftValueData fromBelow)])
transformIntConstant :: t -> Downwards t -> IntConstantType (From t) -> IntConstantType (To t)
transformIntConstant self fromAbove originalIntConstantType = originalIntConstantType {
intConstantSemInf = convert $ intConstantSemInf originalIntConstantType
}
upwardsIntConstant :: t -> Downwards t -> IntConstantType (From t) -> IntConstantType (To t) -> Upwards t
upwardsIntConstant self fromAbove originalIntConstantType transformedIntConstantType = defaultValue
transformFloatConstant :: t -> Downwards t -> FloatConstantType (From t) -> FloatConstantType (To t)
transformFloatConstant self fromAbove originalFloatConstantType = originalFloatConstantType {
floatConstantSemInf = convert $ floatConstantSemInf originalFloatConstantType
}
upwardsFloatConstant :: t -> Downwards t -> FloatConstantType (From t) -> FloatConstantType (To t) -> Upwards t
upwardsFloatConstant self fromAbove originalFloatConstantType transformedFloatConstantType = defaultValue
transformBoolConstant :: t -> Downwards t -> BoolConstantType (From t) -> BoolConstantType (To t)
transformBoolConstant self fromAbove originalBoolConstantType = originalBoolConstantType {
boolConstantSemInf = convert $ boolConstantSemInf originalBoolConstantType
}
upwardsBoolConstant :: t -> Downwards t -> BoolConstantType (From t) -> BoolConstantType (To t) -> Upwards t
upwardsBoolConstant self fromAbove originalBoolConstantType transformedBoolConstantType = defaultValue
transformVariable :: t -> Downwards t -> Variable (From t) -> Variable (To t)
transformVariable self fromAbove originalVariable = originalVariable {
variableSemInf = convert $ variableSemInf originalVariable
}
upwardsVariable :: t -> Downwards t -> Variable (From t) -> Variable (To t) -> Upwards t
upwardsVariable self fromAbove originalVariable transformedVariable = defaultValue
walkProcedure :: Walker t Procedure
walkProcedure selfpointer fromAbove construction = (transformedProcedure, toAbove)
where
toBelow = downwardsProcedure selfpointer fromAbove construction
transformedInParameters = map (walkFormalParameter selfpointer toBelow) $ inParameters construction
transformedOutParameters = map (walkFormalParameter selfpointer toBelow) $ outParameters construction
transformedProcedureBody = (walkBlock selfpointer toBelow) $ procedureBody construction
fromBelow = InfoFromProcedureParts {
recursivelyTransformedInParameters = map fst transformedInParameters,
upwardsInfoFromInParameters = map snd transformedInParameters,
recursivelyTransformedOutParameters = map fst transformedOutParameters,
upwardsInfoFromOutParameters = map snd transformedOutParameters,
recursivelyTransformedProcedureBody = fst transformedProcedureBody,
upwardsInfoFromProcedureBody = snd transformedProcedureBody
}
transformedProcedure = transformProcedure selfpointer fromAbove construction fromBelow
toAbove = upwardsProcedure selfpointer fromAbove construction fromBelow transformedProcedure
walkBlock :: Walker t Block
walkBlock selfpointer fromAbove construction = (transformedBlock, toAbove)
where
toBelow = downwardsBlock selfpointer fromAbove construction
transformedBlockDeclarations = map (walkLocalDeclaration selfpointer toBelow) $ blockDeclarations construction
transformedBlockInstructions = (walkProgram selfpointer toBelow) $ blockInstructions construction
fromBelow = InfoFromBlockParts {
recursivelyTransformedBlockDeclarations = map fst transformedBlockDeclarations,
upwardsInfoFromBlockDeclarations = map snd transformedBlockDeclarations,
recursivelyTransformedBlockInstructions = fst transformedBlockInstructions,
upwardsInfoFromBlockInstructions = snd transformedBlockInstructions
}
transformedBlock = transformBlock selfpointer fromAbove construction fromBelow
toAbove = upwardsBlock selfpointer fromAbove construction fromBelow transformedBlock
walkProgram :: Walker t Program
walkProgram selfpointer fromAbove construction = (transformedProgram, toAbove)
where
toBelow = downwardsProgram selfpointer fromAbove construction
transformedProgramConstruction = case programConstruction construction of
EmptyProgram construction -> (walkEmptyProgramInProgram selfpointer toBelow) construction
PrimitiveProgram construction -> (walkPrimitiveProgramInProgram selfpointer toBelow) construction
SequenceProgram construction -> (walkSequenceProgramInProgram selfpointer toBelow) construction
BranchProgram construction -> (walkBranchProgramInProgram selfpointer toBelow) construction
SequentialLoopProgram construction -> (walkSequentialLoopProgramInProgram selfpointer toBelow) construction
ParallelLoopProgram construction -> (walkParallelLoopProgramInProgram selfpointer toBelow) construction
fromBelow = InfoFromProgramParts {
recursivelyTransformedProgramConstruction = fst transformedProgramConstruction,
upwardsInfoFromProgramConstruction = snd transformedProgramConstruction
}
transformedProgram = transformProgram selfpointer fromAbove construction fromBelow
toAbove = upwardsProgram selfpointer fromAbove construction fromBelow transformedProgram
walkEmptyProgramInProgram :: (TransformationPhase t) => t -> Downwards t -> Empty (From t) -> (ProgramConstruction (To t), Upwards t)
walkEmptyProgramInProgram selfpointer fromAbove construction = (transformedEmpty, toAbove)
where
transformedEmpty = transformEmptyProgramInProgram selfpointer fromAbove construction
toAbove = upwardsEmptyProgramInProgram selfpointer fromAbove construction transformedEmpty
walkPrimitiveProgramInProgram :: (TransformationPhase t) => t -> Downwards t -> Primitive (From t) -> (ProgramConstruction (To t), Upwards t)
walkPrimitiveProgramInProgram selfpointer fromAbove construction = (transformedPrimitive, toAbove)
where
toBelow = downwardsPrimitiveProgramInProgram selfpointer fromAbove construction
transformedPrimitiveInstruction = (walkInstruction selfpointer toBelow) $ primitiveInstruction construction
fromBelow = InfoFromPrimitiveParts {
recursivelyTransformedPrimitiveInstruction = fst transformedPrimitiveInstruction,
upwardsInfoFromPrimitiveInstruction = snd transformedPrimitiveInstruction
}
transformedPrimitive = transformPrimitiveProgramInProgram selfpointer fromAbove construction fromBelow
toAbove = upwardsPrimitiveProgramInProgram selfpointer fromAbove construction fromBelow transformedPrimitive
walkSequenceProgramInProgram :: (TransformationPhase t) => t -> Downwards t -> Sequence (From t) -> (ProgramConstruction (To t), Upwards t)
walkSequenceProgramInProgram selfpointer fromAbove construction = (transformedSequence, toAbove)
where
toBelow = downwardsSequenceProgramInProgram selfpointer fromAbove construction
transformedSequenceProgramList = map (walkProgram selfpointer toBelow) $ sequenceProgramList construction
fromBelow = InfoFromSequenceParts {
recursivelyTransformedSequenceProgramList = map fst transformedSequenceProgramList,
upwardsInfoFromSequenceProgramList = map snd transformedSequenceProgramList
}
transformedSequence = transformSequenceProgramInProgram selfpointer fromAbove construction fromBelow
toAbove = upwardsSequenceProgramInProgram selfpointer fromAbove construction fromBelow transformedSequence
walkBranchProgramInProgram :: (TransformationPhase t) => t -> Downwards t -> Branch (From t) -> (ProgramConstruction (To t), Upwards t)
walkBranchProgramInProgram selfpointer fromAbove construction = (transformedBranch, toAbove)
where
toBelow = downwardsBranchProgramInProgram selfpointer fromAbove construction
transformedBranchConditionVariable = (walkVariable selfpointer toBelow) $ branchConditionVariable construction
transformedThenBlock = (walkBlock selfpointer toBelow) $ thenBlock construction
transformedElseBlock = (walkBlock selfpointer toBelow) $ elseBlock construction
fromBelow = InfoFromBranchParts {
recursivelyTransformedBranchConditionVariable = fst transformedBranchConditionVariable,
upwardsInfoFromBranchConditionVariable = snd transformedBranchConditionVariable,
recursivelyTransformedThenBlock = fst transformedThenBlock,
upwardsInfoFromThenBlock = snd transformedThenBlock,
recursivelyTransformedElseBlock = fst transformedElseBlock,
upwardsInfoFromElseBlock = snd transformedElseBlock
}
transformedBranch = transformBranchProgramInProgram selfpointer fromAbove construction fromBelow
toAbove = upwardsBranchProgramInProgram selfpointer fromAbove construction fromBelow transformedBranch
walkSequentialLoopProgramInProgram :: (TransformationPhase t) => t -> Downwards t -> SequentialLoop (From t) -> (ProgramConstruction (To t), Upwards t)
walkSequentialLoopProgramInProgram selfpointer fromAbove construction = (transformedSequentialLoop, toAbove)
where
toBelow = downwardsSequentialLoopProgramInProgram selfpointer fromAbove construction
transformedSequentialLoopCondition = (walkExpression selfpointer toBelow) $ sequentialLoopCondition construction
transformedConditionCalculation = (walkBlock selfpointer toBelow) $ conditionCalculation construction
transformedSequentialLoopCore = (walkBlock selfpointer toBelow) $ sequentialLoopCore construction
fromBelow = InfoFromSequentialLoopParts {
recursivelyTransformedSequentialLoopCondition = fst transformedSequentialLoopCondition,
upwardsInfoFromSequentialLoopCondition = snd transformedSequentialLoopCondition,
recursivelyTransformedConditionCalculation = fst transformedConditionCalculation,
upwardsInfoFromConditionCalculation = snd transformedConditionCalculation,
recursivelyTransformedSequentialLoopCore = fst transformedSequentialLoopCore,
upwardsInfoFromSequentialLoopCore = snd transformedSequentialLoopCore
}
transformedSequentialLoop = transformSequentialLoopProgramInProgram selfpointer fromAbove construction fromBelow
toAbove = upwardsSequentialLoopProgramInProgram selfpointer fromAbove construction fromBelow transformedSequentialLoop
walkParallelLoopProgramInProgram :: (TransformationPhase t) => t -> Downwards t -> ParallelLoop (From t) -> (ProgramConstruction (To t), Upwards t)
walkParallelLoopProgramInProgram selfpointer fromAbove construction = (transformedParallelLoop, toAbove)
where
toBelow = downwardsParallelLoopProgramInProgram selfpointer fromAbove construction
transformedParallelLoopConditionVariable = (walkVariable selfpointer toBelow) $ parallelLoopConditionVariable construction
transformedNumberOfIterations = (walkExpression selfpointer toBelow) $ numberOfIterations construction
transformedParallelLoopCore = (walkBlock selfpointer toBelow) $ parallelLoopCore construction
fromBelow = InfoFromParallelLoopParts {
recursivelyTransformedParallelLoopConditionVariable = fst transformedParallelLoopConditionVariable,
upwardsInfoFromParallelLoopConditionVariable = snd transformedParallelLoopConditionVariable,
recursivelyTransformedNumberOfIterations = fst transformedNumberOfIterations,
upwardsInfoFromNumberOfIterations = snd transformedNumberOfIterations,
recursivelyTransformedParallelLoopCore = fst transformedParallelLoopCore,
upwardsInfoFromParallelLoopCore = snd transformedParallelLoopCore
}
transformedParallelLoop = transformParallelLoopProgramInProgram selfpointer fromAbove construction fromBelow
toAbove = upwardsParallelLoopProgramInProgram selfpointer fromAbove construction fromBelow transformedParallelLoop
walkFormalParameter :: Walker t FormalParameter
walkFormalParameter selfpointer fromAbove construction = (transformedFormalParameter, toAbove)
where
toBelow = downwardsFormalParameter selfpointer fromAbove construction
transformedFormalParameterVariable = (walkVariable selfpointer toBelow) $ formalParameterVariable construction
fromBelow = InfoFromFormalParameterParts {
recursivelyTransformedFormalParameterVariable = fst transformedFormalParameterVariable,
upwardsInfoFromFormalParameterVariable = snd transformedFormalParameterVariable
}
transformedFormalParameter = transformFormalParameter selfpointer fromAbove construction fromBelow
toAbove = upwardsFormalParameter selfpointer fromAbove construction fromBelow transformedFormalParameter
walkLocalDeclaration :: Walker t LocalDeclaration
walkLocalDeclaration selfpointer fromAbove construction = (transformedLocalDeclaration, toAbove)
where
toBelow = downwardsLocalDeclaration selfpointer fromAbove construction
transformedLocalVariable = (walkVariable selfpointer toBelow) $ localVariable construction
transformedLocalInitValue = case localInitValue construction of
Nothing -> (Nothing, Nothing)
Just justLocalInitValue -> (Just (fst transformedJustLocalInitValue), Just (snd transformedJustLocalInitValue))
where transformedJustLocalInitValue = (walkExpression selfpointer toBelow) $ justLocalInitValue
fromBelow = InfoFromLocalDeclarationParts {
recursivelyTransformedLocalVariable = fst transformedLocalVariable,
upwardsInfoFromLocalVariable = snd transformedLocalVariable,
recursivelyTransformedLocalInitValue = fst transformedLocalInitValue,
upwardsInfoFromLocalInitValue = snd transformedLocalInitValue
}
transformedLocalDeclaration = transformLocalDeclaration selfpointer fromAbove construction fromBelow
toAbove = upwardsLocalDeclaration selfpointer fromAbove construction fromBelow transformedLocalDeclaration
walkExpression :: Walker t Expression
walkExpression selfpointer fromAbove construction = (transformedExpression, toAbove)
where
toBelow = downwardsExpression selfpointer fromAbove construction
transformedExpressionData = case expressionData construction of
LeftValueExpression construction -> (walkLeftValueExpressionInExpression selfpointer toBelow) construction
ConstantExpression construction -> (walkConstantExpressionInExpression selfpointer toBelow) construction
FunctionCallExpression construction -> (walkFunctionCallExpressionInExpression selfpointer toBelow) construction
fromBelow = InfoFromExpressionParts {
recursivelyTransformedExpressionData = fst transformedExpressionData,
upwardsInfoFromExpressionData = snd transformedExpressionData
}
transformedExpression = transformExpression selfpointer fromAbove construction fromBelow
toAbove = upwardsExpression selfpointer fromAbove construction fromBelow transformedExpression
walkLeftValueExpressionInExpression :: (TransformationPhase t) => t -> Downwards t -> LeftValue (From t) -> (ExpressionData (To t), Upwards t)
walkLeftValueExpressionInExpression selfpointer fromAbove construction = (transformedLeftValue, toAbove)
where
toBelow = downwardsLeftValueExpressionInExpression selfpointer fromAbove construction
transformedLeftValueData = case leftValueData construction of
VariableLeftValue construction -> (walkVariableLeftValueInLeftValue selfpointer toBelow) construction
ArrayElemReferenceLeftValue construction -> (walkArrayElemReferenceLeftValueInLeftValue selfpointer toBelow) construction
fromBelow = InfoFromLeftValueParts {
recursivelyTransformedLeftValueData = fst transformedLeftValueData,
upwardsInfoFromLeftValueData = snd transformedLeftValueData
}
transformedLeftValue = transformLeftValueExpressionInExpression selfpointer fromAbove construction fromBelow
toAbove = upwardsLeftValueExpressionInExpression selfpointer fromAbove construction fromBelow transformedLeftValue
walkConstantExpressionInExpression :: (TransformationPhase t) => t -> Downwards t -> Constant (From t) -> (ExpressionData (To t), Upwards t)
walkConstantExpressionInExpression selfpointer fromAbove construction = (transformedConstant, toAbove)
where
toBelow = downwardsConstantExpressionInExpression selfpointer fromAbove construction
transformedConstantData = case constantData construction of
IntConstant construction -> (walkIntConstantInConstant selfpointer toBelow) construction
FloatConstant construction -> (walkFloatConstantInConstant selfpointer toBelow) construction
BoolConstant construction -> (walkBoolConstantInConstant selfpointer toBelow) construction
ArrayConstant construction -> (walkArrayConstantInConstant selfpointer toBelow) construction
fromBelow = InfoFromConstantParts {
recursivelyTransformedConstantData = fst transformedConstantData,
upwardsInfoFromConstantData = snd transformedConstantData
}
transformedConstant = transformConstantExpressionInExpression selfpointer fromAbove construction fromBelow
toAbove = upwardsConstantExpressionInExpression selfpointer fromAbove construction fromBelow transformedConstant
walkFunctionCallExpressionInExpression :: (TransformationPhase t) => t -> Downwards t -> FunctionCall (From t) -> (ExpressionData (To t), Upwards t)
walkFunctionCallExpressionInExpression selfpointer fromAbove construction = (transformedFunctionCall, toAbove)
where
toBelow = downwardsFunctionCallExpressionInExpression selfpointer fromAbove construction
transformedActualParametersOfFunctionToCall = map (walkExpression selfpointer toBelow) $ actualParametersOfFunctionToCall construction
fromBelow = InfoFromFunctionCallParts {
recursivelyTransformedActualParametersOfFunctionToCall = map fst transformedActualParametersOfFunctionToCall,
upwardsInfoFromActualParametersOfFunctionToCall = map snd transformedActualParametersOfFunctionToCall
}
transformedFunctionCall = transformFunctionCallExpressionInExpression selfpointer fromAbove construction fromBelow
toAbove = upwardsFunctionCallExpressionInExpression selfpointer fromAbove construction fromBelow transformedFunctionCall
walkConstant :: Walker t Constant
walkConstant selfpointer fromAbove construction = (transformedConstant, toAbove)
where
toBelow = downwardsConstant selfpointer fromAbove construction
transformedConstantData = case constantData construction of
IntConstant construction -> (walkIntConstantInConstant selfpointer toBelow) construction
FloatConstant construction -> (walkFloatConstantInConstant selfpointer toBelow) construction
BoolConstant construction -> (walkBoolConstantInConstant selfpointer toBelow) construction
ArrayConstant construction -> (walkArrayConstantInConstant selfpointer toBelow) construction
fromBelow = InfoFromConstantParts {
recursivelyTransformedConstantData = fst transformedConstantData,
upwardsInfoFromConstantData = snd transformedConstantData
}
transformedConstant = transformConstant selfpointer fromAbove construction fromBelow
toAbove = upwardsConstant selfpointer fromAbove construction fromBelow transformedConstant
walkIntConstantInConstant :: (TransformationPhase t) => t -> Downwards t -> IntConstantType (From t) -> (ConstantData (To t), Upwards t)
walkIntConstantInConstant selfpointer fromAbove construction = (transformedIntConstantType, toAbove)
where
transformedIntConstantType = transformIntConstantInConstant selfpointer fromAbove construction
toAbove = upwardsIntConstantInConstant selfpointer fromAbove construction transformedIntConstantType
walkFloatConstantInConstant :: (TransformationPhase t) => t -> Downwards t -> FloatConstantType (From t) -> (ConstantData (To t), Upwards t)
walkFloatConstantInConstant selfpointer fromAbove construction = (transformedFloatConstantType, toAbove)
where
transformedFloatConstantType = transformFloatConstantInConstant selfpointer fromAbove construction
toAbove = upwardsFloatConstantInConstant selfpointer fromAbove construction transformedFloatConstantType
walkBoolConstantInConstant :: (TransformationPhase t) => t -> Downwards t -> BoolConstantType (From t) -> (ConstantData (To t), Upwards t)
walkBoolConstantInConstant selfpointer fromAbove construction = (transformedBoolConstantType, toAbove)
where
transformedBoolConstantType = transformBoolConstantInConstant selfpointer fromAbove construction
toAbove = upwardsBoolConstantInConstant selfpointer fromAbove construction transformedBoolConstantType
walkArrayConstantInConstant :: (TransformationPhase t) => t -> Downwards t -> ArrayConstantType (From t) -> (ConstantData (To t), Upwards t)
walkArrayConstantInConstant selfpointer fromAbove construction = (transformedArrayConstantType, toAbove)
where
toBelow = downwardsArrayConstantInConstant selfpointer fromAbove construction
transformedArrayConstantValue = map (walkConstant selfpointer toBelow) $ arrayConstantValue construction
fromBelow = InfoFromArrayConstantParts {
recursivelyTransformedArrayConstantValue = map fst transformedArrayConstantValue,
upwardsInfoFromArrayConstantValue = map snd transformedArrayConstantValue
}
transformedArrayConstantType = transformArrayConstantInConstant selfpointer fromAbove construction fromBelow
toAbove = upwardsArrayConstantInConstant selfpointer fromAbove construction fromBelow transformedArrayConstantType
walkLeftValue :: Walker t LeftValue
walkLeftValue selfpointer fromAbove construction = (transformedLeftValue, toAbove)
where
toBelow = downwardsLeftValue selfpointer fromAbove construction
transformedLeftValueData = case leftValueData construction of
VariableLeftValue construction -> (walkVariableLeftValueInLeftValue selfpointer toBelow) construction
ArrayElemReferenceLeftValue construction -> (walkArrayElemReferenceLeftValueInLeftValue selfpointer toBelow) construction
fromBelow = InfoFromLeftValueParts {
recursivelyTransformedLeftValueData = fst transformedLeftValueData,
upwardsInfoFromLeftValueData = snd transformedLeftValueData
}
transformedLeftValue = transformLeftValue selfpointer fromAbove construction fromBelow
toAbove = upwardsLeftValue selfpointer fromAbove construction fromBelow transformedLeftValue
walkVariableLeftValueInLeftValue :: (TransformationPhase t) => t -> Downwards t -> Variable (From t) -> (LeftValueData (To t), Upwards t)
walkVariableLeftValueInLeftValue selfpointer fromAbove construction = (transformedVariable, toAbove)
where
transformedVariable = transformVariableLeftValueInLeftValue selfpointer fromAbove construction
toAbove = upwardsVariableLeftValueInLeftValue selfpointer fromAbove construction transformedVariable
walkArrayElemReferenceLeftValueInLeftValue :: (TransformationPhase t) => t -> Downwards t -> ArrayElemReference (From t) -> (LeftValueData (To t), Upwards t)
walkArrayElemReferenceLeftValueInLeftValue selfpointer fromAbove construction = (transformedArrayElemReference, toAbove)
where
toBelow = downwardsArrayElemReferenceLeftValueInLeftValue selfpointer fromAbove construction
transformedArrayName = (walkLeftValue selfpointer toBelow) $ arrayName construction
transformedArrayIndex = (walkExpression selfpointer toBelow) $ arrayIndex construction
fromBelow = InfoFromArrayElemReferenceParts {
recursivelyTransformedArrayName = fst transformedArrayName,
upwardsInfoFromArrayName = snd transformedArrayName,
recursivelyTransformedArrayIndex = fst transformedArrayIndex,
upwardsInfoFromArrayIndex = snd transformedArrayIndex
}
transformedArrayElemReference = transformArrayElemReferenceLeftValueInLeftValue selfpointer fromAbove construction fromBelow
toAbove = upwardsArrayElemReferenceLeftValueInLeftValue selfpointer fromAbove construction fromBelow transformedArrayElemReference
walkInstruction :: Walker t Instruction
walkInstruction selfpointer fromAbove construction = (transformedInstruction, toAbove)
where
toBelow = downwardsInstruction selfpointer fromAbove construction
transformedInstructionData = case instructionData construction of
AssignmentInstruction construction -> (walkAssignmentInstructionInInstruction selfpointer toBelow) construction
ProcedureCallInstruction construction -> (walkProcedureCallInstructionInInstruction selfpointer toBelow) construction
fromBelow = InfoFromInstructionParts {
recursivelyTransformedInstructionData = fst transformedInstructionData,
upwardsInfoFromInstructionData = snd transformedInstructionData
}
transformedInstruction = transformInstruction selfpointer fromAbove construction fromBelow
toAbove = upwardsInstruction selfpointer fromAbove construction fromBelow transformedInstruction
walkAssignmentInstructionInInstruction :: (TransformationPhase t) => t -> Downwards t -> Assignment (From t) -> (InstructionData (To t), Upwards t)
walkAssignmentInstructionInInstruction selfpointer fromAbove construction = (transformedAssignment, toAbove)
where
toBelow = downwardsAssignmentInstructionInInstruction selfpointer fromAbove construction
transformedAssignmentLhs = (walkLeftValue selfpointer toBelow) $ assignmentLhs construction
transformedAssignmentRhs = (walkExpression selfpointer toBelow) $ assignmentRhs construction
fromBelow = InfoFromAssignmentParts {
recursivelyTransformedAssignmentLhs = fst transformedAssignmentLhs,
upwardsInfoFromAssignmentLhs = snd transformedAssignmentLhs,
recursivelyTransformedAssignmentRhs = fst transformedAssignmentRhs,
upwardsInfoFromAssignmentRhs = snd transformedAssignmentRhs
}
transformedAssignment = transformAssignmentInstructionInInstruction selfpointer fromAbove construction fromBelow
toAbove = upwardsAssignmentInstructionInInstruction selfpointer fromAbove construction fromBelow transformedAssignment
walkProcedureCallInstructionInInstruction :: (TransformationPhase t) => t -> Downwards t -> ProcedureCall (From t) -> (InstructionData (To t), Upwards t)
walkProcedureCallInstructionInInstruction selfpointer fromAbove construction = (transformedProcedureCall, toAbove)
where
toBelow = downwardsProcedureCallInstructionInInstruction selfpointer fromAbove construction
transformedActualParametersOfProcedureToCall = map (walkActualParameter selfpointer toBelow) $ actualParametersOfProcedureToCall construction
fromBelow = InfoFromProcedureCallParts {
recursivelyTransformedActualParametersOfProcedureToCall = map fst transformedActualParametersOfProcedureToCall,
upwardsInfoFromActualParametersOfProcedureToCall = map snd transformedActualParametersOfProcedureToCall
}
transformedProcedureCall = transformProcedureCallInstructionInInstruction selfpointer fromAbove construction fromBelow
toAbove = upwardsProcedureCallInstructionInInstruction selfpointer fromAbove construction fromBelow transformedProcedureCall
walkActualParameter :: Walker t ActualParameter
walkActualParameter selfpointer fromAbove construction = (transformedActualParameter, toAbove)
where
toBelow = downwardsActualParameter selfpointer fromAbove construction
transformedActualParameterData = case actualParameterData construction of
InputActualParameter construction -> (walkInputActualParameterInActualParameter selfpointer toBelow) construction
OutputActualParameter construction -> (walkOutputActualParameterInActualParameter selfpointer toBelow) construction
fromBelow = InfoFromActualParameterParts {
recursivelyTransformedActualParameterData = fst transformedActualParameterData,
upwardsInfoFromActualParameterData = snd transformedActualParameterData
}
transformedActualParameter = transformActualParameter selfpointer fromAbove construction fromBelow
toAbove = upwardsActualParameter selfpointer fromAbove construction fromBelow transformedActualParameter
walkInputActualParameterInActualParameter :: (TransformationPhase t) => t -> Downwards t -> Expression (From t) -> (ActualParameterData (To t), Upwards t)
walkInputActualParameterInActualParameter selfpointer fromAbove construction = (transformedExpression, toAbove)
where
toBelow = downwardsInputActualParameterInActualParameter selfpointer fromAbove construction
transformedExpressionData = case expressionData construction of
LeftValueExpression construction -> (walkLeftValueExpressionInExpression selfpointer toBelow) construction
ConstantExpression construction -> (walkConstantExpressionInExpression selfpointer toBelow) construction
FunctionCallExpression construction -> (walkFunctionCallExpressionInExpression selfpointer toBelow) construction
fromBelow = InfoFromExpressionParts {
recursivelyTransformedExpressionData = fst transformedExpressionData,
upwardsInfoFromExpressionData = snd transformedExpressionData
}
transformedExpression = transformInputActualParameterInActualParameter selfpointer fromAbove construction fromBelow
toAbove = upwardsInputActualParameterInActualParameter selfpointer fromAbove construction fromBelow transformedExpression
walkOutputActualParameterInActualParameter :: (TransformationPhase t) => t -> Downwards t -> LeftValue (From t) -> (ActualParameterData (To t), Upwards t)
walkOutputActualParameterInActualParameter selfpointer fromAbove construction = (transformedLeftValue, toAbove)
where
toBelow = downwardsOutputActualParameterInActualParameter selfpointer fromAbove construction
transformedLeftValueData = case leftValueData construction of
VariableLeftValue construction -> (walkVariableLeftValueInLeftValue selfpointer toBelow) construction
ArrayElemReferenceLeftValue construction -> (walkArrayElemReferenceLeftValueInLeftValue selfpointer toBelow) construction
fromBelow = InfoFromLeftValueParts {
recursivelyTransformedLeftValueData = fst transformedLeftValueData,
upwardsInfoFromLeftValueData = snd transformedLeftValueData
}
transformedLeftValue = transformOutputActualParameterInActualParameter selfpointer fromAbove construction fromBelow
toAbove = upwardsOutputActualParameterInActualParameter selfpointer fromAbove construction fromBelow transformedLeftValue
walkVariable :: Walker t Variable
walkVariable selfpointer fromAbove construction = (transformedVariable, toAbove)
where
transformedVariable = transformVariable selfpointer fromAbove construction
toAbove = upwardsVariable selfpointer fromAbove construction transformedVariable
data (TransformationPhase t) => InfoFromProcedureParts t = InfoFromProcedureParts {
recursivelyTransformedInParameters :: [FormalParameter (To t)],
upwardsInfoFromInParameters :: [Upwards t],
recursivelyTransformedOutParameters :: [FormalParameter (To t)],
upwardsInfoFromOutParameters :: [Upwards t],
recursivelyTransformedProcedureBody :: Block (To t),
upwardsInfoFromProcedureBody :: Upwards t
}
data (TransformationPhase t) => InfoFromBlockParts t = InfoFromBlockParts {
recursivelyTransformedBlockDeclarations :: [LocalDeclaration (To t)],
upwardsInfoFromBlockDeclarations :: [Upwards t],
recursivelyTransformedBlockInstructions :: Program (To t),
upwardsInfoFromBlockInstructions :: Upwards t
}
data (TransformationPhase t) => InfoFromProgramParts t = InfoFromProgramParts {
recursivelyTransformedProgramConstruction :: ProgramConstruction (To t),
upwardsInfoFromProgramConstruction :: Upwards t
}
data (TransformationPhase t) => InfoFromPrimitiveParts t = InfoFromPrimitiveParts {
recursivelyTransformedPrimitiveInstruction :: Instruction (To t),
upwardsInfoFromPrimitiveInstruction :: Upwards t
}
data (TransformationPhase t) => InfoFromSequenceParts t = InfoFromSequenceParts {
recursivelyTransformedSequenceProgramList :: [Program (To t)],
upwardsInfoFromSequenceProgramList :: [Upwards t]
}
data (TransformationPhase t) => InfoFromBranchParts t = InfoFromBranchParts {
recursivelyTransformedBranchConditionVariable :: Variable (To t),
upwardsInfoFromBranchConditionVariable :: Upwards t,
recursivelyTransformedThenBlock :: Block (To t),
upwardsInfoFromThenBlock :: Upwards t,
recursivelyTransformedElseBlock :: Block (To t),
upwardsInfoFromElseBlock :: Upwards t
}
data (TransformationPhase t) => InfoFromSequentialLoopParts t = InfoFromSequentialLoopParts {
recursivelyTransformedSequentialLoopCondition :: Expression (To t),
upwardsInfoFromSequentialLoopCondition :: Upwards t,
recursivelyTransformedConditionCalculation :: Block (To t),
upwardsInfoFromConditionCalculation :: Upwards t,
recursivelyTransformedSequentialLoopCore :: Block (To t),
upwardsInfoFromSequentialLoopCore :: Upwards t
}
data (TransformationPhase t) => InfoFromParallelLoopParts t = InfoFromParallelLoopParts {
recursivelyTransformedParallelLoopConditionVariable :: Variable (To t),
upwardsInfoFromParallelLoopConditionVariable :: Upwards t,
recursivelyTransformedNumberOfIterations :: Expression (To t),
upwardsInfoFromNumberOfIterations :: Upwards t,
recursivelyTransformedParallelLoopCore :: Block (To t),
upwardsInfoFromParallelLoopCore :: Upwards t
}
data (TransformationPhase t) => InfoFromFormalParameterParts t = InfoFromFormalParameterParts {
recursivelyTransformedFormalParameterVariable :: Variable (To t),
upwardsInfoFromFormalParameterVariable :: Upwards t
}
data (TransformationPhase t) => InfoFromLocalDeclarationParts t = InfoFromLocalDeclarationParts {
recursivelyTransformedLocalVariable :: Variable (To t),
upwardsInfoFromLocalVariable :: Upwards t,
recursivelyTransformedLocalInitValue :: Maybe (Expression (To t)),
upwardsInfoFromLocalInitValue :: Maybe (Upwards t)
}
data (TransformationPhase t) => InfoFromExpressionParts t = InfoFromExpressionParts {
recursivelyTransformedExpressionData :: ExpressionData (To t),
upwardsInfoFromExpressionData :: Upwards t
}
data (TransformationPhase t) => InfoFromConstantParts t = InfoFromConstantParts {
recursivelyTransformedConstantData :: ConstantData (To t),
upwardsInfoFromConstantData :: Upwards t
}
data (TransformationPhase t) => InfoFromFunctionCallParts t = InfoFromFunctionCallParts {
recursivelyTransformedActualParametersOfFunctionToCall :: [Expression (To t)],
upwardsInfoFromActualParametersOfFunctionToCall :: [Upwards t]
}
data (TransformationPhase t) => InfoFromLeftValueParts t = InfoFromLeftValueParts {
recursivelyTransformedLeftValueData :: LeftValueData (To t),
upwardsInfoFromLeftValueData :: Upwards t
}
data (TransformationPhase t) => InfoFromArrayElemReferenceParts t = InfoFromArrayElemReferenceParts {
recursivelyTransformedArrayName :: LeftValue (To t),
upwardsInfoFromArrayName :: Upwards t,
recursivelyTransformedArrayIndex :: Expression (To t),
upwardsInfoFromArrayIndex :: Upwards t
}
data (TransformationPhase t) => InfoFromInstructionParts t = InfoFromInstructionParts {
recursivelyTransformedInstructionData :: InstructionData (To t),
upwardsInfoFromInstructionData :: Upwards t
}
data (TransformationPhase t) => InfoFromAssignmentParts t = InfoFromAssignmentParts {
recursivelyTransformedAssignmentLhs :: LeftValue (To t),
upwardsInfoFromAssignmentLhs :: Upwards t,
recursivelyTransformedAssignmentRhs :: Expression (To t),
upwardsInfoFromAssignmentRhs :: Upwards t
}
data (TransformationPhase t) => InfoFromProcedureCallParts t = InfoFromProcedureCallParts {
recursivelyTransformedActualParametersOfProcedureToCall :: [ActualParameter (To t)],
upwardsInfoFromActualParametersOfProcedureToCall :: [Upwards t]
}
data (TransformationPhase t) => InfoFromActualParameterParts t = InfoFromActualParameterParts {
recursivelyTransformedActualParameterData :: ActualParameterData (To t),
upwardsInfoFromActualParameterData :: Upwards t
}
data (TransformationPhase t) => InfoFromArrayConstantParts t = InfoFromArrayConstantParts {
recursivelyTransformedArrayConstantValue :: [Constant (To t)],
upwardsInfoFromArrayConstantValue :: [Upwards t]
}