Commit ed79b665 authored by Camil Staps's avatar Camil Staps 🚀

Start macros

parent 77dab00c
......@@ -33,11 +33,19 @@ instance print TE_Priority
instance print (FunctionName, ExtendedType)
:: MacroLocation = ML Library Module MacroName
instance print MacroLocation
:: Macro = { macro_rhs :: String
, macro_extras :: TypeExtras
}
:: ClassLocation = CL Library Module Class
:: Library :== String
:: Module :== String
:: FunctionName :== String
:: MacroName :== String
:: Class :== String
:: GenericName :== String
......@@ -54,6 +62,8 @@ findFunction` :: (FunctionLocation ExtendedType -> Bool) TypeDB
findFunction`` :: [(FunctionLocation ExtendedType -> Bool)] TypeDB
-> [(FunctionLocation, ExtendedType)]
getMacro :: MacroLocation TypeDB -> Maybe Macro
getInstances :: Class TypeDB -> [Type]
putInstance :: Class Type TypeDB -> TypeDB
putInstances :: Class [Type] TypeDB -> TypeDB
......
......@@ -13,6 +13,7 @@ import Type
:: TypeDB
= { functionmap :: Map FunctionLocation ExtendedType
, macromap :: Map MacroLocation Macro
, classmap :: Map ClassLocation ([TypeVar],ClassContext,[(FunctionName, ExtendedType)])
, instancemap :: Map Class [Type]
, typemap :: Map TypeLocation TypeDef
......@@ -38,6 +39,7 @@ derive JSONDecode ClassOrGeneric, FunctionLocation, ClassLocation, Type,
instance zero TypeDB
where
zero = { functionmap = newMap
, macromap = newMap
, classmap = newMap
, instancemap = newMap
, typemap = newMap
......@@ -48,6 +50,10 @@ instance < FunctionLocation where (<) (FL a b c) (FL d e f) = (a,b,c) < (d,e,f)
instance print FunctionLocation
where print _ (FL lib mod fn) = fn -- " in " -- mod -- " in " -- lib
instance < MacroLocation where (<) (ML a b c) (ML d e f) = (a,b,c) < (d,e,f)
instance print MacroLocation
where print _ (ML lib mod mn) = mn -- " in " -- mod -- " in " -- lib
instance < ClassLocation where (<) (CL a b c) (CL d e f) = (a,b,c) < (d,e,f)
instance < TypeLocation where (<) (TL a b c) (TL d e f) = (a,b,c) < (d,e,f)
......@@ -99,6 +105,8 @@ findFunction`` :: [(FunctionLocation ExtendedType -> Bool)] TypeDB
-> [(FunctionLocation, ExtendedType)]
findFunction`` fs {functionmap} = toList $ foldr filterWithKey functionmap fs
getMacro :: MacroLocation TypeDB -> Maybe Macro
getInstances :: Class TypeDB -> [Type]
getInstances c {instancemap} = if (isNothing ts) [] (fromJust ts)
where ts = get c instancemap
......
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