Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
b59ef008
Commit
b59ef008
authored
May 26, 2014
by
Julien Lopez
Browse files
Remove old attempt to add a variable to each pattern at compile time
parent
ed82611c
Changes
2
Hide whitespace changes
Inline
Side-by-side
compile/compile.ml
View file @
b59ef008
...
...
@@ -181,18 +181,10 @@ and compile_branches env (brs : Typed.branches) =
(* p_i / t_i -> br.Typed.br_pat / br.Typed.br_type
* p_i / t_i is used here to add elements to env.gamma *)
and
compile_branch
env
br
=
(* We add a fresh variable "pat<nb>:x" for each pattern *)
let
t
,
fv
,
d
=
br
.
Typed
.
br_pat
.
Patterns
.
descr
in
let
fv
,
d
=
incr
Patterns
.
counter
;
let
freshname
=
"pat"
^
(
string_of_int
!
Patterns
.
counter
)
^
":x"
in
let
fv
=
fv
@
[
!
Patterns
.
counter
,
freshname
]
in
fv
,
Patterns
.
Cap
((
Types
.
any
,
fv
,
Patterns
.
Capture
(
!
Patterns
.
counter
,
freshname
))
,
(
t
,
fv
,
d
))
in
let
pat
=
{
br
.
Typed
.
br_pat
with
Patterns
.
descr
=
(
t
,
fv
,
d
);
Patterns
.
fv
=
fv
}
in
let
env
=
List
.
fold_left
enter_local
env
fv
in
let
m
=
Patterns
.
filter
(
Types
.
descr
(
Patterns
.
accept
pat
))
pat
in
let
env
=
List
.
fold_left
enter_local
env
(
Patterns
.
fv
br
.
Typed
.
br_pat
)
in
let
m
=
Patterns
.
filter
(
Types
.
descr
(
Patterns
.
accept
br
.
Typed
.
br_pat
))
br
.
Typed
.
br_pat
in
let
env
=
{
env
with
gamma
=
IdMap
.
union_disj
m
env
.
gamma
}
in
(
pat
,
compile
env
br
.
Typed
.
br_body
)
(
br
.
Typed
.
br_
pat
,
compile
env
br
.
Typed
.
br_body
)
let
enter_globals
env
n
=
match
env
.
cu
with
|
None
->
List
.
fold_left
enter_global_toplevel
env
n
...
...
types/patterns.ml
View file @
b59ef008
...
...
@@ -370,13 +370,10 @@ x=(1,2)
|
Cup
((
a1
,_,_
)
as
p1
,
p2
)
->
approx_var
seen
p2
(
Types
.
diff
t
a1
)
(
approx_var
seen
p1
(
Types
.
cap
t
a1
)
xs
)
|
Cap
((
_
,
fv1
,
d1
)
as
p1
,
((
_
,
fv2
,
d2
)
as
p2
))
->
(
match
d1
with
|
Capture
(
_
,
name
)
when
Str
.
string_match
(
Str
.
regexp
"pat[0-9]+:"
)
(
Encodings
.
Utf8
.
get_str
name
)
0
->
(
match
d2
with
|
Constr
_
->
fv2
|
_
->
approx_var
seen
p2
t
xs
)
|
_
->
IdSet
.
cup
(
approx_var
seen
p1
t
(
IdSet
.
cap
fv1
xs
))
(
approx_var
seen
p2
t
(
IdSet
.
cap
fv2
xs
)))
|
Cap
((
_
,
fv1
,_
)
as
p1
,
((
_
,
fv2
,_
)
as
p2
))
->
IdSet
.
cup
(
approx_var
seen
p1
t
(
IdSet
.
cap
fv1
xs
))
(
approx_var
seen
p2
t
(
IdSet
.
cap
fv2
xs
))
|
Capture
_
->
xs
|
Constant
(
_
,
c
)
->
...
...
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