Commit 11927276 authored by johnvg@science.ru.nl's avatar johnvg@science.ru.nl

add and use function convert_int_to_string

parent e787e618
......@@ -2581,7 +2581,8 @@ SymbDef CreateUpdateFunction (ArgS *record_arg,ArgS *first_field_arg,Node node
StateS record_state,boxed_record_state;
StateP strict_record_state_p;
sprintf (update_function_name,"_upd%d",next_update_function_n);
strcpy (update_function_name,"_upd");
int_to_string (&update_function_name[4],next_update_function_n);
++next_update_function_n;
n_arguments=node->node_arity;
......@@ -2764,8 +2765,9 @@ SymbDef create_select_function (Symbol selector_symbol,int selector_kind)
int fieldnr;
selector_sdef=selector_symbol->symb_def;
sprintf (select_function_name,"_sel%d",next_update_function_n);
strcpy (select_function_name,"_sel");
int_to_string (&select_function_name[4],next_update_function_n);
++next_update_function_n;
select_function_sdef=MakeNewSymbolDefinition (CurrentModule,select_function_name,1,IMPRULE);
......@@ -2852,7 +2854,8 @@ static SymbDef create_match_function_sdef (void)
char match_function_name[16];
SymbDef match_function_sdef;
sprintf (match_function_name,"_match%d",next_match_function_n);
strcpy (match_function_name,"_match");
int_to_string (&match_function_name[6],next_match_function_n);
++next_match_function_n;
match_function_sdef=MakeNewSymbolDefinition (CurrentModule,match_function_name,1,IMPRULE);
......
......@@ -185,6 +185,69 @@ void CompFree (void)
}
}
void int_to_string (char *s,long i)
{
unsigned long u;
unsigned int p,ua[8];
int ua_i;
if (i<0){
*s++ = '-';
u = -i;
} else
u = i;
ua_i = 0;
while (u>=10000){
unsigned long d;
d = u/10000;
ua[ua_i++] = u-d*10000;
u = d;
}
if (u<10){
*s++ = '0'+u;
} else if (u<100){
unsigned int i;
p = u*103;
i=p>>10;
*s++ = '0'+i;
*s++ = '0'+(u-10*i);
} else if (u<1000){
p = u*41;
*s++ = '0'+(p>>12);
p = 10 * (p & 0xfff);
*s++ = '0'+(p>>12);
p = 10 * (p & 0xfff);
*s++ = '0'+(p>>12);
} else {
p = u*8389;
*s++ = '0'+(p>>23);
p = 10 * (p & 0x7fffff);
*s++ = '0'+(p>>23);
p = 10 * (p & 0x7fffff);
*s++ = '0'+(p>>23);
p = 10 * (p & 0x7fffff);
*s++ = '0'+(p>>23);
}
while (ua_i>0){
u = ua[--ua_i];
p = u*8389;
*s++ = '0'+(p>>23);
p = 10 * (p & 0x7fffff);
*s++ = '0'+(p>>23);
p = 10 * (p & 0x7fffff);
*s++ = '0'+(p>>23);
p = 10 * (p & 0x7fffff);
*s++ = '0'+(p>>23);
}
*s='\0';
}
/* The environment to leave the compiler if a fatal error occurs */
void FatalCompError (char *mod, char *proc, char *mess)
......
......@@ -44,6 +44,8 @@ extern void *CompAlloc (SizeT size);
extern void InitStorage (void);
extern void CompFree (void);
extern void int_to_string (char *s,long i);
extern void FatalCompError (char *mod, char *proc, char *mess);
extern void InitSettings (void);
......
......@@ -1696,7 +1696,9 @@ static ImpRuleP create_new_partially_applied_local_function (Node node,int old_f
Node lhs_root,rhs_root;
char *function_name_p,*end_function_name;
sprintf (function_name,"_f%d",next_function_n);
function_name[0] = '_';
function_name[1] = 'f';
int_to_string (&function_name[2],next_function_n);
++next_function_n;
if (DoTimeProfiling || DoProfiling){
......@@ -1895,7 +1897,9 @@ static struct node *create_new_local_function (Node node,StateP function_state_p
if (n_arguments>MAX_N_FUNCTION_ARGUMENTS)
return NULL;
sprintf (function_name,"_f%d",next_function_n);
function_name[0] = '_';
function_name[1] = 'f';
int_to_string (&function_name[2],next_function_n);
++next_function_n;
if (DoTimeProfiling || DoProfiling){
......
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