1 
2 /******************************************************************************
3 * MODULE     : evaluate_main.cpp
4 * DESCRIPTION: standard style evaluation
5 * COPYRIGHT  : (C) 2006  Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11 
12 #ifndef EVALUATE_MAIN_H
13 #define EVALUATE_MAIN_H
14 #include "../Environment/environment.hpp"
15 #include "../Memorizer/memorizer.hpp"
16 
17 extern environment std_env;
18 
19 tree evaluate (tree t);
20 tree evaluate_error (string message);
21 tree evaluate_error (string message, tree a1);
22 tree evaluate_error (string message, array<tree> args);
23 string evaluate_string (tree t);
24 memorizer evaluate (environment env, tree t);
25 tree expand (tree t, bool flag);
26 
27 /* Tree rewriting */
28 #define INACTIVE_INLINE_RECURSE  0
29 #define INACTIVE_INLINE_ONCE     1
30 #define INACTIVE_INLINE_ERROR    2
31 #define INACTIVE_BLOCK_RECURSE   3
32 #define INACTIVE_BLOCK_ONCE      4
33 #define INACTIVE_BLOCK_ERROR     5
34 
35 tree rewrite (tree t);
36 tree evaluate_rewrite (tree t);
37 tree rewrite_inactive (tree t, int inactive_mode);
38 
39 /* Length arithmetic */
40 bool is_length (string s);
41 bool is_length (tree t);
42 SI as_length (string s);
43 SI as_length (tree t);
44 bool is_anylen (tree t);
45 tree as_tmlen (tree t);
46 tree tmlen_plus (tree t1, tree t2);
47 tree tmlen_times (double sc, tree t);
48 tree tmlen_over (tree t1, tree t2);
49 
50 /* Macro expansion */
51 tree evaluate_assign (tree t);
52 tree evaluate_with (tree t);
53 tree evaluate_provides (tree t);
54 tree evaluate_value (tree t);
55 tree evaluate_quote_value (tree t);
56 tree evaluate_drd_props (tree t);
57 tree evaluate_compound (tree t);
58 tree evaluate_arg (tree t);
59 tree evaluate_quote_arg (tree t);
60 tree evaluate_get_label (tree t);
61 tree evaluate_get_arity (tree t);
62 
63 /* Quoting and evaluation */
64 tree evaluate_eval_args (tree t);
65 tree evaluate_quasiquote (tree t);
66 
67 /* Control structures */
68 tree evaluate_if (tree t);
69 tree evaluate_case (tree t);
70 tree evaluate_while (tree t);
71 tree evaluate_for_each (tree t);
72 tree evaluate_include (tree t);
73 tree evaluate_use_package (tree t);
74 tree evaluate_use_module (tree t);
75 
76 /* Computational markup */
77 tree evaluate_or (tree t);
78 tree evaluate_xor (tree t);
79 tree evaluate_and (tree t);
80 tree evaluate_not (tree t);
81 tree evaluate_plus_minus (tree t);
82 tree evaluate_times_over (tree t);
83 tree evaluate_divide (tree t);
84 tree evaluate_modulo (tree t);
85 tree evaluate_math_sqrt (tree t);
86 tree evaluate_exp (tree t);
87 tree evaluate_log (tree t);
88 tree evaluate_pow (tree t);
89 tree evaluate_cos (tree t);
90 tree evaluate_sin (tree t);
91 tree evaluate_tan (tree t);
92 tree evaluate_merge (tree t);
93 tree evaluate_length (tree t);
94 tree evaluate_range (tree t);
95 tree evaluate_number (tree t);
96 tree evaluate_date (tree t);
97 tree evaluate_translate (tree t);
98 tree evaluate_change_case (tree t);
99 tree evaluate_find_file (tree t);
100 tree evaluate_is_tuple (tree t);
101 tree evaluate_lookup (tree t);
102 tree evaluate_equal (tree t);
103 tree evaluate_unequal (tree t);
104 tree evaluate_less (tree t);
105 tree evaluate_lesseq (tree t);
106 tree evaluate_greater (tree t);
107 tree evaluate_greatereq (tree t);
108 tree evaluate_blend (tree t);
109 
110 /* Length units */
111 tree evaluate_cm_length ();
112 tree evaluate_mm_length ();
113 tree evaluate_in_length ();
114 tree evaluate_pt_length ();
115 tree evaluate_bp_length ();
116 tree evaluate_dd_length ();
117 tree evaluate_pc_length ();
118 tree evaluate_cc_length ();
119 tree evaluate_fs_length ();
120 tree evaluate_fbs_length ();
121 tree evaluate_em_length ();
122 tree evaluate_ln_length ();
123 tree evaluate_sep_length ();
124 tree evaluate_yfrac_length ();
125 tree evaluate_ex_length ();
126 tree evaluate_fn_length ();
127 tree evaluate_fns_length ();
128 tree evaluate_bls_length ();
129 tree evaluate_fnbot_length ();
130 tree evaluate_fntop_length ();
131 tree evaluate_spc_length ();
132 tree evaluate_xspc_length ();
133 tree evaluate_par_length ();
134 tree evaluate_pag_length ();
135 tree evaluate_gw_length ();
136 tree evaluate_gh_length ();
137 tree evaluate_gu_length ();
138 tree evaluate_tmpt_length ();
139 tree evaluate_px_length ();
140 tree evaluate_msec_length ();
141 tree evaluate_sec_length ();
142 tree evaluate_min_length ();
143 tree evaluate_hr_length ();
144 
145 /* Miscellaneous primitives */
146 tree evaluate_formatting (tree t, string v);
147 tree evaluate_table (tree t);
148 tree evaluate_hard_id (tree t);
149 tree evaluate_script (tree t);
150 tree evaluate_set_binding (tree t);
151 tree evaluate_get_binding (tree t);
152 tree evaluate_pattern (tree t);
153 tree evaluate_point (tree t);
154 //tree evaluate_box_info (tree t);
155 //tree evaluate_frame_direct (tree t);
156 //tree evaluate_frame_inverse (tree t);
157 
158 /* Other routines */
159 class url;
160 tree load_inclusion (url u);
161 bool is_percentage (tree t, string s);
162 bool is_percentage (tree t);
163 double as_percentage (tree t);
164 bool is_magnification (string s);
165 double get_magnification (string s);
166 void transfer_ip (tree src, tree dest);
167 void decorate_ip (tree src, tree dest);
168 
169 #endif // defined EVLUATE_MAIN_H
170