Verified Commit ba90c5a3 authored by Camil Staps's avatar Camil Staps 🚀

Move the local definitions option further down to findModuleContents

parent 9ab3e2fd
......@@ -53,6 +53,7 @@ indexModule :: !Bool !String !Module !Library
/**
* Parse a module and get its contents
*
* @param Whether local definitions (that only exist in the icl) should be indexed.
* @param The path to the module, without .icl or .dcl
* @result A tuple of:
* - Function definitions
......@@ -67,7 +68,7 @@ indexModule :: !Bool !String !Module !Library
* - Class derivations
* - The module
*/
findModuleContents :: !String !*World
findModuleContents :: !Bool !String !*World
-> *( ![(LocationInModule, FunctionEntry)]
, ![(LocationInModule, FunctionEntry)]
, ![(LocationInModule, FunctionEntry)]
......
......@@ -145,19 +145,7 @@ indexModule :: !Bool !String !'DB'.Module !'DB'.Library
-> *(!TemporaryDB, !*World)
indexModule include_locals root mod lib modf db w
#! (functions, macros, generics, typedefs, clss, insts, derivs, clsderivs, (modname, modentry), w)
= findModuleContents (root </> lib </> mkdir mod) w
#! (functions, macros, generics, typedefs, clss, insts, derivs, clsderivs) =
if include_locals
(functions, macros, generics, typedefs, clss, insts, derivs, clsderivs)
( filter (hasDcl o fst) functions
, filter (hasDcl o fst) macros
, filter (hasDcl o fst) generics
, filter (hasDcl o fst) typedefs
, filter (hasDcl o fst) clss
, filter (hasDcl o thd3) insts
, filter (not o isEmpty o snd) (map (appSnd (filter (hasDcl o thd3))) derivs)
, filter (hasDcl o (\(_,_,_,x)->x)) clsderivs
)
= findModuleContents include_locals (root </> lib </> mkdir mod) w
#! lib = lib % (0, size lib - size modname + size mod - 1)
#! db =
{ db
......@@ -188,15 +176,13 @@ where
castLoc :: String LocationInModule -> 'DB'.Location
castLoc m l = 'DB'.Location lib m l.dcl_line l.icl_line (fromJust (l.name <|> Just "")) // TODO
hasDcl loc = isJust loc.dcl_line
mkdir :: String -> String
mkdir s = { if (c == '.') '/' c \\ c <-: s }
instance zero LocationInModule
where zero = {dcl_line=Nothing, icl_line=Nothing, name=Nothing}
findModuleContents :: !String !*World
findModuleContents :: !Bool !String !*World
-> *( ![(LocationInModule, 'DB'.FunctionEntry)]
, ![(LocationInModule, 'DB'.FunctionEntry)]
, ![(LocationInModule, 'DB'.FunctionEntry)]
......@@ -208,24 +194,36 @@ findModuleContents :: !String !*World
, !('DB'.Name, 'DB'.ModuleEntry)
, !*World
)
findModuleContents path w
findModuleContents include_locals path w
#! (dcl,dcl_symbols,w) = readModule False w
#! (dcl,modname) = case dcl of
Left _ -> ([], "")
Right dcl -> (dcl.mod_defs, dcl.mod_ident.id_name)
#! (icl,icl_symbols,w) = readModule True w
#! icl = case icl of Left _ -> []; Right icl -> icl.mod_defs
= ( combine cmpLocFst joinLocFst pd_typespecs dcl dcl_symbols icl icl_symbols
, combine cmpLocFst joinLocFst pd_macros dcl dcl_symbols icl icl_symbols
, combine cmpLocFst joinLocFst pd_generics dcl dcl_symbols icl icl_symbols
, combine cmpLocFst joinLocFst pd_types dcl dcl_symbols icl icl_symbols
, combine cmpLocFst joinLocFst pd_classes dcl dcl_symbols icl icl_symbols
, combine cmpInsts joinInsts pd_instances dcl dcl_symbols icl icl_symbols
, combineDerivs (pd_derivations True dcl) (pd_derivations False icl)
, combine cmpClsDeriv joinClsDeriv pd_class_derivations dcl dcl_symbols icl icl_symbols
, (modname,pd_module dcl)
, w
)
#! contents=:(functions,macros,generics,typedefs,clss,insts,derivs,clsderivs) =
( combine cmpLocFst joinLocFst pd_typespecs dcl dcl_symbols icl icl_symbols
, combine cmpLocFst joinLocFst pd_macros dcl dcl_symbols icl icl_symbols
, combine cmpLocFst joinLocFst pd_generics dcl dcl_symbols icl icl_symbols
, combine cmpLocFst joinLocFst pd_types dcl dcl_symbols icl icl_symbols
, combine cmpLocFst joinLocFst pd_classes dcl dcl_symbols icl icl_symbols
, combine cmpInsts joinInsts pd_instances dcl dcl_symbols icl icl_symbols
, combineDerivs (pd_derivations True dcl) (pd_derivations False icl)
, combine cmpClsDeriv joinClsDeriv pd_class_derivations dcl dcl_symbols icl icl_symbols
)
#! (functions,macros,generics,typedefs,clss,insts,derivs,clsderivs) =
if include_locals
contents
( filter (hasDcl o fst) functions
, filter (hasDcl o fst) macros
, filter (hasDcl o fst) generics
, filter (hasDcl o fst) typedefs
, filter (hasDcl o fst) clss
, filter (hasDcl o thd3) insts
, filter (not o isEmpty o snd) (map (appSnd (filter (hasDcl o thd3))) derivs)
, filter (hasDcl o (\(_,_,_,x)->x)) clsderivs
) with hasDcl loc = isJust loc.dcl_line
= (functions,macros,generics,typedefs,clss,insts,derivs,clsderivs,(modname,pd_module dcl),w)
where
combine :: (a a -> Bool) (a a -> a)
(Bool [ParsedDefinition] SymbolTable -> [a])
......
Markdown is supported
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