Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Cloogle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cloogle
Cloogle
Commits
621e3ddf
Verified
Commit
621e3ddf
authored
Jun 24, 2017
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganise TypeDB -> CloogleDB
parent
b50e3c09
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
705 additions
and
147 deletions
+705
-147
CloogleDB.dcl
CloogleDB.dcl
+226
-0
CloogleDB.icl
CloogleDB.icl
+356
-0
CloogleDBFactory.dcl
CloogleDBFactory.dcl
+5
-5
CloogleDBFactory.icl
CloogleDBFactory.icl
+54
-49
Search.dcl
Search.dcl
+2
-2
Search.icl
Search.icl
+61
-90
libcloogle
libcloogle
+1
-1
No files found.
Typ
eDB.dcl
→
Cloogl
eDB.dcl
View file @
621e3ddf
definition
module
Typ
eDB
definition
module
Cloogl
eDB
/**
* A database with information about Clean modules.
* This module is called TypeDB for historical reasons and should be renamed (TODO).
*
* The functions here follow a general guideline about nomenclature:
* - get* expects that you already know the location of the value you seek and
...
...
@@ -23,80 +22,87 @@ definition module TypeDB
from
StdOverloaded
import
class
<,
class
zero
from
StdClass
import
class
Ord
from
Data
.
Map
import
::
Map
from
Data
.
Maybe
import
::
Maybe
from
Data
.
Map
import
::
Map
from
Data
.
Maybe
import
::
Maybe
from
GenEq
import
generic
gEq
// CleanTypeUnifier
from
Type
import
::
Type
,
::
TypeVar
,
::
TVAssignment
,
::
TypeDef
,
class
print
(..),
::
ClassContext
,
::
ClassRestriction
,
::
ClassOrGeneric
,
::
Priority
from
Type
import
::
Type
,
::
TypeVar
,
::
TVAssignment
,
::
TypeDef
,
::
ClassContext
,
::
ClassRestriction
,
::
ClassOrGeneric
,
::
Priority
,
class
print
(..)
from
Doc
import
::
Documentation
from
Cloogle
import
::
FunctionKind
from
Doc
import
::
Documentation
/**
* A storage for function types, class definitions, type definitions, etc.
*/
::
Typ
eDB
::
Cloogl
eDB
/**
*
Not-type information that is often associated with things that have a type
*
A location in the Clean libraries
*/
::
TypeExtras
=
{
te_priority
::
!
Maybe
Priority
//* The infix priority
,
te_isconstructor
::
!
Bool
//* Whether this function is a constructor
,
te_isrecordfield
::
!
Bool
//* Whether this function is a record field
,
te_generic_vars
::
!
Maybe
[
String
]
//* The names of the type variables of a generic function
// Using TypeVar causes import clashes in TypeDBFactory
,
te_representation
::
!
Maybe
String
//* A string representation of the entry
,
te_documentation
::
!
Maybe
Documentation
//* Documentation on this entry
}
::
Location
=
Location
Library
Module
LineNr
LineNr
Name
//* A normal location
|
Builtin
Name
//* A language builtin
/**
*
A Type with TypeExtras
*
Not-type information that is often associated with things that have a type
*/
::
ExtendedType
=
ET
!
Type
!
TypeExtras
::
FunctionEntry
=
{
fe_kind
::
!
FunctionKind
//* The type of entry
,
fe_type
::
!
Maybe
Type
//* The type, Nothing for macros
,
fe_priority
::
!
Maybe
Priority
//* The infix priority
,
fe_generic_vars
::
!
Maybe
[
String
]
//* The names of the type variables of a generic function
// Using TypeVar causes import clashes in CloogleDBFactory
,
fe_representation
::
!
Maybe
String
//* A string representation of the entry
,
fe_documentation
::
!
Maybe
Documentation
//* Documentation on this entry
}
/**
* A TypeDef with meta-data
*/
::
ExtendedTypeDef
=
{
etd
_typedef
::
!
TypeDef
//* The TypeDef
,
etd
_doc
::
!
Maybe
Documentation
//* Documentation on the TypeDef (a TypeDoc)
::
TypeDefEntry
=
{
tde
_typedef
::
!
TypeDef
//* The TypeDef
,
tde
_doc
::
!
Maybe
Documentation
//* Documentation on the TypeDef (a TypeDoc)
}
/**
* Information about a
macro
* Information about a
Clean module
*/
::
M
acro
=
{
m
acro_as_string
::
!
String
//* A string representation
,
m
acro_extras
::
!
TypeExtras
//* Extra information
::
M
oduleEntry
=
{
m
e_is_core
::
!
Bool
//* Whether this is a core module (e.g. the os* modules in ObjectIO and TCPIP)
,
m
e_documentation
::
!
Maybe
Documentation
//* Documentation on this module (a ModuleDoc)
}
/**
*
A location in the Clean librarie
s
*
Information about a Clean clas
s
*/
::
Location
=
Location
Library
Module
LineNr
LineNr
Name
//* A normal location
|
Builtin
Name
//* A language builtin
::
ClassEntry
=
{
ce_vars
::
![
String
]
//* The type variables of the class
// Using TypeVar causes import clashes in CloogleDBFactory
,
ce_context
::
!
ClassContext
//* A class context
,
ce_documentation
::
!
Maybe
Documentation
//* Documentation on this class (a ClassDoc)
,
ce_members
::
![(!
Name
,
!
FunctionEntry
)]
//* Class members: function name and type information
}
/**
* Information about a
Clean modul
e
* Information about a
class instanc
e
*/
::
ModuleInfo
=
{
i
s_core
::
!
Bool
//* Whether this is a core module (e.g. the os* modules in ObjectIO and TCPIP)
,
mod_documentation
::
!
Maybe
Documentation
//* Documentation on this module (a ModuleDoc)
::
InstanceEntry
=
{
i
e_types
::
[(
Type
,
String
)]
//* The instantiated type and a string representation for each class variable
,
ie_locations
::
[
Location
]
//* The places where this instance is found
}
/**
* Information about a
Clean class
* Information about a
generic derivation
*/
::
Class
=
{
class_vars
::
![
String
]
//* The type variables of the class
// Using TypeVar causes import clashes in TypeDBFactory
,
class_context
::
!
ClassContext
//* A class context
,
class_documentation
::
!
Maybe
Documentation
//* Documentation on this class (a ClassDoc)
,
class_members
::
![(!
Name
,
!
ExtendedType
)]
//* Class members: function name and type information
::
DeriveEntry
=
{
de_type
::
Type
//* The type to derive an instance for
,
de_type_representation
::
String
//* A string representation of the type
,
de_locations
::
[
Location
]
//* The locations in which the derivation occurs
}
::
Name
:==
String
...
...
@@ -104,19 +110,19 @@ from Doc import ::Documentation
::
Module
:==
String
::
LineNr
:==
Maybe
Int
instance
zero
Typ
eDB
instance
zero
TypeExtras
instance
zero
Module
Info
instance
zero
Cloogl
eDB
instance
zero
FunctionEntry
instance
zero
Module
Entry
instance
print
(
Name
,
ExtendedType
)
instance
print
(
Name
,
FunctionEntry
)
getName
::
Location
->
Name
isBuiltin
::
Location
->
Bool
isCore
::
Location
Typ
eDB
->
Bool
isCore
::
Location
Cloogl
eDB
->
Bool
to
ExtendedTypeDef
::
TypeDef
(
Maybe
Documentation
)
->
ExtendedTypeDef
getTypeDef
::
ExtendedTypeDef
->
TypeDef
getTypeDefDoc
::
ExtendedTypeDef
->
Maybe
Documentation
to
TypeDefEntry
::
TypeDef
(
Maybe
Documentation
)
->
TypeDefEntry
getTypeDef
::
TypeDefEntry
->
TypeDef
getTypeDefDoc
::
TypeDefEntry
->
Maybe
Documentation
/**
* Wrapper around the Class record field to work around name clashes
...
...
@@ -127,73 +133,61 @@ getTypeDefDoc :: ExtendedTypeDef -> Maybe Documentation
* @param The names and types of the class members
* @result A Class record with those data
*/
toClass
::
[
String
]
ClassContext
(
Maybe
Documentation
)
[(
Name
,
ExtendedType
)]
->
Class
toClass
::
[
String
]
ClassContext
(
Maybe
Documentation
)
[(
Name
,
FunctionEntry
)]
->
ClassEntry
functionCount
::
TypeDB
->
Int
macroCount
::
TypeDB
->
Int
classCount
::
TypeDB
->
Int
instanceCount
::
TypeDB
->
Int
typeCount
::
TypeDB
->
Int
deriveCount
::
TypeDB
->
Int
moduleCount
::
TypeDB
->
Int
functionCount
::
CloogleDB
->
Int
classCount
::
CloogleDB
->
Int
instanceCount
::
CloogleDB
->
Int
typeCount
::
CloogleDB
->
Int
deriveCount
::
CloogleDB
->
Int
moduleCount
::
CloogleDB
->
Int
/**
* Filter the whole database on locations using a property function
*/
filterLocations
::
(
Location
->
Bool
)
TypeDB
->
TypeDB
getFunction
::
Location
TypeDB
->
Maybe
ExtendedType
putFunction
::
!
Location
!
ExtendedType
!
TypeDB
->
TypeDB
putFunctions
::
![(!
Location
,
!
ExtendedType
)]
!
TypeDB
->
TypeDB
findFunction
::
Name
TypeDB
->
[(
Location
,
ExtendedType
)]
findFunction`
::
(
Location
ExtendedType
->
Bool
)
TypeDB
->
[(
Location
,
ExtendedType
)]
findFunction``
::
[(
Location
ExtendedType
->
Bool
)]
TypeDB
->
[(
Location
,
ExtendedType
)]
getMacro
::
Location
TypeDB
->
Maybe
Macro
putMacro
::
!
Location
!
Macro
!
TypeDB
->
TypeDB
putMacros
::
![(!
Location
,
!
Macro
)]
!
TypeDB
->
TypeDB
findMacro`
::
(
Location
Macro
->
Bool
)
TypeDB
->
[(
Location
,
Macro
)]
findMacro``
::
[(
Location
Macro
->
Bool
)]
TypeDB
->
[(
Location
,
Macro
)]
getInstances
::
Name
TypeDB
->
[([(
Type
,
String
)],
[
Location
])]
putInstance
::
!
Name
![(!
Type
,!
String
)]
!
Location
!
TypeDB
->
TypeDB
putInstances
::
![(!
Name
,
![(!
Type
,!
String
)],
!
Location
)]
!
TypeDB
->
TypeDB
getClass
::
Location
TypeDB
->
Maybe
Class
putClass
::
!
Location
!
Class
!
TypeDB
->
TypeDB
putClasses
::
![(!
Location
,
!
Class
)]
!
TypeDB
->
TypeDB
findClass
::
Name
TypeDB
->
[(
Location
,
Class
)]
findClass`
::
(
Location
Class
->
Bool
)
TypeDB
->
[(
Location
,
Class
)]
findClass``
::
[(
Location
Class
->
Bool
)]
TypeDB
->
[(
Location
,
Class
)]
findClassMembers`
::
(
Location
[
String
]
ClassContext
Name
ExtendedType
->
Bool
)
TypeDB
->
[(
Location
,
[
String
],
ClassContext
,
Name
,
ExtendedType
)]
findClassMembers``
::
[
Location
[
String
]
ClassContext
Name
ExtendedType
->
Bool
]
TypeDB
->
[(
Location
,
[
String
],
ClassContext
,
Name
,
ExtendedType
)]
getType
::
Location
TypeDB
->
Maybe
ExtendedTypeDef
putType
::
!
Location
!
ExtendedTypeDef
!
TypeDB
->
TypeDB
putTypes
::
![(!
Location
,
!
ExtendedTypeDef
)]
!
TypeDB
->
TypeDB
findType
::
Name
TypeDB
->
[(
Location
,
ExtendedTypeDef
)]
findType`
::
(
Location
ExtendedTypeDef
->
Bool
)
TypeDB
->
[(
Location
,
ExtendedTypeDef
)]
findType``
::
[(
Location
ExtendedTypeDef
->
Bool
)]
TypeDB
->
[(
Location
,
ExtendedTypeDef
)]
allTypes
::
(
TypeDB
->
[
ExtendedTypeDef
])
getDerivations
::
Name
TypeDB
->
[(
Type
,
String
,
[
Location
])]
putDerivation
::
!
Name
!
Type
!
String
!
Location
!
TypeDB
->
TypeDB
putDerivations
::
!
Name
![(!
Type
,
!
String
,
!
Location
)]
!
TypeDB
->
TypeDB
putDerivationss
::
![(!
Name
,
![(!
Type
,
!
String
,
!
Location
)])]
!
TypeDB
->
TypeDB
getModule
::
Library
Module
TypeDB
->
Maybe
ModuleInfo
putModule
::
!
Library
!
Module
!
ModuleInfo
!
TypeDB
->
TypeDB
findModule`
::
(
Library
Module
ModuleInfo
->
Bool
)
TypeDB
->
[(
Library
,
Module
,
ModuleInfo
)]
/**
* Search for exactly a certain type
*/
searchExact
::
Type
TypeDB
->
[(
Location
,
ExtendedType
)]
filterLocations
::
(
Location
->
Bool
)
CloogleDB
->
CloogleDB
getFunction
::
Location
CloogleDB
->
Maybe
FunctionEntry
putFunction
::
!
Location
!
FunctionEntry
!
CloogleDB
->
CloogleDB
putFunctions
::
![(!
Location
,
!
FunctionEntry
)]
!
CloogleDB
->
CloogleDB
findFunction
::
Name
CloogleDB
->
[(
Location
,
FunctionEntry
)]
findFunction`
::
(
Location
FunctionEntry
->
Bool
)
CloogleDB
->
[(
Location
,
FunctionEntry
)]
findFunction``
::
[(
Location
FunctionEntry
->
Bool
)]
CloogleDB
->
[(
Location
,
FunctionEntry
)]
getInstances
::
Name
CloogleDB
->
[
InstanceEntry
]
putInstance
::
!
Name
![(!
Type
,!
String
)]
!
Location
!
CloogleDB
->
CloogleDB
putInstances
::
![(!
Name
,
![(!
Type
,!
String
)],
!
Location
)]
!
CloogleDB
->
CloogleDB
getClass
::
Location
CloogleDB
->
Maybe
ClassEntry
putClass
::
!
Location
!
ClassEntry
!
CloogleDB
->
CloogleDB
putClasses
::
![(!
Location
,
!
ClassEntry
)]
!
CloogleDB
->
CloogleDB
findClass
::
Name
CloogleDB
->
[(
Location
,
ClassEntry
)]
findClass`
::
(
Location
ClassEntry
->
Bool
)
CloogleDB
->
[(
Location
,
ClassEntry
)]
findClass``
::
[(
Location
ClassEntry
->
Bool
)]
CloogleDB
->
[(
Location
,
ClassEntry
)]
findClassMembers`
::
(
Location
[
String
]
ClassContext
Name
FunctionEntry
->
Bool
)
CloogleDB
->
[(
Location
,
[
String
],
ClassContext
,
Name
,
FunctionEntry
)]
findClassMembers``
::
[
Location
[
String
]
ClassContext
Name
FunctionEntry
->
Bool
]
CloogleDB
->
[(
Location
,
[
String
],
ClassContext
,
Name
,
FunctionEntry
)]
getType
::
Location
CloogleDB
->
Maybe
TypeDefEntry
putType
::
!
Location
!
TypeDefEntry
!
CloogleDB
->
CloogleDB
putTypes
::
![(!
Location
,
!
TypeDefEntry
)]
!
CloogleDB
->
CloogleDB
findType
::
Name
CloogleDB
->
[(
Location
,
TypeDefEntry
)]
findType`
::
(
Location
TypeDefEntry
->
Bool
)
CloogleDB
->
[(
Location
,
TypeDefEntry
)]
findType``
::
[(
Location
TypeDefEntry
->
Bool
)]
CloogleDB
->
[(
Location
,
TypeDefEntry
)]
allTypes
::
(
CloogleDB
->
[
TypeDefEntry
])
getDerivations
::
Name
CloogleDB
->
[
DeriveEntry
]
putDerivation
::
!
Name
!
Type
!
String
!
Location
!
CloogleDB
->
CloogleDB
putDerivations
::
!
Name
![(!
Type
,
!
String
,
!
Location
)]
!
CloogleDB
->
CloogleDB
putDerivationss
::
![(!
Name
,
![(!
Type
,
!
String
,
!
Location
)])]
!
CloogleDB
->
CloogleDB
getModule
::
Library
Module
CloogleDB
->
Maybe
ModuleEntry
putModule
::
!
Library
!
Module
!
ModuleEntry
!
CloogleDB
->
CloogleDB
findModule`
::
(
Library
Module
ModuleEntry
->
Bool
)
CloogleDB
->
[(
Library
,
Module
,
ModuleEntry
)]
/**
* Get all the class instances of a type
...
...
@@ -204,7 +198,7 @@ searchExact :: Type TypeDB -> [(Location, ExtendedType)]
* instantiating the class (type and string representation) and all the
* locations where the class is instantiated for those types)
*/
getTypeInstances
::
Name
TypeDB
->
[(
Name
,
[(
Type
,
String
)],
[
Location
]
)]
getTypeInstances
::
Name
CloogleDB
->
[(
Name
,
InstanceEntry
)]
/**
* Get all the generic derivations of a type
...
...
@@ -214,24 +208,19 @@ getTypeInstances :: Name TypeDB -> [(Name, [(Type,String)], [Location])]
* @result A list of derivations (name of the generic function and all the
* locations where it is derived for that type)
*/
getTypeDerivations
::
Name
TypeDB
->
[(
Name
,
[
Location
])]
/**
* Completely evaluate a database to normal form
*/
evalDb
::
!
TypeDB
->
TypeDB
getTypeDerivations
::
Name
CloogleDB
->
[(
Name
,
[
Location
])]
/**
* Initialise an empty database
*/
newDb
::
Typ
eDB
newDb
::
Cloogl
eDB
/**
* Read the database from a file. The file should be opened for reading.
*/
openDb
::
*
File
->
*(!
Typ
eDB
,
!*
File
)
openDb
::
*
File
->
*(!
Cloogl
eDB
,
!*
File
)
/**
* Save the database to a file. The file should be opened for writing.
*/
saveDb
::
!
Typ
eDB
!*
File
->
*
File
saveDb
::
!
Cloogl
eDB
!*
File
->
*
File
Typ
eDB.icl
→
Cloogl
eDB.icl
View file @
621e3ddf
implementation
module
Typ
eDB
implementation
module
Cloogl
eDB
// Standard libraries
import
StdArray
...
...
@@ -30,19 +30,20 @@ import GenLexOrd
// CleanTypeUnifier
import
Type
import
Cloogle
import
Doc
::
Typ
eDB
::
Cloogl
eDB
=
{
// Base maps
functionmap
::
!
Map
Location
ExtendedType
,
macromap
::
!
Map
Location
Macro
,
classmap
::
!
Map
Location
Class
,
instancemap
::
!
Map
Name
[([(
Type
,
String
)],
[
Location
])]
,
typemap
::
!
Map
Location
ExtendedTypeDef
,
derivemap
::
!
Map
Name
[(
Type
,
String
,
[
Location
])]
,
modulemap
::
!
Map
(
Library
,
Module
)
ModuleInfo
functionmap
::
!
Map
Location
FunctionEntry
,
classmap
::
!
Map
Location
ClassEntry
,
instancemap
::
!
Map
Name
[
InstanceEntry
]
,
typemap
::
!
Map
Location
TypeDefEntry
,
derivemap
::
!
Map
Name
[
DeriveEntry
]
,
modulemap
::
!
Map
(
Library
,
Module
)
ModuleEntry
// Derived maps
,
instancemap`
::
!
Map
Name
[(
Name
,
[(
Type
,
String
)],
[
Location
]
)]
,
instancemap`
::
!
Map
Name
[(
Name
,
InstanceEntry
)]
,
derivemap`
::
!
Map
Name
[(
Name
,
[
Location
])]
}
...
...
@@ -52,22 +53,21 @@ printersperse ia a bs = intercalate (print False a) (map (print ia) bs)
(--)
infixr
5
::
a
b
->
[
String
]
|
print
a
&
print
b
(--)
a
b
=
print
False
a
++
print
False
b
derive
gEq
ClassOrGeneric
,
Location
,
Type
,
TypeExtras
,
Priority
,
ExtendedType
,
TypeDef
,
TypeDefRhs
,
RecordField
,
Constructor
,
Kind
,
Macro
,
Documentation
,
TypeRhsDoc
,
ClassMemberDoc
derive
JSONEncode
ClassOrGeneric
,
Location
,
Type
,
TypeDB
,
TypeExtras
,
Priority
,
ExtendedType
,
TypeDef
,
TypeDefRhs
,
RecordField
,
Constructor
,
Kind
,
Macro
,
ModuleInfo
,
Documentation
,
TypeRhsDoc
,
ClassMemberDoc
,
ExtendedTypeDef
,
Class
derive
JSONDecode
ClassOrGeneric
,
Location
,
Type
,
TypeDB
,
TypeExtras
,
Priority
,
ExtendedType
,
TypeDef
,
TypeDefRhs
,
RecordField
,
Constructor
,
Kind
,
Macro
,
ModuleInfo
,
Documentation
,
TypeRhsDoc
,
ClassMemberDoc
,
ExtendedTypeDef
,
Class
instance
zero
Typ
eDB
derive
gEq
ClassOrGeneric
,
Location
,
Type
,
Priority
,
FunctionEntry
,
TypeDef
,
TypeDefRhs
,
RecordField
,
Constructor
,
Kind
,
Documentation
,
TypeRhsDoc
,
ClassMemberDoc
,
InstanceEntry
,
DeriveEntry
derive
JSONEncode
ClassOrGeneric
,
Location
,
Type
,
CloogleDB
,
Priority
,
FunctionEntry
,
TypeDef
,
TypeDefRhs
,
RecordField
,
Constructor
,
Kind
,
ModuleEntry
,
Documentation
,
TypeRhsDoc
,
ClassMemberDoc
,
TypeDefEntry
,
ClassEntry
,
InstanceEntry
,
DeriveEntry
derive
JSONDecode
ClassOrGeneric
,
Location
,
Type
,
CloogleDB
,
Priority
,
FunctionEntry
,
TypeDef
,
TypeDefRhs
,
RecordField
,
Constructor
,
Kind
,
ModuleEntry
,
Documentation
,
TypeRhsDoc
,
ClassMemberDoc
,
TypeDefEntry
,
ClassEntry
,
InstanceEntry
,
DeriveEntry
instance
zero
Cloogl
eDB
where
zero
=
{
functionmap
=
newMap
,
macromap
=
newMap
,
classmap
=
newMap
,
instancemap
=
newMap
,
typemap
=
newMap
...
...
@@ -84,39 +84,38 @@ instance < Type where (<) a b = (a =?= b) === LT
instance
<
(
a
,
b
,
c
,
d
)
|
gLexOrd
{|*|}
a
&
gLexOrd
{|*|}
b
&
gLexOrd
{|*|}
c
&
gLexOrd
{|*|}
d
where
(<)
a
b
=
(
a
=?=
b
)
===
LT
instance
==
Location
where
(==)
a
b
=
gEq
{|*|}
a
b
instance
==
Location
where
==
a
b
=
gEq
{|*|}
a
b
instance
==
DeriveEntry
where
==
a
b
=
gEq
{|*|}
a
b
instance
zero
TypeExtras
instance
zero
FunctionEntry
where
zero
=
{
te_priority
=
Nothing
,
te_isconstructor
=
False
,
te_isrecordfield
=
False
,
t
e_generic_vars
=
Nothing
,
t
e_representation
=
Nothing
,
t
e_documentation
=
Nothing
zero
=
{
fe_kind
=
Function
,
fe_type
=
Nothing
,
fe_priority
=
Nothing
,
f
e_generic_vars
=
Nothing
,
f
e_representation
=
Nothing
,
f
e_documentation
=
Nothing
}
instance
zero
ModuleInfo
where
zero
=
{
is_core
=
False
,
mod_documentation
=
Nothing
}
instance
print
TypeExtras
where
print
b
{
te_priority
=
Just
p
}
=
print
b
p
--
" "
print
b
{
te_generic_vars
=
Just
vars
}
=
printersperse
b
" "
vars
--
" "
print
_
_
=
[]
instance
zero
ModuleEntry
where
zero
=
{
me_is_core
=
False
,
me_documentation
=
Nothing
}
instance
print
(
Name
,
ExtendedType
)
instance
print
(
Name
,
FunctionEntry
)
where
print
_
(
f
,
(
ET
t
e
)
)
=
gen
--
fname
--
" "
--
e
--
":: "
--
t
print
b
(
f
,
fe
)
=
gen
--
fname
--
" "
--
prio
--
vars
--
if
(
isJust
fe
.
fe_type
)
(
":: "
--
fe
.
fe_type
)
[]
where
gen
=
if
(
isJust
e
.
te_generic_vars
)
"generic "
""
prio
=
case
fe
.
fe_priority
of
Nothing
->
[]
Just
p
->
print
b
p
--
" "
vars
=
case
fe
.
fe_generic_vars
of
Nothing
->
[]
Just
vs
->
printersperse
b
" "
vars
--
" "
gen
=
if
(
isJust
fe
.
fe_generic_vars
)
"generic "
""
fname
|
isJust
e
.
te_priority
=
concat
(
"("
--
f
--
")"
)
|
e
.
te_isrecordfield
=
"."
+++
f
|
otherwise
=
f
|
isJust
fe
.
fe_priority
=
concat
(
"("
--
f
--
")"
)
|
fe
.
fe_kind
==
RecordField
=
"."
+++
f
|
otherwise
=
f
getName
::
Location
->
Name
getName
(
Location
_
_
_
_
name
)
=
name
...
...
@@ -126,56 +125,52 @@ isBuiltin :: Location -> Bool
isBuiltin
(
Builtin
_)
=
True
isBuiltin
_
=
False
isCore
::
Location
Typ
eDB
->
Bool
isCore
::
Location
Cloogl
eDB
->
Bool
isCore
(
Builtin
_)
_
=
False
isCore
(
Location
lib
mod
_
_
_)
db
=
case
getModule
lib
mod
db
of
Nothing
=
False
(
Just
b
)
=
b
.
is_core
(
Just
b
)
=
b
.
me_
is_core
to
ExtendedTypeDef
::
TypeDef
(
Maybe
Documentation
)
->
ExtendedTypeDef
to
ExtendedTypeDef
td
doc
=
{
etd_typedef
=
td
,
etd
_doc
=
doc
}
to
TypeDefEntry
::
TypeDef
(
Maybe
Documentation
)
->
TypeDefEntry
to
TypeDefEntry
td
doc
=
{
tde_typedef
=
td
,
tde
_doc
=
doc
}
getTypeDef
::
ExtendedTypeDef
->
TypeDef
getTypeDef
{
etd_typedef
}
=
etd
_typedef
getTypeDef
::
TypeDefEntry
->
TypeDef
getTypeDef
{
tde_typedef
}
=
tde
_typedef
getTypeDefDoc
::
ExtendedTypeDef
->
Maybe
Documentation
getTypeDefDoc
{
etd_doc
}
=
etd
_doc
getTypeDefDoc
::
TypeDefEntry
->
Maybe
Documentation
getTypeDefDoc
{
tde_doc
}
=
tde
_doc
toClass
::
[
String
]
ClassContext
(
Maybe
Documentation
)
[(
Name
,
ExtendedType
)]
->
Class
toClass
::
[
String
]
ClassContext
(
Maybe
Documentation
)
[(
Name
,
FunctionEntry
)]
->
ClassEntry
toClass
vs
cc
doc
mems
=
{
c
lass
_vars
=
vs
,
c
lass
_context
=
cc
,
c
lass
_documentation
=
doc
,
c
lass
_members
=
mems
=
{
c
e
_vars
=
vs
,
c
e
_context
=
cc
,
c
e
_documentation
=
doc
,
c
e
_members
=
mems
}
functionCount
::
Typ
eDB
->
Int
functionCount
::
Cloogl
eDB
->
Int
functionCount
{
functionmap
}
=
mapSize
functionmap
macroCount
::
TypeDB
->
Int
macroCount
{
macromap
}
=
mapSize
macromap
classCount
::
TypeDB
->
Int
classCount
::
CloogleDB
->
Int
classCount
{
classmap
}
=
mapSize
classmap
instanceCount
::
Typ
eDB
->
Int
instanceCount
::
Cloogl
eDB
->
Int
instanceCount
{
instancemap
}
=
sum
$
map
length
$
elems
instancemap
typeCount
::
Typ
eDB
->
Int
typeCount
::
Cloogl
eDB
->
Int
typeCount
{
typemap
}
=
mapSize
typemap
deriveCount
::
Typ
eDB
->
Int
deriveCount
::
Cloogl
eDB
->
Int
deriveCount
{
derivemap
}
=
sum
$
map
length
$
elems
derivemap
moduleCount
::
Typ
eDB
->
Int
moduleCount
::
Cloogl
eDB
->
Int
moduleCount
{
modulemap
}
=
mapSize
modulemap
filterLocations
::
(
Location
->
Bool
)
TypeDB
->
Typ
eDB
filterLocations
::
(
Location
->
Bool
)
CloogleDB
->
Cloogl
eDB
filterLocations
f
db
=
{
db
&
functionmap
=
filterLoc
db
.
functionmap
,
macromap
=
filterLoc
db
.
macromap
,
classmap
=
filterLoc
db
.
classmap
,
typemap
=
filterLoc
db
.
typemap
,
instancemap
=
filtInstLocs
<$>
db
.
instancemap
...
...
@@ -186,197 +181,176 @@ where
filterLoc
::
((
Map
Location
a
)
->
Map
Location
a
)
filterLoc
=
filterWithKey
(
const
o
f
)
filtInstLocs
::
[
(
a
,
[
Location
])]
->
[(
a
,
[
Location
])
]
filtInstLocs
::
[
InstanceEntry
]
->
[
InstanceEntry
]
filtInstLocs
[]
=
[]
filtInstLocs
[(
t
,
ls
):
rest
]
=
case
ls`
of
[]
=
filtInstLocs
rest
_
=
[(
t
,
ls`
):
filtInstLocs
rest
]
where
ls`
=
filter
f
ls
filtInstLocs
[
ie
:
rest
]
=
case
filter
f
ie
.
ie_locations
of
[]
=
filtInstLocs
rest
ls
=
[{
ie
&
ie_locations
=
ls
}:
filtInstLocs
rest
]
filtDervLocs
::
[
(
a
,
b
,
[
Location
])]
->
[(
a
,
b
,
[
Location
])
]
filtDervLocs
::
[
DeriveEntry
]
->
[
DeriveEntry
]
filtDervLocs
[]
=
[]
filtDervLocs
[(
t
,
s
,
ls
):
rest
]
=
case
ls`
of
[]
=
filtDervLocs
rest
_
=
[(
t
,
s
,
ls`
):
filtDervLocs
rest
]
where
ls`
=
filter
f
ls
filtDervLocs
[
de
:
rest
]
=
case
filter
f
de
.
de_locations
of
[]
=
filtDervLocs
rest
ls
=
[{
de
&
de_locations
=
ls
}:
filtDervLocs
rest
]
filtModules
::
((
Map
(
Library
,
Module
)
a
)
->
Map
(
Library
,
Module
)
a
)
filtModules
=
filterWithKey
(\(
l
,
m
)
_
->
f
(
Location
l
m
Nothing
Nothing
undef
))
getFunction
::
Location
TypeDB
->
Maybe
ExtendedType
getFunction
::
Location
CloogleDB
->
Maybe
FunctionEntry
getFunction
loc
{
functionmap
}
=
get
loc
functionmap
putFunction
::
!
Location
!
ExtendedType
!
TypeDB
->
Typ
eDB
putFunction
::
!
Location
!
FunctionEntry
!
CloogleDB
->
Cloogl
eDB
putFunction
fl
t
tdb
=:{
functionmap
}
=
{
tdb
&
functionmap
=
put
fl
t
functionmap
}
putFunctions
::
![(!
Location
,
!
ExtendedType
)]
!
TypeDB
->
Typ
eDB
putFunctions
::
![(!
Location
,
!
FunctionEntry
)]
!
CloogleDB
->
Cloogl
eDB
putFunctions
ts
tdb
=
foldr
(\(
loc
,
t
)
db
->
putFunction
loc
t
db
)
tdb
ts
findFunction
::
Name
TypeDB
->
[(
Location
,
ExtendedType
)]
findFunction
::
Name
CloogleDB
->
[(
Location
,
FunctionEntry
)]
findFunction
f
db
=:{
functionmap
}
=
toList
$
filterWithKey
(\
fl
_->
f
==
getName
fl
)
functionmap
findFunction`
::
(
Location
ExtendedType
->
Bool
)
Typ
eDB
->
[(
Location
,
ExtendedType
)]
findFunction`
::
(
Location
FunctionEntry
->
Bool
)
Cloogl
eDB
->
[(
Location
,
FunctionEntry
)]
findFunction`
f
{
functionmap
}
=
toList
$
filterWithKey
f
functionmap
findFunction``
::
[(
Location
ExtendedType
->
Bool
)]
Typ
eDB
->
[(
Location
,
ExtendedType
)]