Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
goaljobs
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
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
OpenSource
goaljobs
Commits
087ea609
Commit
087ea609
authored
11 years ago
by
Richard W.M. Jones
Browse files
Options
Downloads
Patches
Plain Diff
Implement goalloc.
parent
aa32ee45
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
goaljobs-reference.pod
+15
-0
15 additions, 0 deletions
goaljobs-reference.pod
pa_goal.ml
+8
-1
8 additions, 1 deletion
pa_goal.ml
with
23 additions
and
1 deletion
goaljobs-reference.pod
+
15
−
0
View file @
087ea609
...
...
@@ -193,6 +193,21 @@ would print:
my name is foo
=head2 goalloc
Inside goals, you can use C<goalloc> to get a printable source
location of the goal, ie:
let goal foo () =
printf "%s\n" goalloc
would print:
File "source.ml", line 2, characters 13-71 (end at line 3, character 23)
Note that the actual string format depends on the internal OCaml
function C<Loc.to_string> so it might change in future.
=head2 onfail, onsuccess, onrun
Inside goals you can register function(s) which run if the goal
...
...
This diff is collapsed.
Click to expand it.
pa_goal.ml
+
8
−
1
View file @
087ea609
...
...
@@ -68,6 +68,9 @@ let generate_let_goal _loc (r : rec_flag) (lets : binding) =
(* Rename the function to goal_<name>. *)
let
gname
=
"goal_"
^
name
in
(* Convert loc to string for goalloc. *)
let
goalloc
=
Loc
.
to_string
_loc
in
(* Split the function into parameters and body. *)
let
params
,
body
=
function_parameters
expr
in
...
...
@@ -87,6 +90,10 @@ let generate_let_goal _loc (r : rec_flag) (lets : binding) =
let
body
=
<:
expr
<
(* Define a goal name which the body may use. *)
let
goalname
=
$
str
:
name
$
in
(* Source location. *)
let
goalloc
=
$
str
:
goalloc
$
in
(* Define onsuccess, onrun, onfail functions that the body may call. *)
let
_on
,
_call_on
=
let
_on
fns
f
=
fns
:=
f
::
!
fns
in
...
...
@@ -109,7 +116,7 @@ let generate_let_goal _loc (r : rec_flag) (lets : binding) =
_call_onsuccesses
()
;
(* Avoid a compiler warning: *)
ignore
(
goalname
)
ignore
(
goalname
)
;
ignore
(
goalloc
)
with
(* target() within the body may raise Goal_OK meaning that the
* goal should be short-circuited. We return as if it's an
...
...
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