Commit 905bcf96 authored by clean's avatar clean
Browse files

labels global function names without ";n" extension

parent b49450ad
......@@ -20,6 +20,15 @@ import RWSDebug
:: Backender :== *BackEnd -> *BackEnd
// foldr` :: (.a -> .(.b -> .b)) .b ![.a] -> .b // op e0 (op e1(...(op r e##)...)
foldr` op r l :== foldr l
where
foldr [] = r
foldr [a:x] = op a (foldr x)
flip` f x y
:== f y x
/* +++
:: *BackEndState = {bes_backEnd :: BackEnd, bes_varHeap :: *VarHeap}
......@@ -32,7 +41,7 @@ accVarHeap f beState
= f beState.bes_varHeap
= (result, {beState & bes_varHeap = varHeap})
*/
appBackEnd f beState :== f beState
appBackEnd f :== f
accVarHeap f beState :== f beState
beFunction0 f
......@@ -231,8 +240,8 @@ notYetImplementedExpr
= (BasicExpr (BVS "\"error in compiler (something was not implemented by lazy Ronny)\"") BT_Int)
backEndConvertModules :: PredefinedSymbols FrontEndSyntaxTree VarHeap *BackEnd -> *BackEnd
backEndConvertModules predefs {fe_icl = fe_icl =: {icl_name, icl_functions, icl_common, icl_imported_objects}, fe_components, fe_dcls, fe_arrayInstances, fe_dclIclConversions, fe_iclDclConversions} varHeap backEnd
// sanity check ...
backEndConvertModules predefs {fe_icl = fe_icl =: {icl_name, icl_functions, icl_common, icl_imported_objects}, fe_components, fe_dcls, fe_arrayInstances, fe_dclIclConversions, fe_iclDclConversions, fe_globalFunctions} varHeap backEnd
// sanity check ...
// | cIclModIndex <> kIclModuleIndex || cPredefinedModuleIndex <> kPredefinedModuleIndex
// = undef <<- "backendconvert, backEndConvertModules: module index mismatch"
// ... sanity check
......@@ -245,9 +254,9 @@ backEndConvertModules predefs {fe_icl = fe_icl =: {icl_name, icl_functions, icl_
# backEnd
= abort "front end abort" backEnd
*/
#! backEnd
# backEnd
= BEDeclareModules (size fe_dcls) backEnd
#! backEnd
# backEnd
= predefineSymbols fe_dcls.[cPredefinedModuleIndex] predefs backEnd
# currentDcl
......@@ -277,32 +286,32 @@ backEndConvertModules predefs {fe_icl = fe_icl =: {icl_name, icl_functions, icl_
, (rstypes, types)
)
*/
#! backEnd
# backEnd
= declareCurrentDclModule fe_icl fe_dcls.[cIclModIndex] (backEnd -*-> "declareCurrentDclModule")
#! backEnd
# backEnd
= declareOtherDclModules fe_dcls (backEnd -*-> "declareOtherDclModules")
#! backEnd
# backEnd
= defineDclModule varHeap cIclModIndex fe_dcls.[cIclModIndex] (backEnd -*-> "defineDclModule(cIclMoIndex)")
#! backEnd
# backEnd
= reshuffleTypes (size icl_common.com_type_defs) typeConversions (backEnd -*-> "reshuffleTypes")
#! backEnd
# backEnd
= defineOtherDclModules fe_dcls varHeap (backEnd -*-> "defineOtherDclModules")
#! backEnd
# backEnd
= BEDeclareIclModule icl_name.id_name (size icl_functions) (size icl_common.com_type_defs) (size icl_common.com_cons_defs) (size icl_common.com_selector_defs) (backEnd -*-> "BEDeclareIclModule")
#! backEnd
= declareFunctionSymbols icl_functions (getConversions fe_iclDclConversions) functionIndices (backEnd -*-> "declareFunctionSymbols")
# backEnd
= declareFunctionSymbols icl_functions (getConversions fe_iclDclConversions) functionIndices fe_globalFunctions (backEnd -*-> "declareFunctionSymbols")
with
getConversions :: (Optional {#Int}) -> {#Int}
getConversions No
= {}
getConversions (Yes conversions)
= conversions
#! backEnd
# backEnd
= declare cIclModIndex varHeap icl_common (backEnd -*-> "declare (cIclModIndex)")
#! backEnd
# backEnd
= declareArrayInstances fe_arrayInstances icl_functions (backEnd -*-> "declareArrayInstances")
#! backEnd
# backEnd
= adjustArrayFunctions predefs fe_arrayInstances icl_functions fe_dcls varHeap (backEnd -*-> "adjustArrayFunctions")
#! (rules, backEnd)
// MW was: = convertRules [(index, icl_functions.[index]) \\ (_, index) <- functionIndices] varHeap (backEnd -*-> "convertRules")
......@@ -311,12 +320,12 @@ backEndConvertModules predefs {fe_icl = fe_icl =: {icl_name, icl_functions, icl_
varHeap (backEnd -*-> "convertRules")
#! backEnd
= BEDefineRules rules (backEnd -*-> "BEDefineRules")
#! backEnd
# backEnd
= beDefineImportedObjsAndLibs
(convertStrings [imported.io_name \\ imported <- icl_imported_objects | not imported.io_is_library])
(convertStrings [imported.io_name \\ imported <- icl_imported_objects | imported.io_is_library])
(backEnd -*-> "beDefineImportedObjsAndLibs")
#! backEnd
# backEnd
= markExports fe_dcls.[cIclModIndex] dcl_common.com_class_defs dcl_common.com_type_defs icl_common.com_class_defs icl_common.com_type_defs fe_dclIclConversions (backEnd -*-> "markExports")
with
dcl_common
......@@ -364,9 +373,9 @@ defineOtherDclModule varHeap moduleIndex dclModule
= defineDclModule varHeap moduleIndex dclModule
defineDclModule :: VarHeap ModuleIndex DclModule -> Backender
defineDclModule varHeap moduleIndex {dcl_name, dcl_common, dcl_functions, dcl_is_system}
defineDclModule varHeap moduleIndex {dcl_name, dcl_common, dcl_instances, dcl_functions, dcl_is_system}
= declare moduleIndex varHeap dcl_common
o` declareFunTypes moduleIndex dcl_functions varHeap
o` declareFunTypes moduleIndex dcl_functions dcl_instances.ir_from varHeap
// move types from their dcl to icl positions
......@@ -419,7 +428,7 @@ non trivial changes are indicated with a comment
instance declareVars [a] | declareVars a where
declareVars :: [a] VarHeap -> Backender | declareVars a
declareVars list varHeap
= foldState (flip declareVars varHeap) list
= foldState (flip` declareVars varHeap) list
instance declareVars (Ptr VarInfo) where
declareVars varInfoPtr varHeap
......@@ -582,13 +591,22 @@ instance declare {#a} | declareWithIndex a & Array {#} a where
declare moduleIndex varHeap array
= foldStateWithIndexA (\i -> declareWithIndex i moduleIndex varHeap) array
declareFunctionSymbols :: {#FunDef} {#Int} [(Int, Int)] *BackEnd -> *BackEnd
declareFunctionSymbols functions iclDclConversions functionIndices backEnd
= foldr (declare iclDclConversions) backEnd [(functionIndex, componentIndex, functions.[functionIndex]) \\ (componentIndex, functionIndex) <- functionIndices]
declareFunctionSymbols :: {#FunDef} {#Int} [(Int, Int)] IndexRange *BackEnd -> *BackEnd
declareFunctionSymbols functions iclDclConversions functionIndices globalFunctions backEnd
= foldr` (declare iclDclConversions) backEnd [(functionIndex, componentIndex, functions.[functionIndex]) \\ (componentIndex, functionIndex) <- functionIndices]
where
declare :: {#Int} (Int, Int, FunDef) *BackEnd -> *BackEnd
declare iclDclConversions (functionIndex, componentIndex, function) backEnd
= BEDeclareFunction (function.fun_symb.id_name +++ ";" +++ toString iclDclConversions.[functionIndex]) function.fun_arity functionIndex componentIndex backEnd
= BEDeclareFunction
(functionName function.fun_symb.id_name functionIndex iclDclConversions globalFunctions)
function.fun_arity functionIndex componentIndex backEnd
where
functionName :: {#Char} Int {#Int} IndexRange -> {#Char}
functionName name functionIndex iclDclConversions {ir_from, ir_to}
| functionIndex >= ir_to || functionIndex < ir_from
= (name +++ ";" +++ toString iclDclConversions.[functionIndex])
// otherwise
= name
// move to backendsupport
foldStateWithIndexRangeA function frm to array
......@@ -621,18 +639,25 @@ instance declareWithIndex (TypeDef a) where
declareWithIndex typeIndex moduleIndex _ {td_name}
= BEDeclareType typeIndex moduleIndex td_name.id_name
declareFunTypes :: ModuleIndex {#FunType} VarHeap -> Backender
declareFunTypes moduleIndex funTypes varHeap
= foldStateWithIndexA (declareFunType moduleIndex varHeap) funTypes
declareFunTypes :: ModuleIndex {#FunType} Int VarHeap -> Backender
declareFunTypes moduleIndex funTypes nrOfDclFunctions varHeap
= foldStateWithIndexA (declareFunType moduleIndex varHeap nrOfDclFunctions) funTypes
declareFunType :: ModuleIndex VarHeap Index FunType -> Backender
declareFunType moduleIndex varHeap functionIndex {ft_symb, ft_type_ptr}
declareFunType :: ModuleIndex VarHeap Index Int FunType -> Backender
declareFunType moduleIndex varHeap nrOfDclFunctions functionIndex {ft_symb, ft_type_ptr}
= case (sreadPtr ft_type_ptr varHeap) of
VI_ExpandedType expandedType
-> beDeclareRuleType functionIndex moduleIndex (ft_symb.id_name +++ ";" +++ toString functionIndex)
-> beDeclareRuleType functionIndex moduleIndex (functionName ft_symb.id_name functionIndex nrOfDclFunctions)
o` beDefineRuleType functionIndex moduleIndex (convertTypeAlt functionIndex moduleIndex expandedType)
_
-> identity
where
functionName :: {#Char} Int Int -> {#Char}
functionName name functionIndex nrOfDclFunctions
| functionIndex < nrOfDclFunctions
= name
// otherwise
= name +++ ";" +++ toString functionIndex
currentModuleTypeConversions :: {#ClassDef} {#ClassDef} (Optional ConversionTable) -> {#Int}
currentModuleTypeConversions iclClasses dclClasses (Yes conversionTable)
......@@ -703,7 +728,7 @@ convertTypeLhs moduleIndex typeIndex args
convertTypeVars :: [ATypeVar] -> BEMonad BETypeVarListP
convertTypeVars typeVars
= foldr (beTypeVars o convertTypeVar) beNoTypeVars typeVars
= foldr` (beTypeVars o convertTypeVar) beNoTypeVars typeVars
convertTypeVar :: ATypeVar -> BEMonad BETypeVarP
convertTypeVar typeVar
......@@ -745,7 +770,7 @@ defineType _ _ _ _ _ _ be
convertConstructors :: Int {#Char} ModuleIndex {#ConsDef} [DefinedSymbol] VarHeap -> BEMonad BEConstructorListP
convertConstructors typeIndex typeName moduleIndex constructors symbols varHeap
= foldr (beConstructors o convertConstructor typeIndex typeName moduleIndex constructors varHeap) beNoConstructors symbols
= foldr` (beConstructors o convertConstructor typeIndex typeName moduleIndex constructors varHeap) beNoConstructors symbols
convertConstructor :: Int {#Char} ModuleIndex {#ConsDef} VarHeap DefinedSymbol -> BEMonad BEConstructorListP
convertConstructor typeIndex typeName moduleIndex constructorDefs varHeap {ds_index}
......@@ -915,8 +940,8 @@ adjustArrayFunctions predefs arrayInstancesRange functions dcls varHeap
/*
convertRules :: [(Int, FunDef)] VarHeap -> BEMonad BEImpRuleP
convertRules rules varHeap
// = foldr (beRules o flip convertRule varHeap) beNoRules rules
= foldl (flip beRules) beNoRules (map (flip convertRule varHeap) rules)
// = foldr` (beRules o flip` convertRule varHeap) beNoRules rules
= foldl (flip` beRules) beNoRules (map (flip` convertRule varHeap) rules)
*/
/* MW was
......@@ -928,7 +953,7 @@ convertRules aliasDummyId rules varHeap be
# (null, be)
= BENoRules be
= convert rules varHeap null be
// = foldr (beRules o flip convertRule varHeap) beNoRules rules
// = foldr` (beRules o flip` convertRule varHeap) beNoRules rules
where
convert :: [(Int, FunDef)] VarHeap BEImpRuleP *BackEnd -> (BEImpRuleP, *BackEnd)
convert [] _ rulesP be
......@@ -1055,7 +1080,7 @@ consVariableToType (TempQCV varId)
convertTypeArgs :: [AType] -> BEMonad BETypeArgP
convertTypeArgs args
= foldr (beTypeArgs o convertAnnotTypeNode) beNoTypeArgs args
= foldr` (beTypeArgs o convertAnnotTypeNode) beNoTypeArgs args
/* MW was
convertBackendBodies :: Int Int [BackendBody] VarHeap -> BEMonad BERuleAltP
......@@ -1108,11 +1133,11 @@ convertBackendBody functionIndex lineNumber aliasDummyId body=:{bb_args, bb_rhs}
convertStrings :: [{#Char}] -> BEMonad BEStringListP
convertStrings strings
= foldr (beStrings o beString) beNoStrings strings
= foldr` (beStrings o beString) beNoStrings strings
convertCodeParameters :: (CodeBinding a) VarHeap -> BEMonad BECodeParameterP | varInfoPtr a
convertCodeParameters codeParameters varHeap
= foldr (beCodeParameters o flip convertCodeParameter varHeap) beNoCodeParameters codeParameters
= foldr` (beCodeParameters o flip` convertCodeParameter varHeap) beNoCodeParameters codeParameters
class varInfoPtr a :: a -> VarInfoPtr
......@@ -1138,7 +1163,7 @@ convertBackendLhs functionIndex patterns varHeap
convertPatterns :: [FunctionPattern] VarHeap -> BEMonad BEArgP
convertPatterns patterns varHeap
= foldr (beArgs o flip convertPattern varHeap) beNoArgs patterns
= foldr` (beArgs o flip` convertPattern varHeap) beNoArgs patterns
convertPattern :: FunctionPattern VarHeap -> BEMonad BENodeP
convertPattern (FP_Variable freeVar) varHeap
......@@ -1162,7 +1187,7 @@ convertFreeVarPattern freeVar varHeap
convertLhsArgs :: [FreeVar] VarHeap -> BEMonad BEArgP
convertLhsArgs freeVars varHeap
= foldr (beArgs o (flip convertFreeVarPattern) varHeap) beNoArgs freeVars
= foldr` (beArgs o (flip` convertFreeVarPattern) varHeap) beNoArgs freeVars
convertVarPtr :: VarInfoPtr VarHeap -> BEMonad BENodeP
convertVarPtr var varHeap
......@@ -1170,7 +1195,7 @@ convertVarPtr var varHeap
convertVars :: [VarInfoPtr] VarHeap -> BEMonad BEArgP
convertVars vars varHeap
= foldr (beArgs o flip convertVarPtr varHeap) beNoArgs vars
= foldr` (beArgs o flip` convertVarPtr varHeap) beNoArgs vars
/* MW was
convertRootExpr :: Expression VarHeap -> BEMonad BENodeP
......@@ -1287,7 +1312,7 @@ convertNodeDef {bind_src=expr, bind_dst=freeVar} varHeap
convertNodeDefs :: [Bind Expression FreeVar] VarHeap -> BEMonad BENodeDefP
convertNodeDefs binds varHeap
= foldr (beNodeDefs o flip convertNodeDef varHeap) beNoNodeDefs binds
= foldr` (beNodeDefs o flip` convertNodeDef varHeap) beNoNodeDefs binds
collectStrictNodeIds :: Expression -> [FreeVar]
collectStrictNodeIds (Let {let_strict_binds, let_expr})
......@@ -1301,7 +1326,7 @@ convertStrictNodeId freeVar varHeap
convertStrictNodeIds :: [FreeVar] VarHeap -> BEMonad BEStrictNodeIdP
convertStrictNodeIds freeVars varHeap
= foldr (beStrictNodeIds o flip convertStrictNodeId varHeap) beNoStrictNodeIds freeVars
= foldr` (beStrictNodeIds o flip` convertStrictNodeId varHeap) beNoStrictNodeIds freeVars
convertRhsStrictNodeIds :: Expression VarHeap -> BEMonad BEStrictNodeIdP
convertRhsStrictNodeIds expression varHeap
......@@ -1321,7 +1346,7 @@ convertLiteralSymbol (BVS string)
convertArgs :: [Expression] VarHeap -> BEMonad BEArgP
convertArgs exprs varHeap
= foldr (beArgs o flip convertExpr varHeap) beNoArgs exprs
= foldr` (beArgs o flip` convertExpr varHeap) beNoArgs exprs
convertSymbol :: !SymbIdent -> BEMonad BESymbolP
convertSymbol {symb_kind=SK_Function {glob_module, glob_object}}
......@@ -1367,7 +1392,7 @@ convertExpr (Selection isUnique expression selections) varHeap
addKinds _ []
= []
convertExpr (RecordUpdate _ expr updates) varHeap
= foldl (convertUpdate varHeap) (convertExpr expr varHeap) updates
= foldl (convertUpdate varHeap) (convertExpr expr varHeap) updates -*-> "be: RecordUpdate"
where
convertUpdate varHeap expr {bind_src=NoBind _}
= expr
......@@ -1383,7 +1408,7 @@ convertExpr (RecordUpdate _ expr updates) varHeap
convertExpr (Update expr1 [singleSelection] expr2) varHeap
= case singleSelection of
RecordSelection _ _
-> beUpdateNode (convertArgs [expr1, Selection No expr2 [singleSelection]] varHeap)
-> beUpdateNode (convertArgs [expr1, Selection No expr2 [singleSelection]] varHeap) -*-> "be: Update [single]"
ArraySelection {glob_object={ds_index}, glob_module} _ index
// RWS not used?, eleminate beSpecialArrayFunctionSymbol?
-> beNormalNode
......
......@@ -63,12 +63,12 @@ foldStateWithIndexA function array
o` foldStateWithIndexA (index+1)
foldrA function result array
:== foldrA result 0
:== foldrA 0
where
arraySize
= size array
foldrA result index
foldrA index
| index == arraySize
= result
// otherwise
= function array.[index] (foldrA result (index+1))
= function array.[index] (foldrA (index+1))
......@@ -55,12 +55,12 @@ foldStateWithIndexA function array
o` foldStateWithIndexA (index+1)
foldrA function result array
:== foldrA result 0
:== foldrA 0
where
arraySize
= size array
foldrA result index
foldrA index
| index == arraySize
= result
// otherwise
= function array.[index] (foldrA result (index+1))
= function array.[index] (foldrA (index+1))
......@@ -11,6 +11,7 @@ import checksupport, transform, overloading
, fe_varHeap :: !.VarHeap
, fe_dclIclConversions ::!Optional {# Index}
, fe_iclDclConversions ::!Optional {# Index}
, fe_globalFunctions :: !IndexRange
, fe_arrayInstances :: !IndexRange
}
......
......@@ -10,6 +10,7 @@ import RWSDebug
, fe_varHeap :: !.VarHeap
, fe_dclIclConversions ::!Optional {# Index}
, fe_iclDclConversions ::!Optional {# Index}
, fe_globalFunctions :: !IndexRange
, fe_arrayInstances :: !IndexRange
}
......@@ -78,6 +79,7 @@ frontEndInterface mod_ident search_paths predef_symbols hash_table files error i
, fe_varHeap = var_heap
, fe_dclIclConversions = optional_dcl_icl_conversions
, fe_iclDclConversions = build_optional_icl_dcl_conversions (size fun_defs) optional_dcl_icl_conversions
, fe_globalFunctions = global_fun_range
, fe_arrayInstances = array_instances
}
)
......
......@@ -129,10 +129,8 @@ where
collectFunctions (PE_Bound bound_expr) ca
# (bound_expr, ca) = collectFunctions bound_expr ca
= (PE_Bound bound_expr, ca)
// MW was: collectFunctions (PE_Lambda lam_ident args res) ca
collectFunctions (PE_Lambda lam_ident args res pos) ca
# ((args,res), ca) = collectFunctions (args,res) ca
// MW was: # (range, ca) = addFunctionsRange [transformLambda lam_ident args res] ca
# (range, ca) = addFunctionsRange [transformLambda lam_ident args res pos] ca
= (PE_Let cIsStrict (CollectedLocalDefs { loc_functions = range, loc_nodes = [] })
(PE_Ident lam_ident), ca)
......@@ -173,11 +171,9 @@ where
= collectFunctions (transformSequence sequence ca_predefs) ca
collectFunctions (PE_ArrayDenot exprs) ca=:{ca_predefs}
= collectFunctions (transformArrayDenot exprs ca_predefs) ca
// MV ..
collectFunctions (PE_Dynamic exprs opt_dyn_type) ca
# (exprs, ca) = collectFunctions exprs ca
= (PE_Dynamic exprs opt_dyn_type, ca)
// .. MV
collectFunctions expr ca
= (expr, ca)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment