Back to index

texmacs  1.0.7.15
Classes | Functions
std_environment.cpp File Reference
#include "list_environment.hpp"
#include "memorizer.hpp"
#include "iterator.hpp"

Go to the source code of this file.

Classes

class  std_environment
class  std_environment_rep
class  assign_memorizer_rep
class  begin_with_memorizer_rep
class  end_with_memorizer_rep

Functions

 ABSTRACT_NULL_CODE (std_environment)
std_environment as_std_environment (const environment &env)
std_environment primitive_environment (basic_environment global)
std_environment primitive_environment (hashmap< string, tree > h)
void primitive (environment &env, hashmap< string, tree > h)
std_environment assign_environment (std_environment env, basic_environment local)
void assign (environment &env, assoc_environment local)
std_environment begin_with_environment (std_environment env, basic_environment local)
void begin_with (environment &env, assoc_environment local)
std_environment end_with_environment (std_environment env)
void end_with (environment &env)
assoc_environment assoc (int key1, const tree &val1)
assoc_environment assoc (int key1, const tree &val1, int key2, const tree &val2)
basic_environment test_environment (int n, int code)
void test_environments ()

Function Documentation

std_environment as_std_environment ( const environment env) [inline]

Definition at line 85 of file std_environment.cpp.

                                                                   {
    return std_environment ((std_environment_rep*) as_pointer (env)); }

Here is the caller graph for this function:

void assign ( environment env,
assoc_environment  local 
)

Definition at line 155 of file std_environment.cpp.

                                                   {
  memorizer mem= tm_new<assign_memorizer_rep> (env, local);
  if (!is_memorized (mem)) mem->compute ();
  env= mem->get_environment ();
}

Here is the call graph for this function:

Definition at line 122 of file std_environment.cpp.

                                                                  {
  list_environment accel (local, env->accel);
  if (env->pure) return std_environment (false, local, env, accel, env->args);
  list_environment merged (local, env->env);
  return std_environment (false, merged, env->next, accel, env->args);
}

Here is the caller graph for this function:

assoc_environment assoc ( int  key1,
const tree val1 
)

Definition at line 390 of file std_environment.cpp.

                                   {
  assoc_environment env (1);
  env->raw_write (0, key1, val1);
  return env;
}

Here is the caller graph for this function:

assoc_environment assoc ( int  key1,
const tree val1,
int  key2,
const tree val2 
)

Definition at line 397 of file std_environment.cpp.

                                                               {
  assoc_environment env (2);
  env->raw_write (0, key1, val1);
  env->raw_write (1, key2, val2);
  return env;
}
void begin_with ( environment env,
assoc_environment  local 
)

Definition at line 197 of file std_environment.cpp.

                                                       {
  memorizer mem= tm_new<begin_with_memorizer_rep> (env, local);
  if (!is_memorized (mem)) mem->compute ();
  env= mem->get_environment ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 166 of file std_environment.cpp.

                                                                      {
  list_environment accel (local, env->accel);
  return std_environment (true, local, env, accel, env->args);
}

Here is the caller graph for this function:

void end_with ( environment env)

Definition at line 245 of file std_environment.cpp.

                            {
  memorizer mem= tm_new<end_with_memorizer_rep> (env);
  if (!is_memorized (mem)) mem->compute ();
  env= mem->get_environment ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 208 of file std_environment.cpp.

                                           {
  if (env->pure) return env->next;
  ASSERT (env->next->pure, "pure environment expected");
  basic_environment patch= flatten (env->env);
  basic_environment with_env= flatten (env->next->env);
  patch->multiple_remove (with_env->a, with_env->n);
  if (patch->size == 0) return env->next->next;
  while (patch->size < (patch->n>>1))
    patch->resize (patch->n >> 1);
  std_environment up= env->next->next;
  std_environment aux (up->pure, up->env, up->next, up->accel, env->args);
  return assign_environment (aux, patch);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void primitive ( environment env,
hashmap< string, tree h 
)

Definition at line 111 of file std_environment.cpp.

                                                     {
  env= as_environment (primitive_environment (h));
  //cout << HRULE;
  //env->print ("");
}

Here is the call graph for this function:

Definition at line 93 of file std_environment.cpp.

                                                 {
  list_environment env (global);
  return std_environment (false, env, std_environment (),
                       env, list_environment ());
}

Here is the caller graph for this function:

Definition at line 100 of file std_environment.cpp.

                                               {
  basic_environment global (1);
  iterator<string> it= iterate (h);
  while (it->busy ()) {
    string key= it->next();
    global->write ((int) make_tree_label (key), copy (h[key]));
  }
  return primitive_environment (global);
}

Here is the call graph for this function:

basic_environment test_environment ( int  n,
int  code 
)

Definition at line 405 of file std_environment.cpp.

                                   {
  array<string> s (8);
  s[0]= "Hallo"; s[1]= "Hop"; s[2]= "Blah"; s[3]= "Holala";
  s[4]= "Ploef"; s[5]= "Blurk"; s[6]= "Blauwbilgorgel"; s[7]= "Vrolijk";
  int modulo= 32;
  while (modulo<n) modulo <<= 1;
  basic_environment env (1);
  for (int i=0; i<n; i++) {
    int i1= code%8, i2= (3*code)%8;
    if (i1 == i2) i2= (i2+1)%8;
    string s1= copy (s[i1]), s2= copy (s[i2]);
    env->write (code % modulo, s1);
    int j1= code % N(s1), j2= code % N(s2);
    s[i1]= s2 (0, j2) * s1 (j1, N(s1));
    s[i2]= s1 (0, j1) * s2 (j2, N(s2));
    code= code*code % 176246173;
    if (code < 0) code= -code;
    while (env->contains (code % modulo)) code= (code+1) % 176246173;
  }
  return env;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 428 of file std_environment.cpp.

                     {
  assoc_environment a1= assoc (6, "Sylvie", 9, "Nicole");
  assoc_environment a2= assoc (9, "Joris");
  assoc_environment a3= assoc (21, "Judith");
  assoc_environment a4= assoc (9, "Judith", 6, "Tessa");
  assoc_environment a5= assoc (9, "Piet", 21, "Joris");

  basic_environment b1= test_environment (23, 1234567);
  std_environment std1= primitive_environment (b1);
  std1->print (""); cout << HRULE;
  std1->accel->print (""); cout << HRULE;
  std_environment std2= begin_with_environment (std1, a1);
  std2->print (""); cout << HRULE;
  std2->accel->print (""); cout << HRULE;
  std_environment std3= assign_environment (std2, a5);
  std3->print (""); cout << HRULE;
  std3->accel->print (""); cout << HRULE;
  std_environment std4= assign_environment (std3, a3);
  std4->print (""); cout << HRULE;
  std4->accel->print (""); cout << HRULE;
  std_environment std5= begin_with_environment (std4, a4);
  std5->print (""); cout << HRULE;
  std5->accel->print (""); cout << HRULE;
  std_environment std6= assign_environment (std5, a2);
  std6->print (""); cout << HRULE;
  std6->accel->print (""); cout << HRULE;
  for (int i=0; i<10; i++)
    cout << i << "\t" << std6->read (i) << "\n";
  cout << HRULE;
  std6->accel->print (""); cout << HRULE;
  for (int i=0; i<10; i++)
    cout << i << "\t" << std6->read (i) << "\n";
  cout << HRULE;
  std6->accel->print (""); cout << HRULE;
  for (int i=0; i<40; i++)
    cout << i << "\t" << std6->read (i) << "\n";
  cout << HRULE;
  std6->accel->print (""); cout << HRULE;
  std_environment std7= end_with_environment (std6);
  std7->print (""); cout << HRULE;
  std7->accel->print (""); cout << HRULE;
  std_environment std8= end_with_environment (std7);
  std8->print (""); cout << HRULE;
  std8->accel->print (""); cout << HRULE;
}

Here is the call graph for this function: