Back to index

texmacs  1.0.7.15
Defines | Functions | Variables
evaluate_main.hpp File Reference
#include "../Environment/environment.hpp"
#include "../Memorizer/memorizer.hpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define INACTIVE_INLINE_RECURSE   0
#define INACTIVE_INLINE_ONCE   1
#define INACTIVE_INLINE_ERROR   2
#define INACTIVE_BLOCK_RECURSE   3
#define INACTIVE_BLOCK_ONCE   4
#define INACTIVE_BLOCK_ERROR   5

Functions

tree evaluate (tree t)
tree evaluate_error (string message)
tree evaluate_error (string message, tree a1)
tree evaluate_error (string message, array< tree > args)
string evaluate_string (tree t)
memorizer evaluate (environment env, tree t)
tree expand (tree t, bool flag)
tree rewrite (tree t)
tree evaluate_rewrite (tree t)
tree rewrite_inactive (tree t, int inactive_mode)
bool is_length (string s)
bool is_length (tree t)
SI as_length (string s)
SI as_length (tree t)
bool is_anylen (tree t)
tree as_tmlen (tree t)
tree tmlen_plus (tree t1, tree t2)
tree tmlen_times (double sc, tree t)
tree tmlen_over (tree t1, tree t2)
tree evaluate_assign (tree t)
tree evaluate_with (tree t)
tree evaluate_provides (tree t)
tree evaluate_value (tree t)
tree evaluate_quote_value (tree t)
tree evaluate_drd_props (tree t)
tree evaluate_compound (tree t)
tree evaluate_arg (tree t)
tree evaluate_quote_arg (tree t)
tree evaluate_get_label (tree t)
tree evaluate_get_arity (tree t)
tree evaluate_eval_args (tree t)
tree evaluate_quasiquote (tree t)
tree evaluate_if (tree t)
tree evaluate_case (tree t)
tree evaluate_while (tree t)
tree evaluate_for_each (tree t)
tree evaluate_include (tree t)
tree evaluate_use_package (tree t)
tree evaluate_use_module (tree t)
tree evaluate_or (tree t)
tree evaluate_xor (tree t)
tree evaluate_and (tree t)
tree evaluate_not (tree t)
tree evaluate_plus_minus (tree t)
tree evaluate_times_over (tree t)
tree evaluate_divide (tree t)
tree evaluate_modulo (tree t)
tree evaluate_math_sqrt (tree t)
tree evaluate_exp (tree t)
tree evaluate_log (tree t)
tree evaluate_pow (tree t)
tree evaluate_cos (tree t)
tree evaluate_sin (tree t)
tree evaluate_tan (tree t)
tree evaluate_merge (tree t)
tree evaluate_length (tree t)
tree evaluate_range (tree t)
tree evaluate_number (tree t)
tree evaluate_date (tree t)
tree evaluate_translate (tree t)
tree evaluate_change_case (tree t)
tree evaluate_find_file (tree t)
tree evaluate_is_tuple (tree t)
tree evaluate_lookup (tree t)
tree evaluate_equal (tree t)
tree evaluate_unequal (tree t)
tree evaluate_less (tree t)
tree evaluate_lesseq (tree t)
tree evaluate_greater (tree t)
tree evaluate_greatereq (tree t)
tree evaluate_cm_length ()
tree evaluate_mm_length ()
tree evaluate_in_length ()
tree evaluate_pt_length ()
tree evaluate_bp_length ()
tree evaluate_dd_length ()
tree evaluate_pc_length ()
tree evaluate_cc_length ()
tree evaluate_fs_length ()
tree evaluate_fbs_length ()
tree evaluate_em_length ()
tree evaluate_ln_length ()
tree evaluate_sep_length ()
tree evaluate_yfrac_length ()
tree evaluate_ex_length ()
tree evaluate_fn_length ()
tree evaluate_fns_length ()
tree evaluate_bls_length ()
tree evaluate_fnbot_length ()
tree evaluate_fntop_length ()
tree evaluate_spc_length ()
tree evaluate_xspc_length ()
tree evaluate_par_length ()
tree evaluate_pag_length ()
tree evaluate_gw_length ()
tree evaluate_gh_length ()
tree evaluate_tmpt_length ()
tree evaluate_px_length ()
tree evaluate_msec_length ()
tree evaluate_sec_length ()
tree evaluate_min_length ()
tree evaluate_hr_length ()
tree evaluate_formatting (tree t, string v)
tree evaluate_table (tree t)
tree evaluate_hard_id (tree t)
tree evaluate_script (tree t)
tree evaluate_set_binding (tree t)
tree evaluate_get_binding (tree t)
tree evaluate_pattern (tree t)
tree evaluate_point (tree t)
tree load_inclusion (url u)
bool is_percentage (tree t, string s)
bool is_percentage (tree t)
double as_percentage (tree t)
bool is_magnification (string s)
double get_magnification (string s)
void transfer_ip (tree src, tree dest)
void decorate_ip (tree src, tree dest)

Variables

environment std_env

Define Documentation

#define INACTIVE_BLOCK_ERROR   5

Definition at line 33 of file evaluate_main.hpp.

#define INACTIVE_BLOCK_ONCE   4

Definition at line 32 of file evaluate_main.hpp.

#define INACTIVE_BLOCK_RECURSE   3

Definition at line 31 of file evaluate_main.hpp.

#define INACTIVE_INLINE_ERROR   2

Definition at line 30 of file evaluate_main.hpp.

#define INACTIVE_INLINE_ONCE   1

Definition at line 29 of file evaluate_main.hpp.

#define INACTIVE_INLINE_RECURSE   0

Definition at line 28 of file evaluate_main.hpp.


Function Documentation

Definition at line 104 of file evaluate_length.cpp.

                     {
  tree r= as_tmlen (l);
  string s= r[N(r)==1? 0: 1]->label;
  return (SI) (as_double (s));
}

Here is the call graph for this function:

Here is the caller graph for this function:

SI as_length ( tree  t)

Definition at line 111 of file evaluate_length.cpp.

                   {
  tree r= as_tmlen (t);
  string s= r[N(r)==1? 0: 1]->label;
  return (SI) (as_double (s));
}

Here is the call graph for this function:

double as_percentage ( tree  t)

Definition at line 286 of file env_length.cpp.

                       {
  return as_double (t->label (0, N (t->label) - 1)) / 100.0;
}
tree as_tmlen ( tree  t)

Definition at line 75 of file evaluate_length.cpp.

                  {
  if (is_func (t, TMLEN)) {
    if (is_double (t[0])) return t;
    if (N(t) < 3) return as_tmlen (t[0]);
    tree _min= as_tmlen (t[0]);
    tree _def= as_tmlen (t[1]);
    tree _max= as_tmlen (t[2]);
    _min= _min[N(_min) == 3? 1: 0];
    _def= _def[N(_def) == 3? 1: 0];
    _max= _max[N(_max) == 3? 1: 0];
    return tree (TMLEN, _min, _def, _max);
  }
  else if (is_atomic (t)) {
    string s= t->label;
    int start= 0, i, n=N(s);
    while ((start+1<n) && (s[start]=='-') && (s[start+1]=='-')) start += 2;
    for (i=start; (i<n) && ((s[i]<'a') || (s[i]>'z')); i++) {}
    string s1= s (start, i);
    string s2= s (i, n);
    if (!(is_double (s1) && is_locase_alpha (s2))) return tree (TMLEN, "0");
    return tmlen_times (as_double (s1),
                     as_tmlen (evaluate (compound (s2 * "-length"))));
  }
  else if (is_func (t, MACRO, 1))
    return as_tmlen (evaluate (t[0]));
  else return tree (TMLEN, "0");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void decorate_ip ( tree  src,
tree  dest 
)

Definition at line 84 of file evaluate_main.cpp.

                                  {
  decorate_ip (dest, decorate_right (obtain_ip (src)));
}

Here is the call graph for this function:

tree evaluate ( tree  t)

Definition at line 403 of file evaluate_main.cpp.

                  {
  if (is_atomic (t)) return t;
  cout << "Evaluate "
    // << obtain_ip (t) << " "
       << "[" << (t.operator -> ())
       << ", " << (std_env.operator -> ()) << "] "
       << t << INDENT << LF;
  memorizer mem= evaluate_memorizer (std_env, t);
  if (is_memorized (mem)) {
    cout << UNINDENT << "Memorized " << mem->get_tree () << LF;
    std_env= mem->get_environment ();
    return mem->get_tree ();
  }
  memorize_start ();
  tree r= evaluate_impl (t);
  decorate_ip (t, r);
  mem->set_tree (r);
  mem->set_environment (std_env);
  memorize_end ();
  cout << UNINDENT << "Computed " << mem->get_tree ()
    // << " at " << obtain_ip (r);
       << LF;
  return mem->get_tree ();
}

Here is the call graph for this function:

memorizer evaluate ( environment  env,
tree  t 
)

Definition at line 429 of file evaluate_main.cpp.

                                   {
  environment old_env= std_env;
  memorize_initialize ();
  std_env= env;
  (void) evaluate (t);
  std_env= old_env;
  return memorize_finalize ();
}

Here is the call graph for this function:

Definition at line 40 of file evaluate_boolean.cpp.

                      {
  if (N(t)<2) return evaluate_error ("bad and");
  for (int i=0; i<N(t); i++) {
    tree u= evaluate (t[i]);
    if (!is_bool (u)) return evaluate_error ("bad and");
    if (!as_bool (u)) return as_string_bool (false);
  }
  return as_string_bool (true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 22 of file evaluate_macro.cpp.

                         {
  int i, n=N(t), k=n>>1;
  assoc_environment local (k);
  for (i=0; i<k; i++) {
    string var= as_string (evaluate (t[i<<1]));
    tree   val= evaluate (t[(i<<1)+1]);
    local->raw_write (i, var, val);
  }
  assign (std_env, local);
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 255 of file evaluate_length.cpp.

                       {
  double fs= (std_font_base_size () * std_magnification () *
             std_inch () * std_font_size ()) / 72.0;
  return tmlen_plus (tree (TMLEN, as_string (fs)),
                   tree (as_vspace (std_env [PAR_SEP])));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 186 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch() / 72.0)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 36 of file evaluate_control.cpp.

                       {
  if (N(t) < 2) return evaluate_error ("bad case");
  int i, n= N(t);
  for (i=0; i<(n-1); i+=2) {
    tree u= evaluate (t[i]);
    if (!is_bool (u)) return evaluate_error ("bad case");
    if (as_bool (u)) return evaluate (t[i+1]);
  }
  if (i<n) return evaluate (t[i]);
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 192 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (4.531 * std_inch() / 25.4)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file evaluate_textual.cpp.

                              {
  if (N(t) < 2) return evaluate_error ("bad change case");
  return evaluate_change_case (t[0], evaluate (t[1]), false, true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch() / 2.54)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 297 of file evaluate_macro.cpp.

                           {
  int d; tree f;
  if (L(t) == COMPOUND) {
    d= 1;
    f= t[0];
    if (is_compound (f)) f= evaluate (f);
    if (is_atomic (f)) {
      string var= f->label;
      if (!std_env->contains (var)) return evaluate_error ("undefined", var);
      f= std_env [var];
    }
  }
  else {
    string var= as_string (L(t));
    if (!std_env->contains (var)) return evaluate_error ("undefined", var);
    d= 0;
    f= std_env [var];
  }

  if (is_applicable (f)) {
    int i, n=N(f)-1, m=N(t)-d;
    assoc_environment local (L(f)==XMACRO? 1: n);
    if (L(f) == XMACRO)
      local->raw_write (0, as_string (f[0]), t);
    else {
      static tree uninit (UNINIT);
      for (i=0; i<n; i++)
       local->raw_write (i, as_string (f[i]), i<m? t[i+d]: uninit);
      //local->print ("");
    }
    tree e= expand (f[n], local);
    decorate_ip (t, e);
    return evaluate (e);
    // FIXME: should we remember partial expansions?
  }
  else return evaluate (f);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 175 of file evaluate_numeric.cpp.

                      {
  if (N(t)!=1) return evaluate_error ("bad cos");
  tree t1= evaluate (t[0]);
  if (is_double (t1))
    return as_tree (cos (as_double (t1)));
  return evaluate_error ("bad cos");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 113 of file evaluate_textual.cpp.

                       {
  if (N(t)>2) return evaluate_error ("bad date");
  string lan= as_string (std_env [LANGUAGE]);
  if (N(t) == 2) {
    tree u= evaluate (t[1]);
    if (is_compound (u)) return evaluate_error ("bad date");
    lan= u->label;
  }
  string fm= "";
  if (N(t) != 0) {
    tree u= evaluate (t[0]);
    if (is_compound (u)) return evaluate_error ("bad date");
    fm= u->label;
  }
  return get_date (lan, fm);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 188 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (0.376 * std_inch() / 25.4)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 104 of file evaluate_numeric.cpp.

                         {
  if (N(t) != 2) return evaluate_error ("bad divide");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad divide");
  if (is_int (t1->label) && (is_int (t2->label))) {
    int den= as_int (t2->label);
    if (den == 0) return evaluate_error ("division by zero");
    return as_string (as_int (t1->label) / den);
  }
  return evaluate_error ("bad divide");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 82 of file evaluate_macro.cpp.

                            {
  (void) t; return "";
  // FIXME: not yet implemented
}

Here is the caller graph for this function:

Definition at line 213 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_fn()->wquad)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 63 of file evaluate_boolean.cpp.

                        {
  if (N(t)!=2) return evaluate_error ("bad equal");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_atomic (t1) && is_atomic (t2) &&
      is_length (t1->label) && is_length (t2->label))
    return as_string_bool (as_length (t1) == as_length (t2));
  return as_string_bool (t1 == t2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree evaluate_error ( string  message)

Definition at line 375 of file evaluate_main.cpp.

                              {
  return tree (ERROR, error);
}
tree evaluate_error ( string  message,
tree  a1 
)

Definition at line 380 of file evaluate_main.cpp.

                                        {
  return tree (ERROR, error, arg);
}
tree evaluate_error ( string  message,
array< tree args 
)

Definition at line 385 of file evaluate_main.cpp.

                                                {
  tree r= tree (ERROR, error);
  r << args;
  return r;
}

Definition at line 20 of file evaluate_quote.cpp.

                            {
#ifdef CLASSICAL_MACRO_EXPANSION
  if (macro_top_level (std_env) || !is_atomic (t[0]))
    return evaluate_error ("undefined", t[0]);
  basic_environment local= macro_arguments (std_env);
  int key= make_tree_label (t[0]->label);
  if (!local->contains (key))
    return evaluate_error ("undefined", t[0]);
  tree u= local [key];
#else
  tree u= t[0];
#endif
  if (is_atomic (u)) return evaluate_error ("bad eval-args");

#ifdef CLASSICAL_MACRO_EXPANSION
  macro_up (std_env);
#endif

  int i, n= N(u);
  tree r (u, n);
  for (i=0; i<n; i++)
    r[i]= evaluate (u[i]);

#ifdef CLASSICAL_MACRO_EXPANSION
  macro_redown (std_env, local);
#endif

  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 221 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_fn()->yx)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 147 of file evaluate_numeric.cpp.

                      {
  if (N(t)!=1) return evaluate_error ("bad exp");
  tree t1= evaluate (t[0]);
  if (is_double (t1))
    return as_tree (exp (as_double (t1)));
  return evaluate_error ("bad exp");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 207 of file evaluate_length.cpp.

                       {
  double fbs= (std_font_base_size () * std_magnification () *
              std_inch ()) / 72.0;
  return tree (TMLEN, as_string (fbs));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 184 of file evaluate_textual.cpp.

                            {
  int i, n=N(t);
  array<tree> r (n);
  for (i=0; i<n; i++) {
    r[i]= evaluate (t[i]);
    if (is_compound (r[i]))
      return evaluate_error ("bad find file");
  }
  for (i=0; i<(n-1); i++) {
    url u= resolve (url (r[i]->label, r[n-1]->label));
    if (!is_none (u)) {
      if (is_rooted (u, "default")) u= reroot (u, "file");
      return as_string (u);
    }
  }
  url base_file_name (as_string (std_env["base-file-name"]));
  url u= resolve (base_file_name * url_parent () * r[n-1]->label);
  if (!is_none (u)) {
    if (is_rooted (u, "default")) u= reroot (u, "file");
    return as_string (u);
  }
  return "false";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 225 of file evaluate_length.cpp.

                      {
  double fs= (std_font_base_size () * std_magnification () *
             std_inch () * std_font_size ()) / 72.0;
  return tree (TMLEN, as_string (0.5*fs), as_string (fs), as_string (1.5*fs));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 263 of file evaluate_length.cpp.

                         {
  return tree (TMLEN, as_string (std_fn()->y1));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 232 of file evaluate_length.cpp.

                       {
  double fs= (std_font_base_size () * std_magnification () *
             std_inch () * std_font_size ()) / 72.0;
  return tree (TMLEN, "0", "0", as_string (fs));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 268 of file evaluate_length.cpp.

                         {
  return tree (TMLEN, as_string (std_fn()->y2));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 64 of file evaluate_control.cpp.

                           {
  if (N(t) != 2) return evaluate_error ("bad for-each");
  tree fun = evaluate (t[0]);
  tree args= evaluate (t[1]);
  if (!is_tuple (args)) return evaluate_error ("bad for-each");
  int i, n= N(args);
  for (i=0; i<n; i++)
    evaluate (tree (COMPOUND, fun, args[i]));
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 25 of file evaluate_misc.cpp.

                                       {
  int i, n= N(t);
  tree r (t, n-1);
  for (i=0; i<n-1; i++) r[i]= evaluate (t[i]);
  tree oldv= std_env [v];
  tree newv= oldv * r;
  assoc_environment local (1);
  local->raw_write (0, v, newv);
  begin_with (std_env, local);
  tree b= evaluate (t[n-1]);
  end_with (std_env);
  return r * tree (TFORMAT, b);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 200 of file evaluate_length.cpp.

                      {
  double fs= (std_font_base_size () * std_magnification () *
             std_inch () * std_font_size ()) / 72.0;
  return tree (TMLEN, as_string (fs));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 98 of file evaluate_macro.cpp.

                            {
  tree r= evaluate (t[0]);
  return as_string (arity (r));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 131 of file evaluate_misc.cpp.

                              {
  if (N(t) != 1 && N(t) != 2) return tree (ERROR, "bad get binding");
  string key= evaluate_string (t[0]);
  tree value= local_ref->contains (key)? local_ref [key]: global_ref [key];
  int type= (N(t) == 1? 0: as_int (evaluate_string (t[1])));
  if (type != 0 && type != 1) type= 0;
  if (is_func (value, TUPLE) && (N(value) >= 2)) value= value[type];
  else if (type == 1) value= tree (UNINIT);
  /* FIXME:
  if (complete && value == tree (UNINIT))
    system_warning ("Undefined reference", key);
  */
  return value;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 92 of file evaluate_macro.cpp.

                            {
  tree r= evaluate (t[0]);
  return copy (as_string (L(r)));  
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 323 of file evaluate_length.cpp.

                      {
  //return tree (TMLEN, as_string (gh));
  return tree (TMLEN, as_string (6 * std_inch() / 2.54)); // 6cm
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 117 of file evaluate_boolean.cpp.

                          {
  if (N(t)!=2) return evaluate_error ("bad greater");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad greater");
  string s1= t1->label;
  string s2= t2->label;
  if (is_double (s1) && (is_double (s2)))
    return as_string_bool (as_double (s1) > as_double (s2));
  if (is_length (s1) && is_length (s2))
    return as_string_bool (as_length (s1) > as_length (s2));
  return evaluate_error ("bad greater");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 133 of file evaluate_boolean.cpp.

                            {
  if (N(t)!=2) return evaluate_error ("bad greater or equal");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad greater or equal");
  string s1= t1->label;
  string s2= t2->label;
  if (is_double (s1) && (is_double (s2)))
    return as_string_bool (as_double (s1) >= as_double (s2));
  if (is_length (s1) && is_length (s2))
    return as_string_bool (as_length (s1) >= as_length (s2));
  return evaluate_error ("bad greater or equal");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 317 of file evaluate_length.cpp.

                      {
  //return tree (TMLEN, as_string (gw));
  return tree (TMLEN, as_string (10 * std_inch() / 2.54)); // 10cm
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 53 of file evaluate_misc.cpp.

                          {
  if (N(t) == 0) {
    pointer ptr= (pointer) std_env.operator -> ();
    return "%" * as_hexadecimal (ptr);
  }
  else {
    t= expand (t[0], true);
    pointer ptr1= (pointer) std_env.operator -> ();
    pointer ptr2= (pointer) t.operator -> ();
    return "%" * as_hexadecimal (ptr1) * "-" * as_hexadecimal (ptr2);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 331 of file evaluate_length.cpp.

{ return tree (TMLEN, "3600000"); }

Here is the caller graph for this function:

Definition at line 26 of file evaluate_control.cpp.

                     {
  if (N(t) != 2 && N(t) != 3) return evaluate_error ("bad if");
  tree u= evaluate (t[0]);
  if (!is_bool (u)) return evaluate_error ("bad if");
  if (as_bool (u)) return evaluate (t[1]);
  if (N(t)==3) return evaluate (t[2]);
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 182 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch())); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 80 of file evaluate_control.cpp.

                          {
  url base_file_name (as_string (std_env["base-file-name"]));
  url incl_file_name= url_system (as_string (evaluate (t[0])));
  tree incl= load_inclusion (incl_file_name);

  assoc_environment local (2);
  local->raw_write (0, string ("cur-file-name"),
                  as_string (incl_file_name));
  local->raw_write (1, string ("secure"),
                  bool_as_tree (is_secure (incl_file_name)));

  begin_with (std_env, local);
  tree r= evaluate (incl);
  end_with (std_env);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 213 of file evaluate_textual.cpp.

                           {
  if (N(t)!=1) return evaluate_error ("bad tuple query");
  return as_string_bool(is_tuple (evaluate (t[0])));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 57 of file evaluate_textual.cpp.

                         {
  if (N(t)!=1) return evaluate_error ("bad length");
  tree t1= evaluate (t[0]);
  if (is_compound (t1)) {
    if (is_tuple (t1)) return as_string (N (t1));
    return evaluate_error ("bad length");
  }
  return as_string (N (t1->label));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 85 of file evaluate_boolean.cpp.

                       {
  if (N(t)!=2) return evaluate_error ("bad less");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad less");
  string s1= t1->label;
  string s2= t2->label;
  if (is_double (s1) && is_double (s2))
    return as_string_bool (as_double (s1) < as_double (s2));
  if (is_length (s1) && is_length (s2))
    return as_string_bool (as_length (s1) < as_length (s2));
  return evaluate_error ("bad less");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 101 of file evaluate_boolean.cpp.

                         {
  if (N(t)!=2) return evaluate_error ("bad less or equal");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad less or equal");
  string s1= t1->label;
  string s2= t2->label;
  if (is_double (s1) && (is_double (s2)))
    return as_string_bool (as_double (s1) <= as_double (s2));
  if (is_length (s1) && is_length (s2))
    return as_string_bool (as_length (s1) <= as_length (s2));
  return evaluate_error ("bad less or equal");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 215 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_fn()->wline)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 156 of file evaluate_numeric.cpp.

                      {
  if (N(t)!=1) return evaluate_error ("bad log");
  tree t1= evaluate (t[0]);
  if (is_double (t1))
    return as_tree (log (as_double (t1)));
  return evaluate_error ("bad log");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 219 of file evaluate_textual.cpp.

                         {
  if (N(t)!=2) return evaluate_error ("bad look up");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (!(is_compound (t1) && is_int (t2)))
    return evaluate_error ("bad look up");
  int i= as_int (t2);
  if (i < 0 || i >= N(t1))
    return evaluate_error ("index out of range in look up");
  return t1[i];
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 138 of file evaluate_numeric.cpp.

                            {
  if (N(t)!=1) return evaluate_error ("bad sqrt");
  tree t1= evaluate (t[0]);
  if (is_double (t1))
    return as_tree (sqrt (as_double (t1)));
  return evaluate_error ("bad sqrt");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 25 of file evaluate_textual.cpp.

                        {
  int i, n= N(t);
  if (n == 0) return "";
  tree acc= evaluate (t[0]);
  if (is_concat (acc)) acc= tree_as_string (acc);
  for (i=1; i<n; i++) {
    tree add= evaluate (t[i]);
    if (is_atomic (acc) && (is_atomic (add) || is_concat (add)))
      acc= acc->label * tree_as_string (add);
    else if (is_tuple (acc) && is_tuple (add))
      acc= acc * add;
    else if (is_func (acc, MACRO) && is_func (add, MACRO) &&
            (N(acc) == N(add)) &&
            (acc (0, N(acc)-1) == add (0, N(add)-1)))
      {
       tree r = copy (acc);
       tree u1= copy (acc[N(acc)-1]);
       tree u2= copy (add[N(add)-1]);
       tree u (CONCAT, u1, u2);
       if (u1 == "") u= u2;
       else if (u2 == "") u= u1;
       else if (is_atomic (u1) && is_atomic (u2))
         u= u1->label * u2->label;
       r[N(r)-1]= u;
       acc= r;
      }
    else return evaluate_error ("bad merge");
  }
  return acc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 330 of file evaluate_length.cpp.

{ return tree (TMLEN, "60000"); }

Here is the caller graph for this function:

Definition at line 180 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch() / 25.4)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 119 of file evaluate_numeric.cpp.

                         {
  if (N(t)!=2) return evaluate_error ("bad modulo");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad modulo");
  if (is_int (t1->label) && (is_int (t2->label))) {
    int den= as_int (t2->label);
    if (den == 0) return evaluate_error ("modulo zero");
    return as_string (as_int (t1->label) % den);
  }
  return evaluate_error ("bad modulo");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 328 of file evaluate_length.cpp.

{ return tree (TMLEN, "1"); }

Here is the caller graph for this function:

Definition at line 51 of file evaluate_boolean.cpp.

                      {
  if (N(t)!=1) return evaluate_error ("bad not");
  tree u= evaluate(t[0]);
  if (!is_bool (u)) return evaluate_error ("bad not");
  return as_string_bool (!as_bool (u));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 94 of file evaluate_textual.cpp.

                         {
  if (N(t)!=2) return evaluate_error ("bad number");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad number");
  string s1= t1->label;
  string s2= t2->label;
  int nr= as_int (s1);
  if (s2 == "roman") return roman_nr (nr);
  if (s2 == "Roman") return Roman_nr (nr);
  if (s2 == "alpha") return alpha_nr (nr);
  if (s2 == "Alpha") return Alpha_nr (nr);
  if (s2 == "fnsymbol")
    return tree (WITH, MODE, "math", tree (RIGID, fnsymbol_nr (nr)));
  return evaluate_error ("bad number");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 19 of file evaluate_boolean.cpp.

                     {
  if (N(t)<2) return evaluate_error ("bad or");
  for (int i=0; i<N(t); i++) {
    tree u= evaluate (t[i]);
    if (!is_bool (u)) return evaluate_error ("bad or");
    if (as_bool (u)) return as_string_bool (true);
  }
  return as_string_bool (false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 302 of file evaluate_length.cpp.

                       {
  /*
  SI d1, height, d2, d3, d4, d5, d6, d7;
  get_page_pars (d1, height, d2, d3, d4, d5, d6, d7);
  return tree (TMLEN, as_string (height));
  */
  return tree (TMLEN, as_string (23 * std_inch() / 2.54)); // 23cm
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 291 of file evaluate_length.cpp.

                       {
  /*
  SI width, d1, d2, d3, d4, d5, d6, d7;
  get_page_pars (width, d1, d2, d3, d4, d5, d6, d7);
  width -= (get_length (PAR_LEFT) + get_length (PAR_RIGHT));
  return tree (TMLEN, as_string (width));
  */
  return tree (TMLEN, as_string (15 * std_inch() / 2.54)); // 15cm
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 147 of file evaluate_misc.cpp.

                          {
  url base_file_name (as_string (std_env ["base-file-name"]));
  url im= evaluate_string (t[0]);
  url image= resolve (relative (base_file_name, im));
  if (is_none (image))
    image= resolve (url ("$TEXMACS_PATTERN_PATH") * im);
  if (is_none (image)) return "white";
  int imw_pt, imh_pt;
  int dpi= as_int (as_string (std_env ["dpi"]));
  image_size (image, imw_pt, imh_pt);
  double pt= ((double) dpi*PIXEL) / 72.0;
  SI imw= (SI) (((double) imw_pt) * pt);
  SI imh= (SI) (((double) imh_pt) * pt);
  if (imw <= 0 || imh <= 0) return "white";
  string w= evaluate_string (t[1]);
  string h= evaluate_string (t[2]);
  if (is_length (w))
    w= as_string (as_length (w));
  else if (is_magnification (w))
    w= as_string ((SI) (get_magnification (w) * ((double) imw)));
  if (is_length (h))
    h= as_string (as_length (h));
  else if (is_magnification (h))
    h= as_string ((SI) (get_magnification (h) * ((double) imh)));
  if (w == "" && h != "") {
    if (is_int (h)) w= as_string ((SI) ((as_double (h) * imw) / imh));
    else if (is_percentage (h))
      w= as_string (100.0 * (as_percentage (h) * imw) / imh) * "@";
    else return "white";
  }
  else if (h == "" && w != "") {
    if (is_int (w)) h= as_string ((SI) ((as_double (w) * imh) / imw));
    else if (is_percentage (w))
      h= as_string (100.0 * (as_percentage (w) * imh) / imw) * "@";
    else return "white";
  }
  else if (w == "" && h == "") {
    w= as_string (imw);
    h= as_string (imh);
  }
  else if ((!is_int (w) && !is_percentage (w)) ||
          (!is_int (h) && !is_percentage (h)))
    return "white";
  tree r (PATTERN, as_string (image), w, h);
  if (N(t) == 4) r << evaluate (t[3]);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 190 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (12.0 * std_inch() / 72.27)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 19 of file evaluate_numeric.cpp.

                             {
  int i, n= N(t);
  if (n==0) return evaluate_error ("bad plus/minus");
  tree inc= evaluate (t[0]);
  if (is_double (inc)) {
    double acc= as_double (inc);
    if ((n==1) && is_func (t, MINUS))
      acc= -acc;
    for (i=1; i<n; i++) {
      tree inc= evaluate (t[i]);
      if (!is_double (inc))
       return evaluate_error ("bad plus/minus");
      if ((i == n-1) && is_func (t, MINUS))
       acc -= as_double (inc);
      else acc += as_double (inc);
    }
    return as_string (acc);
  }
  else if (is_anylen (inc)) {
    tree acc= as_tmlen (inc);
    if ((n==1) && is_func (t, MINUS))
      acc= tmlen_times (-1, acc);
    for (i=1; i<n; i++) {
      tree inc= evaluate (t[i]);
      if (!is_anylen (inc))
       return evaluate_error ("bad plus/minus");
      inc= as_tmlen (inc);
      if ((i == n-1) && is_func (t, MINUS))
       inc= tmlen_times (-1, inc);
      acc= tmlen_plus (acc, inc);
    }
    return acc;
  }
  else return evaluate_error ("bad plus/minus");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 196 of file evaluate_misc.cpp.

                        {
  int i, n= N(t);
  tree u (_POINT, n);
  for (i=0; i<n; i++)
    u[i]= evaluate (t[i]);
  if (n==0 || is_double (u[0])) return u;
  return as_tree (as_point (u));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 165 of file evaluate_numeric.cpp.

                      {
  if (N(t)!=2) return evaluate_error ("bad pow");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_double (t1) && is_double (t2))
    return as_tree (pow (as_double (t1), as_double (t2)));
  return evaluate_error ("bad pow");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 53 of file evaluate_macro.cpp.

                           {
  tree r= evaluate (t[0]);
  if (is_compound (r)) return evaluate_error ("bad provides");
  if (std_env->contains (r->label)) return "true"; else return "false";  
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 184 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch() / 72.27)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 313 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_sfactor () * PIXEL)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 55 of file evaluate_quote.cpp.

                             {
  if (is_atomic (t)) return t;
  else if (is_func (t, UNQUOTE, 1)) return evaluate (t[0]);
  else {
    int i, n= N(t);
    tree r (L(t));
    for (i=0; i<n; i++) {
      if (is_func (t[i], VAR_UNQUOTE, 1)) {
       tree ins= evaluate (t[i]);
       if (is_compound (ins)) r << A(ins);
       else r << evaluate_error ("bad unquote*");
      }
      else r << evaluate_quasiquote (t[i]);
    }
    return r;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 69 of file evaluate_macro.cpp.

                              {
  tree r= evaluate (t[0]);
  if (is_compound (r)) return evaluate_error ("bad quoted value");
  int key= make_tree_label (r->label);
  if (!std_env->contains (key)) return evaluate_error ("undefined", r);
  return std_env[key];
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 68 of file evaluate_textual.cpp.

                        {
  if (N(t)!=3) return evaluate_error ("bad range");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  tree t3= evaluate (t[2]);
  if (!(is_int (t2) && is_int (t3))) return evaluate_error ("bad range");
  if (is_compound (t1)) {
    if (is_tuple (t1)) {
      int i1= max (0, as_int (t2));
      int i2= min (N (t1), as_int (t3));
      i2 = max (i1, i2);
      return t1 (i1, i2);
    }
    return evaluate_error ("bad range");
  }
  int i1= max (0, as_int (t2));
  int i2= min (N(t1->label), as_int (t3));
  i2 = max (i1, i2);
  return t1->label (i1, i2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 202 of file evaluate_rewrite.cpp.

                          {
  return evaluate (rewrite (t));
}

Here is the call graph for this function: