Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
visitors
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
POTTIER Francois
visitors
Commits
dce14c24
Commit
dce14c24
authored
8 years ago
by
POTTIER Francois
Browse files
Options
Downloads
Patches
Plain Diff
Split [fold] out of [ascend].
parent
68c83e98
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Visitors.ml
+34
-17
34 additions, 17 deletions
src/Visitors.ml
with
34 additions
and
17 deletions
src/Visitors.ml
+
34
−
17
View file @
dce14c24
...
@@ -679,30 +679,26 @@ let ifbuild (attrs : attributes) (builder : builder) : builder =
...
@@ -679,30 +679,26 @@ let ifbuild (attrs : attributes) (builder : builder) : builder =
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* [ascend] builds the code that forms the ascending part of a visitor method
(* [ascend] builds the code that forms the ascending part of a visitor method,
(associated with a data constructor or record). The ascending part of the
that is, the code found after the recursive calls. The parameters of the
method is the code found after the recursive calls. The parameters of the
function [ascend] are as follows:
function [ascend] are as follows:
[decl] the type declaration under which we are working
[tys] the types of the components of the data constructor or record
[this] a variable that denotes the data structure that is visited
[this] a variable that denotes the data structure that is visited
[subjects] the matrix of arguments to the recursive calls
[subjects] the matrix of arguments to the recursive calls
[rs], [ss] vectors of variables that denote the results of the calls
[rs], [ss] vectors of variables that denote the results of the calls
[builder] code for reconstructing a data structure
[builder] code for reconstructing a data structure
[
m
]
the name of the virtual ascending method
[
fold
]
what to do if this is a [fold] visitor
*)
*)
let
ascend
let
ascend
(
decl
:
type_declaration
)
(
tys
:
core_types
)
(
this
:
variable
)
(
this
:
variable
)
(
subjects
:
expressions
list
)
(
subjects
:
expressions
list
)
(
rs
:
variables
)
(
rs
:
variables
)
(
ss
:
variables
)
(
ss
:
variables
)
(
builder
:
builder
)
(
builder
:
builder
)
(
m
:
methode
)
(
fold
:
unit
->
expression
)
:
expression
=
=
let
rec
ascend
scheme
=
let
rec
ascend
scheme
=
match
scheme
with
match
scheme
with
...
@@ -729,15 +725,34 @@ let ascend
...
@@ -729,15 +725,34 @@ let ascend
returned by a [map] visitor and by a [reduce] visitor. *)
returned by a [map] visitor and by a [reduce] visitor. *)
tuple
[
ascend
Map
;
ascend
Reduce
]
tuple
[
ascend
Map
;
ascend
Reduce
]
|
Fold
->
|
Fold
->
(* A [fold] visitor invokes a virtual method, named [m], passing [env]
fold
()
and [rs] as arguments. *)
vhook
m
(
env
::
rs
)
(
ty_arrows
(
ty_env
::
map
fold_result_type
tys
)
(
decl_result_type
decl
))
in
in
ascend
X
.
scheme
ascend
X
.
scheme
(* [fold decl m rs tys] builds the code that forms the ascending part of a
visitor method, when this method is associated with a data constructor or
record, and when the scheme is [fold]. The parameters of the function
[ascend] are as follows:
[decl] the type declaration under which we are working
[m] the name of the virtual ascending method
[rs] a vector of variables that denote the results of the calls
[tys] the types of the components of this data constructor or record
*)
let
fold
(
decl
:
type_declaration
)
(
m
:
methode
)
(
rs
:
variables
)
(
tys
:
core_types
)
()
(* delay the side effect! *)
=
(* Invoke the virtual ascending method, with [env] and [rs] as arguments.
As a side effect, declare the existence of this method. *)
vhook
m
(
env
::
rs
)
(
ty_arrows
(
ty_env
::
map
fold_result_type
tys
)
(
decl_result_type
decl
)
)
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* [visit_type env_in_scope ty] builds a small expression that represents the
(* [visit_type env_in_scope ty] builds a small expression that represents the
...
@@ -989,7 +1004,8 @@ let constructor_declaration decl (cd : constructor_declaration) : case =
...
@@ -989,7 +1004,8 @@ let constructor_declaration decl (cd : constructor_declaration) : case =
(
visitor_fun_type
(
transmit
(
decl_type
decl
)
tys
)
(
decl_type
decl
))))
(
visitor_fun_type
(
transmit
(
decl_type
decl
)
tys
)
(
decl_type
decl
))))
(
bind
rs
ss
(
bind
rs
ss
(
visit_types
tys
subjects
)
(
visit_types
tys
subjects
)
(
ascend
decl
tys
this
subjects
rs
ss
builder
(
datacon_ascending_method
cd
))
(
ascend
this
subjects
rs
ss
builder
(
fold
decl
(
datacon_ascending_method
cd
)
rs
tys
))
)
)
)
)
...
@@ -1032,7 +1048,8 @@ let visit_decl (decl : type_declaration) : expression =
...
@@ -1032,7 +1048,8 @@ let visit_decl (decl : type_declaration) : expression =
and
ss
=
summaries
labels
in
and
ss
=
summaries
labels
in
bind
rs
ss
bind
rs
ss
(
visit_types
tys
subjects
)
(
visit_types
tys
subjects
)
(
ascend
decl
tys
(
hd
xs
)
subjects
rs
ss
builder
(
tycon_ascending_method
decl
))
(
ascend
(
hd
xs
)
subjects
rs
ss
builder
(
fold
decl
(
tycon_ascending_method
decl
)
rs
tys
))
)
)
(* A sum type. *)
(* A sum type. *)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment