texnesting.h /size: 2924 b    last modification: 2024-01-16 10:22
1/*
2    See license.txt in the root of this project.
3*/
4
5# ifndef LMT_NESTING_H
6# define LMT_NESTING_H
7
8/* 
9    Todo: make this record 6*4 smaller, not all are halfwords, although padding might then make us
10    end up with the same size. We also end up with plenty of casts elsewhere. 
11*/
12
13typedef struct list_state_record {
14    int      mode;                 // singleword 
15    halfword head;                 
16    halfword tail;                 
17    int      prev_graf;            
18    int      mode_line;            
19    halfword prev_depth;           // scaled
20    halfword space_factor;         
21    halfword direction_stack;      
22    int      math_dir;             // singleword 
23    int      math_style;           // singleword 
24    int      math_scale;           
25    int      math_main_style;      // singleword 
26    halfword delimiter;            // todo: get rid of these and use the stack 
27    halfword incomplete_noad;      // todo: get rid of these and use the stack 
28    halfword math_flatten;         // singleword 
29    halfword math_begin;           // singleword 
30    halfword math_end;             // singleword 
31    halfword math_mode;            // singleword 
32    halfword tolerance;
33    halfword pretolerance;
34} list_state_record;
35
36typedef struct nest_state_info {
37    list_state_record *nest;
38    memory_data        nest_data;
39    int                shown_mode; // singleword
40    int                math_mode;  // singleword
41} nest_state_info;
42
43extern nest_state_info lmt_nest_state;
44
45# define cur_list lmt_nest_state.nest[lmt_nest_state.nest_data.ptr] /*tex The \quote {top} semantic state. */
46# define cur_mode (abs(cur_list.mode))
47
48extern void        tex_initialize_nest_state (void);
49/*     int         tex_room_on_nest_stack    (void); */
50extern void        tex_initialize_nesting    (void);
51extern void        tex_push_nest             (void);
52extern void        tex_pop_nest              (void);
53extern void        tex_tail_prepend          (halfword p);
54extern void        tex_tail_append           (halfword p);
55extern void        tex_tail_append_list      (halfword p);
56extern halfword    tex_pop_tail              (void);
57extern const char *tex_string_mode           (int m);
58extern void        tex_show_activities       (void);
59extern int         tex_vmode_nest_index      (void);
60
61/*tex
62    When we use a macro instead of a function we need to use an intermediate variable because |_p_|
63    can be a functioncall itself (something |new_*|). The gain is a little performance because this
64    one is called a lot. The loss is a bit larger binary. There are some more macros sensitive for
65    this, like the ones that couple nodes. Also, inlining a function can spoil this game!
66*/
67
68/*
69# define tail_append(_p_) do { \
70    halfword __p__ = _p_ ; \
71    tex_couple_nodes(cur_list.tail, __p__); \
72    cur_list.tail = __p__; \
73} while (0)
74*/
75
76/*
77# define tail_append tex_tail_append
78*/
79
80# endif
81