Commit 5b8ffadd authored by John van Groningen's avatar John van Groningen
Browse files

remove unused RULE_INTERNAL_FUNCTION_MASK and RULE_LAMBDA_FUNCTION_MASK, and code and arguments

that is/are only used if one of these masks was used
parent 7694b7ce
......@@ -194,11 +194,6 @@ void PrintRuleNode (Node node,Bool brackets,int n_leading_spaces,File file)
#ifdef PRINT_NODE_LINE_NUMBERS
FPrintF (file,"#%d",node->node_line);
#endif
if (node_symb->symb_kind==definition && node_symb->symb_def->sdef_kind==IMPRULE &&
(node_symb->symb_def->sdef_rule->rule_mark & RULE_INTERNAL_FUNCTION_MASK))
{
FPrintF (file,"_%d",node_symb->symb_def->sdef_number);
}
if (node -> node_arguments)
{ FPutC (' ', file);
......
......@@ -319,7 +319,7 @@ static NodeDefP copy_lhs_node_ids_of_node_defs (NodeDefs old_node_defs)
return first_p;
}
static NodeDefP copy_rhs_node_ids_of_node_defs (NodeDefs old_node_defs,NodeDefP **end_node_defs_h)
static NodeDefP copy_rhs_node_ids_of_node_defs (NodeDefs old_node_defs)
{
NodeDefP old_def_p,first_p,*next_h;
......@@ -347,12 +347,6 @@ static NodeDefP copy_rhs_node_ids_of_node_defs (NodeDefs old_node_defs,NodeDefP
*next_h=NULL;
if (end_node_defs_h!=NULL)
if (first_p==NULL)
*end_node_defs_h=NULL;
else
*end_node_defs_h=next_h;
return first_p;
}
......@@ -420,7 +414,7 @@ static Node copy_root_node (Node old)
old_arg=old_arg->arg_next;
new_then_else_info->if_then_node_defs=copy_rhs_node_ids_of_node_defs (old_then_else_info->if_then_node_defs,NULL);
new_then_else_info->if_then_node_defs=copy_rhs_node_ids_of_node_defs (old_then_else_info->if_then_node_defs);
new_arg = CompAllocType (ArgS);
new_arg->arg_state = LazyState;
......@@ -431,7 +425,7 @@ static Node copy_root_node (Node old)
copy_nodes_of_node_defs (new_then_else_info->if_then_node_defs,False);
new_then_else_info->if_then_strict_node_ids=copy_strict_node_ids (old_then_else_info->if_then_strict_node_ids);
new_then_else_info->if_else_node_defs=copy_rhs_node_ids_of_node_defs (old_then_else_info->if_else_node_defs,NULL);
new_then_else_info->if_else_node_defs=copy_rhs_node_ids_of_node_defs (old_then_else_info->if_else_node_defs);
old_arg=old_arg->arg_next;
......@@ -496,7 +490,7 @@ static Node copy_root_node (Node old)
if (case_node_p->node_kind==CaseNode){
new_case_node_p->node_su.su_u.u_case=CompAllocType (CaseNodeContentsS);
new_case_node_p->node_node_defs = copy_rhs_node_ids_of_node_defs (case_node_p->node_node_defs,NULL);
new_case_node_p->node_node_defs = copy_rhs_node_ids_of_node_defs (case_node_p->node_node_defs);
if (case_node_arg_p->arg_node->node_kind==PushNode){
ArgP push_node_arg_1,new_push_node_arg_1,new_push_node_arg_2;
......@@ -568,7 +562,7 @@ static Node copy_root_node (Node old)
} else if (case_node_p->node_kind==DefaultNode){
new_case_node_p->node_su.su_u.u_case=CompAllocType (CaseNodeContentsS);
new_case_node_p->node_node_defs = copy_rhs_node_ids_of_node_defs (case_node_p->node_node_defs,NULL);
new_case_node_p->node_node_defs = copy_rhs_node_ids_of_node_defs (case_node_p->node_node_defs);
copy_nodes_of_node_defs (new_case_node_p->node_node_defs,False);
new_case_node_arg_p->arg_node = copy_root_node (case_node_arg_p->arg_node);
......@@ -603,7 +597,7 @@ static Node copy_root_node (Node old)
new_case_node_p->node_su.su_u.u_case=CompAllocType (CaseNodeContentsS);
new_case_node_p->node_node_defs = copy_rhs_node_ids_of_node_defs (case_node_p->node_node_defs,NULL);
new_case_node_p->node_node_defs = copy_rhs_node_ids_of_node_defs (case_node_p->node_node_defs);
copy_nodes_of_node_defs (new_case_node_p->node_node_defs,False);
new_case_node_arg_p->arg_node = copy_root_node (case_node_arg_p->arg_node);
......@@ -668,7 +662,7 @@ static Node copy_root_node (Node old)
arg_1->arg_node = copy_root_node (old->node_arguments->arg_node);
new->node_node_defs = copy_rhs_node_ids_of_node_defs (old->node_node_defs,NULL);
new->node_node_defs = copy_rhs_node_ids_of_node_defs (old->node_node_defs);
arg_2->arg_node = copy_root_node (old->node_arguments->arg_next->arg_node);
......@@ -744,7 +738,7 @@ static Node copy_node (Node old,Bool lhs)
old_arg=old_arg->arg_next;
new_then_else_info->if_then_node_defs=copy_rhs_node_ids_of_node_defs (old_then_else_info->if_then_node_defs,NULL);
new_then_else_info->if_then_node_defs=copy_rhs_node_ids_of_node_defs (old_then_else_info->if_then_node_defs);
new_arg = CompAllocType (ArgS);
new_arg->arg_state = LazyState;
......@@ -755,7 +749,7 @@ static Node copy_node (Node old,Bool lhs)
copy_nodes_of_node_defs (new_then_else_info->if_then_node_defs,False);
new_then_else_info->if_then_strict_node_ids=copy_strict_node_ids (old_then_else_info->if_then_strict_node_ids);
new_then_else_info->if_else_node_defs=copy_rhs_node_ids_of_node_defs (old_then_else_info->if_else_node_defs,NULL);
new_then_else_info->if_else_node_defs=copy_rhs_node_ids_of_node_defs (old_then_else_info->if_else_node_defs);
old_arg=old_arg->arg_next;
......@@ -810,7 +804,7 @@ static void copy_alts (RuleAltP old_alts,RuleAlts *next_p,Symbol new_symbol)
new->alt_lhs_root->node_symbol=new_symbol;
copy_nodes_of_node_defs (new->alt_lhs_defs,True);
new->alt_rhs_defs=copy_rhs_node_ids_of_node_defs (old->alt_rhs_defs,NULL);
new->alt_rhs_defs=copy_rhs_node_ids_of_node_defs (old->alt_rhs_defs);
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
new->alt_rhs_root = copy_root_node (old->alt_rhs_root);
#else
......@@ -828,26 +822,12 @@ static void copy_alts (RuleAltP old_alts,RuleAlts *next_p,Symbol new_symbol)
*next_p = NULL;
}
void copy_rhs_node_defs_and_root (RuleAltP old_alt_p,NodeP *new_root_node_h,NodeDefP *node_defs_p)
{
NodeDefP new_node_defs,*end_node_defs_h;
new_node_defs=copy_rhs_node_ids_of_node_defs (old_alt_p->alt_rhs_defs,&end_node_defs_h);
*new_root_node_h = copy_node (old_alt_p->alt_rhs_root,False);
copy_nodes_of_node_defs (new_node_defs,False);
if (end_node_defs_h!=NULL){
*end_node_defs_h=*node_defs_p;
*node_defs_p=new_node_defs;
}
}
void copy_imp_rule_nodes (ImpRuleP old_rule_p,ImpRuleP new_rule_p)
{
copy_alts (old_rule_p->rule_alts,&new_rule_p->rule_alts,new_rule_p->rule_type->type_alt_lhs->type_node_symbol);
new_rule_p->rule_line = old_rule_p->rule_line;
new_rule_p->rule_root = new_rule_p->rule_alts->alt_lhs_root;
new_rule_p->rule_mark = old_rule_p->rule_mark & (RULE_CAF_MASK | RULE_INTERNAL_FUNCTION_MASK | RULE_LAMBDA_FUNCTION_MASK);
new_rule_p->rule_mark = old_rule_p->rule_mark & RULE_CAF_MASK;
}
static ImpRules new_strict_result_rules;
......
......@@ -4,5 +4,4 @@ void copy_imp_rule_nodes (ImpRuleP old_rule_p,ImpRuleP new_rule_p);
int optimise_tuple_result_function (Node node,StateS demanded_state);
void generate_states (struct imp_rule *rules,int do_strictness_analysis);
StateP state_of_node_or_node_id (NodeP node_p);
void copy_rhs_node_defs_and_root (RuleAltP old_alt_p,NodeP *new_root_node_h,NodeDefP *node_defs_p);
void add_sizes_of_states_of_node_ids (NodeIdListElementP node_id_list,int *total_a_size_p,int *total_b_size_p);
......@@ -3479,7 +3479,7 @@ static SymbolP copy_imp_rule_and_add_arguments (SymbDef rule_sdef,int n_extra_ar
return new_symbol_p;
}
static int create_new_function_with_more_arguments (NodeP node_p,int determine_node_state)
static void create_new_function_with_more_arguments (NodeP node_p)
{
NodeP function_node_p;
int n_extra_arguments;
......@@ -3547,17 +3547,16 @@ static int create_new_function_with_more_arguments (NodeP node_p,int determine_n
} else
node_p->node_symbol=function_node_p->node_symbol;
} else
return 0;
return;
} else
return 0;
/* 26-6-2000: added DEFRULE and SYSRULE case */
return;
} else if (function_symbol_p->symb_def->sdef_kind==DEFRULE || function_symbol_p->symb_def->sdef_kind==SYSRULE){
if (function_node_p->node_arity + n_extra_arguments <= function_symbol_p->symb_def->sdef_arity){
node_p->node_symbol=function_node_p->node_symbol;
} else
return 0;
return;
} else
return 0;
return;
{
NodeP function_node_p2;
......@@ -3586,7 +3585,7 @@ static int create_new_function_with_more_arguments (NodeP node_p,int determine_n
node_p->node_arity=function_node_p->node_arity+n_extra_arguments;
return 1;
return;
}
} else if (function_symbol_p->symb_kind==if_symb && function_node_p->node_arity==3){
NodeP apply_node_p;
......@@ -3623,13 +3622,10 @@ static int create_new_function_with_more_arguments (NodeP node_p,int determine_n
}
*node_p=*function_node_p;
if (determine_node_state)
DetermineNodeState (node_p);
DetermineNodeState (node_p);
}
}
}
return 0;
}
#endif
......@@ -3787,7 +3783,7 @@ static NodeDefs *CollectSharedNodeIdsInNode (Node* node_p,NodeId parent_node_id,
#ifdef ADD_ARGUMENTS_TO_HIGHER_ORDER_FUNCTIONS
if (node->node_kind==NormalNode && node->node_symbol->symb_kind==apply_symb)
(void) create_new_function_with_more_arguments (node,1);
create_new_function_with_more_arguments (node);
#endif
for_l (arg,node->node_arguments,arg_next){
......@@ -3898,95 +3894,6 @@ static void CollectSharedAndAnnotatedNodesInRhs (NodeS **root_p,NodeDefS **defs_
root_node->node_node_id->nid_node->node_annotation=NoAnnot;
*/
#ifdef ADD_ARGUMENTS_TO_HIGHER_ORDER_FUNCTIONS
while (root_node->node_kind==NormalNode &&
((root_node->node_symbol->symb_kind==apply_symb && create_new_function_with_more_arguments (root_node,0)) ||
(root_node->node_symbol->symb_kind==definition && root_node->node_symbol->symb_def->sdef_kind==IMPRULE)))
{
if (root_node->node_symbol->symb_def->sdef_kind==IMPRULE){
ImpRuleP imp_rule_p;
imp_rule_p=root_node->node_symbol->symb_def->sdef_rule;
if ((imp_rule_p->rule_mark & RULE_LAMBDA_FUNCTION_MASK) &&
root_node->node_symbol->symb_def->sdef_arity==root_node->node_arity &&
imp_rule_p->rule_alts->alt_next==NULL
# ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
&& ! (imp_rule_p->rule_alts->alt_rhs_root->node_kind==SwitchNode ||
imp_rule_p->rule_alts->alt_rhs_root->node_kind==GuardNode ||
imp_rule_p->rule_alts->alt_rhs_root->node_kind==IfNode)
# endif
)
{
ArgP call_arg_p,lhs_arg_p;
for_l (lhs_arg_p,imp_rule_p->rule_alts->alt_lhs_root->node_arguments,arg_next)
if (lhs_arg_p->arg_node->node_kind!=NodeIdNode ||
lhs_arg_p->arg_node->node_node_id->nid_refcount==-1 ||
lhs_arg_p->arg_node->node_node_id->nid_node!=NULL)
{
break;
}
if (lhs_arg_p==NULL){
NodeP new_root_node;
/*
PrintRuleNode (root_node,False,StdOut);
FPrintF (StdOut,"\n");
PrintRuleAlt (imp_rule_p->rule_alts,StdOut);
*/
for_ll (call_arg_p,lhs_arg_p,root_node->node_arguments,imp_rule_p->rule_alts->alt_lhs_root->node_arguments,arg_next,arg_next){
NodeP call_node_p;
NodeIdP lhs_node_id_p,call_node_id_p;
lhs_node_id_p=lhs_arg_p->arg_node->node_node_id;
call_node_p=call_arg_p->arg_node;
if (call_node_p->node_kind==NodeIdNode)
call_node_id_p=call_node_p->node_node_id;
else {
NodeDefP new_node_def_p;
call_node_id_p=NewNodeId (NULL);
call_node_id_p->nid_refcount=1;
call_node_id_p->nid_ref_count_copy_=1;
call_node_id_p->nid_exp_=NULL;
call_node_id_p->nid_node=call_node_p;
new_node_def_p = NewNodeDef (call_node_id_p,call_node_p);
new_node_def_p->def_next=*defs_p;
*defs_p=new_node_def_p;
}
call_node_id_p->nid_mark &= ~SHARED_NODES_COLLECTED_MASK;
if (call_node_id_p->nid_refcount<0)
call_node_id_p->nid_refcount -= -2-lhs_node_id_p->nid_refcount;
else
call_node_id_p->nid_refcount += -2-lhs_node_id_p->nid_refcount;
lhs_node_id_p->nid_forward_node_id=call_node_id_p;
}
copy_rhs_node_defs_and_root (imp_rule_p->rule_alts,&new_root_node,defs_p);
/*
PrintRuleNode (new_root_node,False,StdOut);
FPrintF (StdOut,"\n");
PrintNodeDefs (*defs_p,False,StdOut);
FPrintF (StdOut,"\n");
FPrintF (StdOut,"\n");
*/
root_node=new_root_node;
*root_p=new_root_node;
continue;
}
}
}
break;
}
#endif
last=defs_p;
/* RWS ...
......
......@@ -550,8 +550,6 @@ STRUCT (imp_rule,ImpRule){
#endif
#define RULE_HAS_VERSION_WITH_MORE_ARGUMENTS 32
#define RULE_UNBOXED_LAZY_CALL 64
#define RULE_INTERNAL_FUNCTION_MASK 128
#define RULE_LAMBDA_FUNCTION_MASK 256
#define RULE_CALL_VIA_LAZY_SELECTIONS_ONLY 1024
#define RULE_TAIL_MODULO_CONS_ENTRY_MASK 2048
......
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