[Omake] Should "stringification" evaluate ValBody?
Aleksey Nogin
anogin at hrl.com
Thu Aug 2 10:16:43 PDT 2007
Currently, most of the "stringification" steps consider the ValBody to
be an empty space. Should they evaluate bodies instead?
The motivation for this is making it possible to pass a body in place of
a regular argument to a "regular" function that does not expect a body.
The attached patch forces the evaluation of ValBody in the following cases:
- string_of_quote_buf
- eval_prim_value (used by string_of_value, file_of_value)
- eval_catenable_value (used by values_of_value, tokens_of_value)
An alternative would be to have bodies eagerly evaluated (instead of
being packed into ValBody) whenever they are passed as arguments to
"regular" (eager arg evaluation) functions. A naive implementation of
this idea breaks things, though.
Aleksey
-------------- next part --------------
Index: src/eval/omake_eval.ml
===================================================================
--- src/eval/omake_eval.ml (revision 11505)
+++ src/eval/omake_eval.ml (working copy)
@@ -496,7 +496,6 @@
| ValFun _
| ValPrim _
| ValRules _
- | ValBody _
| ValMap _
| ValObject _
| ValChannel _
@@ -538,6 +537,7 @@
Buffer.add_string scratch_buf (venv_dirname venv dir2)
| ValNode node ->
Buffer.add_string scratch_buf (venv_nodename venv node)
+ | ValBody _
| ValKeyApply _
| ValApply _
| ValMaybeApply _
@@ -570,7 +570,6 @@
| ValFun _
| ValPrim _
| ValRules _
- | ValBody _
| ValMap _
| ValObject _
| ValChannel _
@@ -580,6 +579,8 @@
| ValArray []
| ValVar _ ->
()
+ | ValBody (env, body, _) ->
+ collect (snd (eval_sequence_exp (venv_with_env venv env) pos body))
| ValSequence vl
| ValQuote vl ->
List.iter collect vl
@@ -700,7 +701,6 @@
| ValFun _
| ValPrim _
| ValRules _
- | ValBody _
| ValMap _
| ValObject _
| ValChannel _
@@ -709,6 +709,7 @@
| ValOther _
| ValVar _ ->
collect (Lm_string_util.tokens_atomic tokens v) vl vll
+ | ValBody _
| ValApply _
| ValKeyApply _
| ValMaybeApply _
@@ -804,7 +805,6 @@
| ValFun _
| ValPrim _
| ValRules _
- | ValBody _
| ValMap _
| ValObject _
| ValChannel _
@@ -813,6 +813,7 @@
| ValOther _
| ValVar _ ->
collect (Lm_string_util.tokens_atomic tokens (TokString v)) vl vll
+ | ValBody _
| ValApply _
| ValKeyApply _
| ValMaybeApply _
@@ -1128,6 +1129,9 @@
(try venv_find_field_internal_exn obj builtin_sym with
Not_found ->
v)
+ | ValBody (env, body, _) ->
+ let v = snd (eval_sequence_exp (venv_with_env venv env) pos body) in
+ eval_prim_value venv pos v
| _ ->
v
@@ -1157,6 +1161,9 @@
with
Not_found ->
v)
+ | ValBody (env, body, _) ->
+ let v = snd (eval_sequence_exp (venv_with_env venv env) pos body) in
+ eval_catenable_value venv pos v
| _ ->
v
More information about the OMake-Devel
mailing list