GNU TeXmacsUser manualReferenceAboutEnglish
The evaluator of the style rewriter and its coverage

This page describes

src/src/Style/Evaluate/

and compares it with the real evaluator edit_env_rep::exec (

Typeset/Env/env_exec.cpp

), whose semantics are documented in evaluation of primitives.

1.Entry points

memorizer evaluate (environment env, tree t)
(top level)

Opens the stack of sub-computations (memorize_initialize), makes env the current environment std_env, evaluates t, restores the previous environment and returns the top-level memorizer (memorize_finalize). The editor calls it as mem= evaluate (ste, cct).

tree evaluate (tree t)
(memoized evaluation)

Atomic trees are returned unchanged and are not memoized. For a compound tree, an evaluate_memorizer keyed on (std_env, t) is created; if it is already known (is_memorized), its result tree is returned and its output environment becomes std_env. Otherwise the evaluation proceeds in a new level of the stack: evaluate_impl (t) computes the result, decorate_ip (t, r) gives the new parts of the result the inverse path of t, and the result tree and the environment after the evaluation are stored in the memorizer. Every call prints Evaluate, Memorized or Computed on the console.

rewrite (tree) (

evaluate_rewrite.cpp

) and the evaluation of inactive markup (

evaluate_inactive.cpp

) are memoized in the same way, with memorizer types MEMORIZE_REWRITE and MEMORIZE_INACTIVE, and print similar traces. Helper functions such as evaluate_string evaluate and then extract an atomic result.

2.Dispatching

evaluate_impl (

evaluate_main.cpp

) is a large switch on the label of the tree, with the same grouping as edit_env_rep::exec: typesetting primitives with side effects, macro expansion, control flow, boolean, arithmetic, textual and length operations, style and activation commands, and miscellaneous ones. Labels which are not handled fall into the default branch:

Macro application uses substitution rather than argument frames (ALTERNATIVE_MACRO_EXPANSION): the arguments are substituted into the body by expand (tree, assoc_environment), sharing all unchanged subtrees, and the result is evaluated. The details are in the experimental evaluator.

3.Coverage

Comparing the case labels of evaluate_impl with those of edit_env_rep::exec (with commented-out code removed), the experimental evaluator handles 126 of the 175 labels of the real one, and no label that the real one does not handle. The 49 missing labels are evaluated componentwise by the default branch: their children are evaluated, but the primitive itself is not executed and stays in the result:

Themes

NEW_THEME, COPY_THEME, APPLY_THEME, SELECT_THEME.

Animations

ANIM_STATIC, ANIM_DYNAMIC, ANIM_TIME, ANIM_PORTION, MORPH.

Box placement

MOVE, SHIFT, RESIZE, CLIPPED, and BOX_INFO, FRAME_DIRECT, FRAME_INVERSE (whose cases and implementations are present but commented out, in

evaluate_main.cpp

and

evaluate_misc.cpp

).

Graphical effects

All EFF_* labels (EFF_MOVE, EFF_GAUSSIAN, EFF_OVAL, EFF_TURBULENCE, …: 15 labels).

Lengths

GUIPX_LENGTH, MS_LENGTH, S_LENGTH, and the corner lengths LCORNER_LENGTH, BCORNER_LENGTH, RCORNER_LENGTH, TCORNER_LENGTH.

Other primitives

MINIMUM, MAXIMUM, RGB_COLOR, RGB_ACCESS, FIND_ACCESSIBLE, FIND_FILE_UPWARDS, OCCURS_INSIDE, HAS_BINDING, GET_ATTACHMENT, FILTER_STYLE, VAR_MARK.

4.Placeholders among the handled primitives

Several primitives are dispatched but implemented only approximately, because the information they need belongs to the typesetter:

provide, or-value

Treated as assign and value respectively (marked “provisory” in

evaluate_main.cpp:112

, 122).

drd-props

evaluate_drd_props returns the empty string without doing anything (evaluate_macro.cpp:82-85).

Page and graphics lengths

evaluate_par_length, evaluate_paw_length and evaluate_pag_length return fixed values (15cm, 18cm and 23cm), evaluate_gw_length and evaluate_gh_length return 10cm and 6cm, and evaluate_gu_length returns 1cm (

evaluate_length.cpp

); the real computations are left in comments.

Bindings

evaluate_set_binding and evaluate_get_binding work on two static hash tables local_ref and global_ref of

evaluate_misc.cpp

, which are never connected to the references of the buffer, and set-binding evaluates to the empty string (the comment says the work of concater_rep::typeset_set_binding should be done instead).

Tables

Cell formats are not re-evaluated (FIXME in evaluate_table).

5.Rewriting

rewrite handles extern (calling Scheme), map-args, include (loading the file relative to base-file-name with load_inclusion), with-package and rewrite-inactive; evaluate_rewrite evaluates the rewritten tree. This parallels edit_env_rep::rewrite, described in evaluation of primitives. The with-package branch is one of the places that no longer compiles (see the pitfalls).

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".