Commit 0e63549d authored by John van Groningen's avatar John van Groningen
Browse files

fix bug in scope numbers

parent 65acc572
......@@ -39,8 +39,8 @@ static void set_root_scope_numbers (NodeP node_p,int local_scope)
int new_local_scope;
ArgP arg_p;
node_p->node_if_scope=local_scope;
node_p->node_if_scope=scope;
new_local_scope=scope+2;
scope+=3;
......@@ -61,33 +61,48 @@ static void set_root_scope_numbers (NodeP node_p,int local_scope)
case SwitchNode:
{
ArgP arg_p;
int old_scope;
old_scope=scope;
for_l (arg_p,node_p->node_arguments,arg_next){
NodeP node;
node=arg_p->arg_node;
if (node->node_kind==CaseNode){
NodeP node_p;
scope=old_scope;
node_p=arg_p->arg_node;
if (node_p->node_kind==CaseNode){
NodeP case_alt_node_p;
case_alt_node_p=node->node_arguments->arg_node;
/* Cedewarrior bug if (case_alt_node_p->node_kind==PushNode){ */
if (node->node_arguments->arg_node->node_kind==PushNode){
case_alt_node_p=node_p->node_arguments->arg_node;
/* Cedewarrior bug if (case_alt_node_p->node_kind==PushNode) */
if (node_p->node_arguments->arg_node->node_kind==PushNode)
set_root_scope_numbers (case_alt_node_p->node_arguments->arg_next->arg_node, local_scope);
}
else
set_root_scope_numbers (node->node_arguments->arg_node, local_scope);
} else if (node->node_kind==DefaultNode){
set_root_scope_numbers (node->node_arguments->arg_node, local_scope);
set_root_scope_numbers (node_p->node_arguments->arg_node, local_scope);
} else if (node_p->node_kind==DefaultNode){
set_root_scope_numbers (node_p->node_arguments->arg_node, local_scope);
} else
ErrorInCompiler ("set_scope_numbers.c", "set_root_scope_numbers", "");
set_node_id_scope_numbers (node_p->node_node_defs,local_scope);
}
}
break;
case GuardNode:
{
int old_scope;
old_scope=scope;
set_root_scope_numbers (node_p->node_arguments->arg_node,local_scope);
scope=old_scope;
set_root_scope_numbers (node_p->node_arguments->arg_next->arg_node,local_scope);
set_node_id_scope_numbers (node_p->node_node_defs,local_scope);
break;
}
}
}
......
......@@ -1530,6 +1530,11 @@ static Bool AdjustState (StateS *old_state_p, StateS newstate)
return False;
}
#if 0
# include "dbprint.h"
extern File rules_file;
#endif
static void DetermineStateOfThenOrElse (Args t_or_e_args, NodeDefs *t_or_e_defs, StateS demstate,int local_scope)
{
Node node;
......@@ -1542,8 +1547,12 @@ static void DetermineStateOfThenOrElse (Args t_or_e_args, NodeDefs *t_or_e_defs,
node_id=node->node_node_id;
if (node_id->nid_ref_count_copy>=0)
--node_id->nid_ref_count_copy__;
} else
} else {
#if 0
FPrintF (rules_file,"DetermineStateOfThenOrElse %d\n",local_scope);
#endif
DetermineStatesOfRootNodeAndDefs (node,t_or_e_defs,demstate, local_scope);
}
AdjustState (&t_or_e_args->arg_state,demstate);
}
......@@ -1554,10 +1563,6 @@ static void DecrementRefCountCopy (NodeId nid)
--nid->nid_ref_count_copy__;
}
#if 0
# include "dbprint.h"
#endif
static Bool AdjustStateOfSharedNode (NodeId nid, StateS demstate, int local_scope)
{
/*
......@@ -1581,9 +1586,9 @@ static Bool AdjustStateOfSharedNode (NodeId nid, StateS demstate, int local_scop
node_id_scope=-node_id_scope;
#if 0
printf ("AdjustStateOfSharedNode ");
DPrintNodeId (nid,StdOut);
printf (" %d %d\n",node_id_scope,local_scope);
FPrintF (rules_file,"AdjustStateOfSharedNode ");
DPrintNodeId (nid,rules_file);
FPrintF (rules_file," %d %d\n",node_id_scope,local_scope);
#endif
if (node_id_scope>=local_scope){
......@@ -1845,9 +1850,9 @@ static Bool NodeInAStrictContext (Node node,StateS demanded_state,int local_scop
node_id_scope=-node_id_scope;
#if 0
printf ("NodeInAStrictContext select_symb ");
DPrintNodeId (node_id,StdOut);
printf (" %d %d\n",node_id_scope,local_scope);
FPrintF (rules_file,"NodeInAStrictContext select_symb %d ",node->node_arity);
DPrintNodeId (node_id,rules_file);
FPrintF (rules_file," %d %d\n",node_id_scope,local_scope);
#endif
if (node_id_scope>=local_scope){
if (IsSimpleState (argnode->node_state)){
......@@ -1873,6 +1878,11 @@ static Bool NodeInAStrictContext (Node node,StateS demanded_state,int local_scop
AdjustState (&argnode->node_state.state_tuple_arguments[node->node_arity-1],demanded_state);
}
}
#if 0
PrintState (argnode->node_state,rules_file);
FPrintF (rules_file,"\n");
#endif
}
}
node->node_state = demanded_state;
......@@ -3594,7 +3604,7 @@ static NodeDefs *CollectSharedNodeIdsInRootNode (Node* node_p,NodeId parent_node
for_l (arg_p,root_node->node_arguments,arg_next){
NodeP node;
node=arg_p->arg_node;
if (node->node_kind==CaseNode){
NodeP case_alt_node_p;
......@@ -3631,6 +3641,7 @@ static NodeDefs *CollectSharedNodeIdsInRootNode (Node* node_p,NodeId parent_node
break;
}
default:
scope=1;
last=CollectSharedNodeIdsInNode (node_p,parent_node_id,last);
break;
......@@ -3644,9 +3655,9 @@ static void CollectSharedAndAnnotatedNodesInRhs (NodeS **root_p,NodeDefS **defs_
{
NodeDefS **last;
NodeP root_node;
/*
scope=1;
*/
NodeIdCount=1;
NodeIdStackTop = (NodeId)-1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment