Commit 0c647aba authored by johnvg@science.ru.nl's avatar johnvg@science.ru.nl
Browse files

remove function transform_patterns_to_case_and_guard_nodes (not used anymore)

parent c60f5696
......@@ -1137,17 +1137,6 @@ void CodeGeneration (ImpMod imod, char *fname)
GenerateStatesForRecords (imod->im_symbols);
#if defined (TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS) && !CLEAN2
{
ImpRuleP rule_p;
for_l (rule_p,imod->im_rules,rule_next)
transform_patterns_to_case_and_guard_nodes (rule_p->rule_alts);
}
#endif
#if 0
PrintRules (imod->im_rules);
#endif
DoStrictnessAnalysis_and_init_ok = DoStrictnessAnalysis && init_strictness_analysis (imod);
if (DoStrictnessAnalysis_and_init_ok){
......
......@@ -4130,10 +4130,6 @@ static ImpRuleS **OptimiseRule (ImpRuleS *rule)
rule_sdef= CurrentSymbol->symb_def;
#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
transform_patterns_to_case_and_guard_nodes (rule->rule_alts);
#endif
alt=rule->rule_alts;
CurrentLine = alt->alt_line;
......
extern void transform_patterns_to_case_and_guard_nodes (RuleAltS *alt);
extern void set_local_reference_counts (struct node *case_node);
extern void set_global_reference_counts (struct node *case_node);
extern struct node_id_ref_count_list *new_node_id_ref_count (struct node_id_ref_count_list *node_id_ref_count_list,struct node_id *node_id,int ref_count);
......
......@@ -101,23 +101,6 @@ static NodeP new_case_node (SymbolP symbol,int symbol_arity,NodeP node,NodeDefP
return case_node;
}
struct root_and_defs_l {
NodeP ** root_l;
NodeDefP ** def_l;
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
StrictNodeIdP **strict_node_ids_l;
NodeDefP ** end_lhs_defs_l;
#endif
};
struct root_and_defs {
NodeP root;
NodeDefP defs;
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
StrictNodeIdP strict_node_ids;
#endif
};
static NodeP new_push_node (Symbol symbol,int arity,ArgP arguments)
{
NodeP push_node;
......@@ -146,260 +129,6 @@ NodeIdRefCountListP new_node_id_ref_count (NodeIdRefCountListP node_id_ref_count
return new_node_id_ref_count_elem;
}
static NodeIdRefCountListP *insert_new_node_id_ref_count (NodeIdRefCountListP *node_id_ref_count_p,NodeIdP node_id,int ref_count)
{
NodeIdRefCountListP node_id_ref_count_elem;
node_id_ref_count_elem=new_node_id_ref_count (NULL,node_id,ref_count);
*node_id_ref_count_p=node_id_ref_count_elem;
return &node_id_ref_count_elem->nrcl_next;
}
static void transform_normal_pattern_node (NodeP node,StateP state_p,NodeIdP node_id,struct root_and_defs_l *root_and_defs_lp);
static void transform_pattern_arguments (SymbolP symbol,ArgP arguments,int arity,NodeIdP node_id,struct root_and_defs_l *root_and_defs_lp)
{
NodeP push_node;
NodeIdListElementP *last_node_id_p;
ArgP arg,arg1,arg2;
arg2=NewArgument (**root_and_defs_lp->root_l);
arg1=NewArgument (NULL);
arg1->arg_next=arg2;
push_node=new_push_node (symbol,arity,arg1);
**root_and_defs_lp->root_l=push_node;
*root_and_defs_lp->root_l=&arg2->arg_node;
last_node_id_p=&push_node->node_node_ids;
for_l (arg,arguments,arg_next){
NodeIdP argument_node_id;
NodeP node;
node=arg->arg_node;
if (node->node_kind==NormalNode){
argument_node_id=NewNodeId (NULL);
argument_node_id->nid_refcount=-1;
argument_node_id->nid_lhs_state_p_=&arg->arg_state;
transform_normal_pattern_node (node,&arg->arg_state,argument_node_id,root_and_defs_lp);
} else {
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
NodeP argument_node_id_node;
argument_node_id=node->node_node_id;
argument_node_id->nid_lhs_state_p_=&arg->arg_state;
argument_node_id_node=argument_node_id->nid_node;
if (argument_node_id_node){
argument_node_id->nid_node=NULL;
transform_normal_pattern_node (argument_node_id_node,&arg->arg_state,argument_node_id,root_and_defs_lp);
}
#else
argument_node_id=node->node_node_id;
if (argument_node_id->nid_node)
transform_normal_pattern_node (argument_node_id->nid_node,&arg->arg_state,argument_node_id,root_and_defs_lp);
#endif
}
#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
argument_node_id->nid_state_=arg->arg_state;
#endif
*last_node_id_p=CompAllocType (NodeIdListElementS);
(*last_node_id_p)->nidl_node_id=argument_node_id;
last_node_id_p=&(*last_node_id_p)->nidl_next;
}
*last_node_id_p=NULL;
arg1->arg_node=NewNodeIdNode (node_id);
}
static void transform_normal_pattern_node (NodeP node,StateP state_p,NodeIdP node_id,struct root_and_defs_l *root_and_defs_lp)
{
SymbolP symbol;
NodeP switch_node,case_node;
NodeP **root_l;
NodeDefP **def_l;
symbol=node->node_symbol;
root_l=root_and_defs_lp->root_l;
def_l=root_and_defs_lp->def_l;
switch (symbol->symb_kind){
case definition:
case_node=new_case_node (symbol,node->node_arity,**root_l,def_l
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
,root_and_defs_lp->strict_node_ids_l
#endif
);
switch_node=new_switch_node (node_id,case_node,state_p,root_l);
if (node->node_arity>0)
transform_pattern_arguments (symbol,node->node_arguments,node->node_arity,node_id,root_and_defs_lp);
return;
case cons_symb:
case_node=new_case_node (symbol,2,**root_l,def_l
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
,root_and_defs_lp->strict_node_ids_l
#endif
);
switch_node=new_switch_node (node_id,case_node,state_p,root_l);
transform_pattern_arguments (symbol,node->node_arguments,2,node_id,root_and_defs_lp);
return;
case nil_symb:
case_node=new_case_node (symbol,0,**root_l,def_l
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
,root_and_defs_lp->strict_node_ids_l
#endif
);
switch_node=new_switch_node (node_id,case_node,state_p,root_l);
return;
case tuple_symb:
case_node=new_case_node (symbol,node->node_arity,**root_l,def_l
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
,root_and_defs_lp->strict_node_ids_l
#endif
);
switch_node=new_switch_node (node_id,case_node,state_p,root_l);
transform_pattern_arguments (symbol,node->node_arguments,node->node_arity,node_id,root_and_defs_lp);
return;
case apply_symb:
case if_symb:
error_in_function ("transform_normal_pattern_node");
return;
case string_denot:
case_node=new_case_node (symbol,0,**root_l,def_l
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
,root_and_defs_lp->strict_node_ids_l
#endif
);
switch_node=new_switch_node (node_id,case_node,state_p,root_l);
return;
default:
if (symbol->symb_kind < Nr_Of_Basic_Types)
error_in_function ("transform_normal_pattern_node");
else {
#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
if (state_p->state_object==BasicSymbolStates [symbol->symb_kind].state_object){
#endif
case_node=new_case_node (symbol,0,**root_l,def_l
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
,root_and_defs_lp->strict_node_ids_l
#endif
);
switch_node=new_switch_node (node_id,case_node,state_p,root_l);
return;
#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
} else if (state_p->state_object==UnknownObj
# if ABSTRACT_OBJECT
|| state_p->state_object==AbstractObj
# endif
){
case_node=new_case_node (symbol,0,**root_l,def_l
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
,root_and_defs_lp->strict_node_ids_l
#endif
);
switch_node=new_switch_node (node_id,case_node,state_p,root_l);
return;
} else
error_in_function ("transform_normal_pattern_node");
#endif
}
}
}
static void transform_argument (ArgP arg_p,struct root_and_defs_l *root_and_defs_lp)
{
NodeP node;
node=arg_p->arg_node;
switch (node->node_kind){
case NormalNode:
#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
if (arg_p->arg_state.state_type==TupleState || arg_p->arg_state.state_type==RecordState){
ArgP arg;
for_l (arg,node->node_arguments,arg_next)
transform_argument (arg,root_and_defs_lp);
} else
#endif
{
NodeIdP node_id;
node_id=NewNodeId (NULL);
node_id->nid_refcount=-1;
node_id->nid_lhs_state_p_=&arg_p->arg_state;
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
if (node->node_symbol->symb_kind==tuple_symb ||
(node->node_symbol->symb_kind==definition && node->node_symbol->symb_def->sdef_kind==RECORDTYPE))
{
error_in_function ("transform_argument");
} else
#endif
transform_normal_pattern_node (node,&arg_p->arg_state,node_id,root_and_defs_lp);
#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
node_id->nid_state_=arg_p->arg_state;
#endif
arg_p->arg_node=NewNodeIdNode (node_id);
}
break;
case NodeIdNode:
{
NodeIdP node_id;
node_id=node->node_node_id;
if (node_id->nid_node!=NULL){
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
SymbolP node_id_nid_node_symbol;
node_id_nid_node_symbol=node_id->nid_node->node_symbol;
if (node_id_nid_node_symbol->symb_kind==tuple_symb ||
(node_id_nid_node_symbol->symb_kind==definition && node_id_nid_node_symbol->symb_def->sdef_kind==RECORDTYPE))
{
error_in_function ("transform_argument 1");
}
#else
if (arg_p->arg_state.state_type==TupleState || arg_p->arg_state.state_type==RecordState){
error_in_function ("transform_argument 1");
} else
#endif
{
transform_normal_pattern_node (node_id->nid_node,&arg_p->arg_state,node_id,root_and_defs_lp);
node_id->nid_node=NULL;
}
}
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
node_id->nid_lhs_state_p_=&arg_p->arg_state;
#else
node_id->nid_state_=arg_p->arg_state;
#endif
break;
}
default:
error_in_function ("transform_argument");
}
}
#if 0
# include "dbprint.h"
#endif
static void replace_global_ref_count_by_local_ref_count (NodeIdRefCountListP node_id_ref_count_list)
{
NodeIdRefCountListP node_id_ref_count_elem;
......@@ -946,68 +675,3 @@ void determine_failing_cases_and_adjust_ref_counts_of_rule (RuleAltP first_alt)
# endif
}
#endif
#if 0
#include "dbprint.h"
#endif
void transform_patterns_to_case_and_guard_nodes (RuleAltP rule_alts)
{
RuleAltP first_alt;
ArgP arg;
struct root_and_defs_l root_and_defs_l;
NodeP *node_p;
NodeDefP *def_p;
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
StrictNodeIdP *strict_node_ids_p;
NodeDefP *end_lhs_defs_p;
#endif
first_alt=rule_alts;
if (first_alt->alt_kind!=Contractum)
return;
node_p=&first_alt->alt_rhs_root;
def_p=&first_alt->alt_rhs_defs;
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
strict_node_ids_p=&first_alt->alt_strict_node_ids;
end_lhs_defs_p=&first_alt->alt_lhs_defs;
#endif
root_and_defs_l.root_l=&node_p;
root_and_defs_l.def_l=&def_p;
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
root_and_defs_l.strict_node_ids_l=&strict_node_ids_p;
root_and_defs_l.end_lhs_defs_l=&end_lhs_defs_p;
#endif
for_l (arg,first_alt->alt_lhs_root->node_arguments,arg_next)
transform_argument (arg,&root_and_defs_l);
if (first_alt->alt_next!=NULL)
error_in_function ("transform_patterns_to_case_and_guard_nodes");
#ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
*end_lhs_defs_p=NULL;
#endif
first_alt->alt_next=NULL;
#if 0
PrintRuleAlt (first_alt,4,StdOut);
#endif
#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS
{
NodeIdRefCountListP node_id_ref_count_list;
node_id_ref_count_list=NULL;
determine_failing_cases_and_adjust_ref_counts (first_alt->alt_rhs_root,&node_id_ref_count_list);
}
# if 0
PrintRuleAlt (first_alt,4,StdOut);
# endif
#endif
}
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