Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Cloogle
Cloogle
Commits
926a918c
Verified
Commit
926a918c
authored
May 07, 2018
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Find used record fields separately from local/global expressions
parent
2b6da6e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
Idents.dcl
Idents.dcl
+3
-2
Idents.icl
Idents.icl
+17
-9
No files found.
Idents.dcl
View file @
926a918c
...
...
@@ -9,8 +9,9 @@ from Data.Set import :: Set
from
syntax
import
::
ParsedDefinition
::
Idents
=
{
locals
::
Set
String
,
globals
::
Set
String
{
locals
::
!
Set
String
,
globals
::
!
Set
String
,
record_fields
::
!
Set
String
}
::
IdentContext
...
...
Idents.icl
View file @
926a918c
...
...
@@ -15,22 +15,25 @@ noLocals ids = {ids & locals=newSet}
instance
zero
Idents
where
zero
=
{
locals
=
newSet
,
globals
=
newSet
{
locals
=
newSet
,
globals
=
newSet
,
record_fields
=
newSet
}
instance
+
Idents
where
+
a
b
=
removeLocalGlobals
{
locals
=
union
a
.
locals
b
.
locals
,
globals
=
union
a
.
globals
b
.
globals
{
locals
=
union
a
.
locals
b
.
locals
,
globals
=
union
a
.
globals
b
.
globals
,
record_fields
=
union
a
.
record_fields
b
.
record_fields
}
instance
idents
[
t
]
|
idents
t
where
idents
c
xs
=
removeLocalGlobals
{
locals
=
unions
[
x
.
locals
\\
x
<-
xids
]
,
globals
=
unions
[
x
.
globals
\\
x
<-
xids
]
{
locals
=
unions
[
x
.
locals
\\
x
<-
xids
]
,
globals
=
unions
[
x
.
globals
\\
x
<-
xids
]
,
record_fields
=
unions
[
x
.
record_fields
\\
x
<-
xids
]
}
where
xids
=
map
(
idents
c
)
xs
...
...
@@ -79,7 +82,7 @@ where
PE_Bound
_
->
zero
PE_Lambda
_
args
rhs
_
->
noLocals
(
idents
ICPattern
args
+
idents
ICExpression
rhs
)
PE_Tuple
es
->
idents
c
es
PE_Record
init
_
fields
->
idents
c
init
+
idents
c
[
f
.
bind_src
\\
f
<-
fields
]
PE_Record
init
_
fields
->
idents
c
init
+
idents
c
[
f
.
bind_dst
\\
f
<-
fields
]
+
idents
c
[
f
.
bind_src
\\
f
<-
fields
]
PE_ArrayPattern
_
->
abort
"idents PE_ArrayPattern
\n
"
//(PE_ArrayPattern ![ElemAssignment]
PE_UpdateComprehension
base
(
PE_Update
_
sels
new
)
_
qs
->
noLocals
(
idents
ICExpression
[
base
,
new
]
+
idents
ICExpression
sels
+
idents
ICPattern
qs
)
...
...
@@ -155,6 +158,11 @@ where
idents
ICPattern
q
.
qual_let_defs
+
idents
ICExpression
q
.
qual_filter
instance
idents
FieldNameOrQualifiedFieldName
where
idents
_
(
FieldName
id
)
=
{
zero
&
record_fields
=
fromList
[
id
.
id_name
]}
idents
_
(
QualifiedFieldName
_
f
)
=
{
zero
&
record_fields
=
fromList
[
f
]}
instance
idents
Generator
where
idents
ICPattern
g
=
idents
ICPattern
g
.
gen_pattern
+
idents
ICExpression
g
.
gen_expr
...
...
@@ -170,7 +178,7 @@ where
instance
idents
ParsedSelection
where
idents
c
ps
=
case
ps
of
PS_Record
id
_
->
idents
c
id
PS_QualifiedRecord
_
s
_
->
idents
c
s
PS_Record
id
_
->
{
zero
&
record_fields
=
fromList
[
id
.
id_name
]}
PS_QualifiedRecord
_
s
_
->
{
zero
&
record_fields
=
fromList
[
s
]}
PS_Array
e
->
idents
c
e
PS_Erroneous
->
zero
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment