Back to index

texmacs  1.0.7.15
Functions | Variables
evaluate_misc.cpp File Reference
#include "evaluate_main.hpp"
#include "std_environment.hpp"
#include "vars.hpp"
#include "analyze.hpp"
#include "url.hpp"
#include "../../Typeset/Graphics/frame.hpp"
#include "image_files.hpp"
#include "renderer.hpp"

Go to the source code of this file.

Functions

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)

Variables

static hashmap< string, treelocal_ref ("?")
static hashmap< string, treeglobal_ref ("?")

Function Documentation

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 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 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 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 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 67 of file evaluate_misc.cpp.

                         {
  if (N(t) != 1 && N(t) != 2) return tree (ERROR, "bad script");
  if (N(t) == 1) return tree (SCRIPT, evaluate (t[0]));
  else return tree (SCRIPT, evaluate (t[0]), expand (t[1], true));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 74 of file evaluate_misc.cpp.

                              {
  tree keys, value;
  if (N(t) == 1) {
    keys= std_env ["the-tags"];
    if (!is_tuple (keys))
      return tree (ERROR, "bad set binding");
    for (int i=0; i<N(keys); i++)
      if (!is_atomic (keys[i]))
       return tree (ERROR, "bad set binding");
    value= evaluate (t[0]);
    assoc_environment local (2);
    local->raw_write (0, string ("the-tags"), tree (TUPLE));
    local->raw_write (1, string ("the-label"), copy (value));
    assign (std_env, local);
  }
  else if (N(t) >= 2) {
    tree key= evaluate (t[0]);
    if (!is_atomic (key)) 
      return tree (ERROR, "bad set binding");
    keys= tuple (key);
    value= evaluate (t[1]);
  }
  else return tree (ERROR, "bad set binding");

  for (int i=0; i<N(keys); i++) {
    string key= keys[i]->label;
    tree old_value= local_ref[key];
    string part= as_string (std_env ["current-part"]);
    url base_file_name (as_string (std_env ["base-file-name"]));
    url cur_file_name (as_string (std_env ["cur-file-name"]));
    if (is_func (old_value, TUPLE) && (N(old_value) >= 2))
      local_ref (key)= tuple (copy (value), old_value[1]);
    else local_ref (key)= tuple (copy (value), "?");
    if (cur_file_name != base_file_name || N(part) != 0) {
      string extra;
      if (cur_file_name != base_file_name)
       extra << as_string (delta (base_file_name, cur_file_name));
      if (N(part) != 0)
       extra << "#" << part (1, N(part));
      local_ref (key) << extra;
    }
    /* FIXME:
    if (complete && is_tuple (old_value) && N(old_value) >= 1) {
      string old_s= tree_as_string (old_value[0]);
      string new_s= tree_as_string (value);
      if (new_s != old_s && !starts (key, "auto-")) {
       if (new_s == "") system_warning ("Redefined", key);
       else system_warning ("Redefined " * key * " as", new_s);
      }
    }
    */
  }

  return ""; // FIXME: do stuff from concater_rep::typeset_set_binding instead
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 40 of file evaluate_misc.cpp.

                        {
  // FIXME: we should execute values in old cell format
  assoc_environment local (1);
  local->raw_write (0, CELL_FORMAT, tree (TFORMAT));
  begin_with (std_env, local);
  int i, n= N(t);
  tree r (t, n);
  for (i=0; i<n; i++) r[i]= evaluate (t[i]);
  end_with (std_env);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

hashmap<string,tree> global_ref("?") [static]
hashmap<string,tree> local_ref("?") [static]