"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Data/Drd/drd_info.cpp" between
TeXmacs-1.99.4-src.tar.gz and TeXmacs-1.99.5-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

drd_info.cpp  (TeXmacs-1.99.4-src):drd_info.cpp  (TeXmacs-1.99.5-src)
skipping to change at line 776 skipping to change at line 776
/****************************************************************************** /******************************************************************************
* Heuristic initialization of DRD * Heuristic initialization of DRD
******************************************************************************/ ******************************************************************************/
void void
drd_info_rep::set_environment (hashmap<string,tree> env2) { drd_info_rep::set_environment (hashmap<string,tree> env2) {
env= env2; env= env2;
} }
tree tree
drd_info_rep::arg_access (tree t, tree arg, tree env, int& type) { drd_info_rep::arg_access (tree t, tree arg, tree env, int& type, bool& found) {
// returns "" if unaccessible and the env if accessible // returns "" if unaccessible and the env if accessible
//cout << " arg_access " << t << ", " << arg << ", " << env << "\n"; // cout << " arg_access " << t << ", " << arg << ", " << env << "\n";
if (is_atomic (t)) return ""; if (is_atomic (t)) return "";
else if (t == arg) return env; else if (t == arg) { found= true; return env; }
else if (is_func (t, QUOTE_ARG, 1) && N(arg) == 1 && t[0] == arg[0]) else if (is_func (t, QUOTE_ARG, 1) && N(arg) == 1 && t[0] == arg[0])
return env; return env;
else if (is_func (t, MAP_ARGS) && (t[2] == arg[0])) { else if (is_func (t, MAP_ARGS) && (t[2] == arg[0])) {
if ((N(t) >= 4) && (N(arg) >= 2) && (as_int (t[3]) > as_int (arg[1]))) if ((N(t) >= 4) && (N(arg) >= 2) && (as_int (t[3]) > as_int (arg[1])))
return ""; return "";
if ((N(t) == 5) && (N(arg) >= 2) && (as_int (t[3]) <= as_int (arg[1]))) if ((N(t) == 5) && (N(arg) >= 2) && (as_int (t[3]) <= as_int (arg[1])))
return ""; return "";
tree_label inner= make_tree_label (as_string (t[0])); tree_label inner= make_tree_label (as_string (t[0]));
tree_label outer= make_tree_label (as_string (t[1])); tree_label outer= make_tree_label (as_string (t[1]));
if (get_nr_indices (inner) > 0) if (get_nr_indices (inner) > 0)
skipping to change at line 802 skipping to change at line 802
if ((get_nr_indices (inner) > 0) && if ((get_nr_indices (inner) > 0) &&
(get_accessible (inner, 0) == ACCESSIBLE_ALWAYS) && (get_accessible (inner, 0) == ACCESSIBLE_ALWAYS) &&
all_accessible (outer)) all_accessible (outer))
return env; return env;
return ""; return "";
} }
else if (is_func (t, MACRO)) return ""; else if (is_func (t, MACRO)) return "";
else if (is_func (t, WITH)) { else if (is_func (t, WITH)) {
int n= N(t)-1; int n= N(t)-1;
//cout << "env= " << drd_env_merge (env, t (0, n)) << "\n"; //cout << "env= " << drd_env_merge (env, t (0, n)) << "\n";
return arg_access (t[n], arg, drd_env_merge (env, t (0, n)), type); return arg_access (t[n], arg, drd_env_merge (env, t (0, n)), type, found);
} }
else if (is_func (t, TFORMAT)) { else if (is_func (t, TFORMAT)) {
int n= N(t)-1; int n= N(t)-1;
tree oldf= drd_env_read (env, CELL_FORMAT, tree (TFORMAT)); tree oldf= drd_env_read (env, CELL_FORMAT, tree (TFORMAT));
tree newf= oldf * tree (TFORMAT, A (t (0, n))); tree newf= oldf * tree (TFORMAT, A (t (0, n)));
tree w = tree (ATTR, CELL_FORMAT, newf); tree w = tree (ATTR, CELL_FORMAT, newf);
tree cenv= get_env_child (t, n, drd_env_merge (env, w)); tree cenv= get_env_child (t, n, drd_env_merge (env, w));
return arg_access (t[n], arg, cenv, type); return arg_access (t[n], arg, cenv, type, found);
} }
else if (is_func (t, COMPOUND) && N(t) >= 1 && is_atomic (t[0])) else if (is_func (t, COMPOUND) && N(t) >= 1 && is_atomic (t[0]))
return arg_access (compound (t[0]->label, A (t (1, N(t)))), return arg_access (compound (t[0]->label, A (t (1, N(t)))),
arg, env, type); arg, env, type, found);
else if ((is_func (t, IF) || is_func (t, VAR_IF)) && N(t) >= 2) else if ((is_func (t, IF) || is_func (t, VAR_IF)) && N(t) >= 2)
return arg_access (t[1], arg, env, type); return arg_access (t[1], arg, env, type, found);
else { else {
int i, n= N(t); int i, n= N(t);
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
int ctype= get_type_child (t, i); int ctype = get_type_child (t, i);
tree cenv = get_env_child (t, i, env); bool cfound= false;
tree aenv = arg_access (t[i], arg, cenv, ctype); tree cenv = get_env_child (t, i, env);
tree aenv = arg_access (t[i], arg, cenv, ctype, cfound);
if (aenv != "") { if (aenv != "") {
if (ctype != TYPE_INVALID) type= ctype; if (ctype != TYPE_INVALID) { type= ctype; found= cfound; }
if (is_accessible_child (t, i)) return aenv; if (is_accessible_child (t, i)) return aenv;
} }
else if (type == TYPE_UNKNOWN && else if (cfound /*type == TYPE_UNKNOWN*/ &&
ctype != TYPE_INVALID && ctype != TYPE_INVALID &&
ctype != TYPE_UNKNOWN) { ctype != TYPE_UNKNOWN) {
type= ctype; type = ctype;
found= cfound;
//cout << " found type " << t << ", " << arg << ", " << type << "\n"; //cout << " found type " << t << ", " << arg << ", " << type << "\n";
} }
} }
return ""; return "";
} }
} }
static void static void
rewrite_symbolic_arguments (tree macro, tree& env) { rewrite_symbolic_arguments (tree macro, tree& env) {
if (!is_func (env, ATTR)) return; if (!is_func (env, ATTR)) return;
skipping to change at line 894 skipping to change at line 896
set_var_type (l, VAR_MACRO_PARAMETER); set_var_type (l, VAR_MACRO_PARAMETER);
} }
else set_type (l, get_type (macro[n])); else set_type (l, get_type (macro[n]));
set_with_like (l, heuristic_with_like (macro, "")); set_with_like (l, heuristic_with_like (macro, ""));
//if (heuristic_with_like (macro, "")) //if (heuristic_with_like (macro, ""))
//cout << "With-like: " << var << LF; //cout << "With-like: " << var << LF;
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
if (is_atomic (macro[i])) if (is_atomic (macro[i]))
if (l >= START_EXTENSIONS || get_child_name (l, i) == "") if (l >= START_EXTENSIONS || get_child_name (l, i) == "")
set_child_name (l, i, macro[i]->label); set_child_name (l, i, macro[i]->label);
int type= TYPE_UNKNOWN; int type = TYPE_UNKNOWN;
bool found= false;
tree arg (ARG, macro[i]); tree arg (ARG, macro[i]);
tree env= arg_access (macro[n], arg, tree (ATTR), type); tree env= arg_access (macro[n], arg, tree (ATTR), type, found);
//if (var == "section" || var == "section-title") //if (var == "section" || var == "section-title")
//cout << var << " -> " << env << ", " << macro << "\n"; //cout << var << " -> " << env << ", " << macro << "\n";
//if (var == "math") //if (var == "math")
//cout << var << ", " << i << " -> " << type << ", " << env << ", " << macro << "\n"; //cout << var << ", " << i << " -> " << type << ", " << env << ", " << macro << "\n";
set_type (l, i, type); set_type (l, i, type);
if (env != "") { if (env != "") {
//if (var == "eqnarray*") //if (var == "eqnarray*")
//cout << var << " -> " << env << "\n"; //cout << var << " -> " << env << "\n";
//if (var == "session") //if (var == "session")
//cout << var << " = " << macro << ", " << i << " -> " << env << "\n"; //cout << var << " = " << macro << ", " << i << " -> " << env << "\n";
skipping to change at line 940 skipping to change at line 943
} }
bool bool
drd_info_rep::heuristic_init_xmacro (string var, tree xmacro) { drd_info_rep::heuristic_init_xmacro (string var, tree xmacro) {
tree_label l = make_tree_label (var); tree_label l = make_tree_label (var);
tag_info old_ti= copy (info[l]); tag_info old_ti= copy (info[l]);
int i, m= minimal_arity (xmacro[1], xmacro[0]); int i, m= minimal_arity (xmacro[1], xmacro[0]);
set_arity (l, m, 1, ARITY_REPEAT, CHILD_DETAILED); set_arity (l, m, 1, ARITY_REPEAT, CHILD_DETAILED);
set_type (l, get_type (xmacro[1])); set_type (l, get_type (xmacro[1]));
for (i=0; i<=m; i++) { for (i=0; i<=m; i++) {
int type= TYPE_UNKNOWN; int type = TYPE_UNKNOWN;
bool found= false;
tree arg (ARG, xmacro[0], as_string (i)); tree arg (ARG, xmacro[0], as_string (i));
tree env= arg_access (xmacro[1], arg, tree (ATTR), type); tree env= arg_access (xmacro[1], arg, tree (ATTR), type, found);
//cout << var << ", " << xmacro << ", " << i << " -> " << type << "\n"; //cout << var << ", " << xmacro << ", " << i << " -> " << type << "\n";
set_type (l, i, type); set_type (l, i, type);
if (env != "") { if (env != "") {
set_accessible (l, i, ACCESSIBLE_ALWAYS); set_accessible (l, i, ACCESSIBLE_ALWAYS);
set_env (l, i, env); set_env (l, i, env);
} }
} }
// if (old_ti != info[l]) // if (old_ti != info[l])
// cout << var << ": " << old_ti << " -> " << info[l] << "\n"; // cout << var << ": " << old_ti << " -> " << info[l] << "\n";
return (old_ti != info[l]); return (old_ti != info[l]);
 End of changes. 15 change blocks. 
17 lines changed or deleted 21 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS