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) ...@@ -39,8 +39,8 @@ static void set_root_scope_numbers (NodeP node_p,int local_scope)
int new_local_scope; int new_local_scope;
ArgP arg_p; ArgP arg_p;
node_p->node_if_scope=local_scope; node_p->node_if_scope=scope;
new_local_scope=scope+2; new_local_scope=scope+2;
scope+=3; scope+=3;
...@@ -61,33 +61,48 @@ static void set_root_scope_numbers (NodeP node_p,int local_scope) ...@@ -61,33 +61,48 @@ static void set_root_scope_numbers (NodeP node_p,int local_scope)
case SwitchNode: case SwitchNode:
{ {
ArgP arg_p; ArgP arg_p;
int old_scope;
old_scope=scope;
for_l (arg_p,node_p->node_arguments,arg_next){ for_l (arg_p,node_p->node_arguments,arg_next){
NodeP node; NodeP node_p;
node=arg_p->arg_node; scope=old_scope;
if (node->node_kind==CaseNode){
node_p=arg_p->arg_node;
if (node_p->node_kind==CaseNode){
NodeP case_alt_node_p; NodeP case_alt_node_p;
case_alt_node_p=node->node_arguments->arg_node; case_alt_node_p=node_p->node_arguments->arg_node;
/* Cedewarrior bug if (case_alt_node_p->node_kind==PushNode){ */ /* Cedewarrior bug if (case_alt_node_p->node_kind==PushNode) */
if (node->node_arguments->arg_node->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); set_root_scope_numbers (case_alt_node_p->node_arguments->arg_next->arg_node, local_scope);
}
else else
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->node_kind==DefaultNode){ } else if (node_p->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 } else
ErrorInCompiler ("set_scope_numbers.c", "set_root_scope_numbers", ""); ErrorInCompiler ("set_scope_numbers.c", "set_root_scope_numbers", "");
set_node_id_scope_numbers (node_p->node_node_defs,local_scope);
} }
} }
break; break;
case GuardNode: case GuardNode:
{
int old_scope;
old_scope=scope;
set_root_scope_numbers (node_p->node_arguments->arg_node,local_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_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); set_node_id_scope_numbers (node_p->node_node_defs,local_scope);
break; break;
}
} }
} }
......
...@@ -1530,6 +1530,11 @@ static Bool AdjustState (StateS *old_state_p, StateS newstate) ...@@ -1530,6 +1530,11 @@ static Bool AdjustState (StateS *old_state_p, StateS newstate)
return False; 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) static void DetermineStateOfThenOrElse (Args t_or_e_args, NodeDefs *t_or_e_defs, StateS demstate,int local_scope)
{ {
Node node; Node node;
...@@ -1542,8 +1547,12 @@ static void DetermineStateOfThenOrElse (Args t_or_e_args, NodeDefs *t_or_e_defs, ...@@ -1542,8 +1547,12 @@ static void DetermineStateOfThenOrElse (Args t_or_e_args, NodeDefs *t_or_e_defs,
node_id=node->node_node_id; node_id=node->node_node_id;
if (node_id->nid_ref_count_copy>=0) if (node_id->nid_ref_count_copy>=0)
--node_id->nid_ref_count_copy__; --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); DetermineStatesOfRootNodeAndDefs (node,t_or_e_defs,demstate, local_scope);
}
AdjustState (&t_or_e_args->arg_state,demstate); AdjustState (&t_or_e_args->arg_state,demstate);
} }
...@@ -1554,10 +1563,6 @@ static void DecrementRefCountCopy (NodeId nid) ...@@ -1554,10 +1563,6 @@ static void DecrementRefCountCopy (NodeId nid)
--nid->nid_ref_count_copy__; --nid->nid_ref_count_copy__;
} }
#if 0
# include "dbprint.h"
#endif
static Bool AdjustStateOfSharedNode (NodeId nid, StateS demstate, int local_scope) static Bool AdjustStateOfSharedNode (NodeId nid, StateS demstate, int local_scope)
{ {
/* /*
...@@ -1581,9 +1586,9 @@ static Bool AdjustStateOfSharedNode (NodeId nid, StateS demstate, int local_scop ...@@ -1581,9 +1586,9 @@ static Bool AdjustStateOfSharedNode (NodeId nid, StateS demstate, int local_scop
node_id_scope=-node_id_scope; node_id_scope=-node_id_scope;
#if 0 #if 0
printf ("AdjustStateOfSharedNode "); FPrintF (rules_file,"AdjustStateOfSharedNode ");
DPrintNodeId (nid,StdOut); DPrintNodeId (nid,rules_file);
printf (" %d %d\n",node_id_scope,local_scope); FPrintF (rules_file," %d %d\n",node_id_scope,local_scope);
#endif #endif
if (node_id_scope>=local_scope){ if (node_id_scope>=local_scope){
...@@ -1845,9 +1850,9 @@ static Bool NodeInAStrictContext (Node node,StateS demanded_state,int local_scop ...@@ -1845,9 +1850,9 @@ static Bool NodeInAStrictContext (Node node,StateS demanded_state,int local_scop
node_id_scope=-node_id_scope; node_id_scope=-node_id_scope;
#if 0 #if 0
printf ("NodeInAStrictContext select_symb "); FPrintF (rules_file,"NodeInAStrictContext select_symb %d ",node->node_arity);
DPrintNodeId (node_id,StdOut); DPrintNodeId (node_id,rules_file);
printf (" %d %d\n",node_id_scope,local_scope); FPrintF (rules_file," %d %d\n",node_id_scope,local_scope);
#endif #endif
if (node_id_scope>=local_scope){ if (node_id_scope>=local_scope){
if (IsSimpleState (argnode->node_state)){ if (IsSimpleState (argnode->node_state)){
...@@ -1873,6 +1878,11 @@ static Bool NodeInAStrictContext (Node node,StateS demanded_state,int local_scop ...@@ -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); 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; node->node_state = demanded_state;
...@@ -3594,7 +3604,7 @@ static NodeDefs *CollectSharedNodeIdsInRootNode (Node* node_p,NodeId parent_node ...@@ -3594,7 +3604,7 @@ static NodeDefs *CollectSharedNodeIdsInRootNode (Node* node_p,NodeId parent_node
for_l (arg_p,root_node->node_arguments,arg_next){ for_l (arg_p,root_node->node_arguments,arg_next){
NodeP node; NodeP node;
node=arg_p->arg_node; node=arg_p->arg_node;
if (node->node_kind==CaseNode){ if (node->node_kind==CaseNode){
NodeP case_alt_node_p; NodeP case_alt_node_p;
...@@ -3631,6 +3641,7 @@ static NodeDefs *CollectSharedNodeIdsInRootNode (Node* node_p,NodeId parent_node ...@@ -3631,6 +3641,7 @@ static NodeDefs *CollectSharedNodeIdsInRootNode (Node* node_p,NodeId parent_node
break; break;
} }
default: default:
scope=1;
last=CollectSharedNodeIdsInNode (node_p,parent_node_id,last); last=CollectSharedNodeIdsInNode (node_p,parent_node_id,last);
break; break;
...@@ -3644,9 +3655,9 @@ static void CollectSharedAndAnnotatedNodesInRhs (NodeS **root_p,NodeDefS **defs_ ...@@ -3644,9 +3655,9 @@ static void CollectSharedAndAnnotatedNodesInRhs (NodeS **root_p,NodeDefS **defs_
{ {
NodeDefS **last; NodeDefS **last;
NodeP root_node; NodeP root_node;
/*
scope=1; scope=1;
*/
NodeIdCount=1; NodeIdCount=1;
NodeIdStackTop = (NodeId)-1; NodeIdStackTop = (NodeId)-1;
......
Supports Markdown
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