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
3037d748
Commit
3037d748
authored
May 26, 2014
by
Julien Lopez
Browse files
Merge from master to propagate
parents
180e9317
b59ef008
Changes
2
Hide whitespace changes
Inline
Side-by-side
compile/compile.ml
View file @
3037d748
...
@@ -199,18 +199,10 @@ and compile_branches env (brs : Typed.branches) =
...
@@ -199,18 +199,10 @@ and compile_branches env (brs : Typed.branches) =
(* p_i / t_i -> br.Typed.br_pat / br.Typed.br_type
(* 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 *)
* p_i / t_i is used here to add elements to env.gamma *)
and
compile_branch
env
br
=
and
compile_branch
env
br
=
(* We add a fresh variable "pat<nb>:x" for each pattern *)
let
env
=
List
.
fold_left
enter_local
env
(
Patterns
.
fv
br
.
Typed
.
br_pat
)
in
let
t
,
fv
,
d
=
br
.
Typed
.
br_pat
.
Patterns
.
descr
in
let
m
=
Patterns
.
filter
(
Types
.
descr
(
Patterns
.
accept
br
.
Typed
.
br_pat
))
br
.
Typed
.
br_pat
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
=
{
env
with
gamma
=
IdMap
.
union_disj
m
env
.
gamma
}
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
let
enter_globals
env
n
=
match
env
.
cu
with
|
None
->
List
.
fold_left
enter_global_toplevel
env
n
|
None
->
List
.
fold_left
enter_global_toplevel
env
n
...
...
types/patterns.ml
View file @
3037d748
...
@@ -371,18 +371,9 @@ x=(1,2)
...
@@ -371,18 +371,9 @@ x=(1,2)
approx_var
seen
p2
(
Types
.
diff
t
a1
)
approx_var
seen
p2
(
Types
.
diff
t
a1
)
(
approx_var
seen
p1
(
Types
.
cap
t
a1
)
xs
)
(
approx_var
seen
p1
(
Types
.
cap
t
a1
)
xs
)
|
Cap
((
_
,
fv1
,_
)
as
p1
,
((
_
,
fv2
,_
)
as
p2
))
->
|
Cap
((
_
,
fv1
,_
)
as
p1
,
((
_
,
fv2
,_
)
as
p2
))
->
IdSet
.
cup
IdSet
.
cup
(
approx_var
seen
p1
t
(
IdSet
.
cap
fv1
xs
))
(
approx_var
seen
p1
t
(
IdSet
.
cap
fv1
xs
))
(
approx_var
seen
p2
t
(
IdSet
.
cap
fv2
xs
))
(
approx_var
seen
p2
t
(
IdSet
.
cap
fv2
xs
))
(*
| Cap ((_,fv1,d1) as p1,((_,fv2,d2) as p2)) ->
(match d1 with
| Capture(_, name) when Str.string_match (Str.regexp "pat[0-9]+:") 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)))
*)
|
Capture
_
->
|
Capture
_
->
xs
xs
|
Constant
(
_
,
c
)
->
|
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