Commit 2056ce9f authored by johnvg@science.ru.nl's avatar johnvg@science.ru.nl
Browse files

print label names using (functions using) FPut[CSI]OutFile instead of FPrintF...

print label names using (functions using) FPut[CSI]OutFile instead of FPrintF in instructions.c in the backend
parent fe3c7c39
......@@ -147,18 +147,109 @@ static Bool DescriptorNeeded (SymbDef sdef)
((DoParallel || DoDescriptors) && (sdef->sdef_mark & (SDEF_USED_CURRIED_MASK | SDEF_USED_LAZILY_MASK)));
}
static void put_label_module_prefix (char *module_name)
static void put_label_module_prefix_name (char *module_name,char *prefix,char *name)
{
PutSOutFile ("e_");
PutSOutFile (module_name);
PutCOutFile ('_');
PutSOutFile (prefix);
PutSOutFile (name);
}
static void put_space_label_module_prefix (char *module_name)
static void put_space_label_module_prefix_name (char *module_name,char *prefix,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutCOutFile ('_');
PutSOutFile (prefix);
PutSOutFile (name);
}
static void put_space_label_module_constructor_r_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" CONSTRUCTOR_R_PREFIX);
PutSOutFile (name);
}
static void put_space_label_module_d_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" D_PREFIX);
PutSOutFile (name);
}
static void put_space_label_module_ea_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" EA_PREFIX);
PutSOutFile (name);
}
static void put_space_label_module_eu_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" EU_PREFIX);
PutSOutFile (name);
}
static void put_space_label_module_l_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" L_PREFIX);
PutSOutFile (name);
}
static void put_space_label_module_n_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" N_PREFIX);
PutSOutFile (name);
}
static void put_space_label_module_r_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" R_PREFIX);
PutSOutFile (name);
}
static void put_space_label_module_record_d_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" RECORD_D_PREFIX);
PutSOutFile (name);
}
static void put_space_label_module_record_n_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" RECORD_N_PREFIX);
PutSOutFile (name);
}
static void put_space_label_module_s_name (char *module_name,char *name)
{
PutSOutFile (" e_");
PutSOutFile (module_name);
PutSOutFile ("_" S_PREFIX);
PutSOutFile (name);
}
static void put_space_quoted_string (char *s)
{
PutSOutFile (" \"");
PutSOutFile (s);
PutCOutFile ('\"');
}
static void Put_SOutFile (char *s)
......@@ -173,27 +264,34 @@ static void PutSSOutFile (char *s1,char *s2)
PutSOutFile (s2);
}
static void PutSdotUOutFile (char *s1,unsigned int u)
static void PutSUOutFile (char *s1,unsigned int u)
{
PutSOutFile (s1);
PutCOutFile ('.');
PutIOutFile ((int)u);
}
static void PutSSdotDOutFile (char *s1,char *s2,int i)
static void PutSdotSOutFile (char *s1,char *s2)
{
PutSOutFile (s1);
PutSOutFile (s2);
PutCOutFile ('.');
PutIOutFile (i);
PutSOutFile (s2);
}
static void PutSUOutFile (char *s1,unsigned int u)
static void PutSdotUOutFile (char *s1,unsigned int u)
{
PutSOutFile (s1);
PutCOutFile ('.');
PutIOutFile ((int)u);
}
static void PutSSdotDOutFile (char *s1,char *s2,int i)
{
PutSOutFile (s1);
PutSOutFile (s2);
PutCOutFile ('.');
PutIOutFile (i);
}
static void PutSSdotSOutFile (char *s1,char *s2,char *s3)
{
PutSOutFile (s1);
......@@ -210,6 +308,18 @@ static void PutSSdotUOutFile (char *s1,char *s2,unsigned int u)
PutIOutFile ((int)u);
}
static void PutdotSOutFile (char *s)
{
PutCOutFile ('.');
PutSOutFile (s);
}
static void PutdotUOutFile (unsigned int u)
{
PutCOutFile ('.');
PutIOutFile ((int)u);
}
static void GenLabel (Label label)
{
if (label->lab_issymbol){
......@@ -219,10 +329,9 @@ static void GenLabel (Label label)
def=label->lab_symbol;
module_name = label->lab_mod;
if (module_name!=NULL){
put_label_module_prefix (module_name);
PutSSOutFile (label->lab_pref,def->sdef_name);
} else if (DoDebug){
if (module_name!=NULL)
put_label_module_prefix_name (module_name,label->lab_pref,def->sdef_name);
else if (DoDebug){
if (def->sdef_kind==IMPRULE)
PutSSdotUOutFile (label->lab_pref,def->sdef_name,def->sdef_number);
else
......@@ -238,7 +347,7 @@ static void GenLabel (Label label)
PutSOutFile (label->lab_name);
}
if (label->lab_post!=0)
PutSUOutFile (".",label->lab_post);
PutdotUOutFile (label->lab_post);
}
static void GenDescriptorOrNodeEntryLabel (Label label)
......@@ -250,15 +359,12 @@ static void GenDescriptorOrNodeEntryLabel (Label label)
def=label->lab_symbol;
module_name = label->lab_mod;
if (module_name!=NULL){
put_label_module_prefix (module_name);
PutSSOutFile (label->lab_pref,def->sdef_name);
} else if (ExportLocalLabels){
put_label_module_prefix (CurrentModule);
if (module_name!=NULL)
put_label_module_prefix_name (module_name,label->lab_pref,def->sdef_name);
else if (ExportLocalLabels){
put_label_module_prefix_name (CurrentModule,label->lab_pref,def->sdef_name);
if (def->sdef_kind==IMPRULE)
PutSSdotUOutFile (label->lab_pref,def->sdef_name,def->sdef_number);
else
PutSSOutFile (label->lab_pref,def->sdef_name);
PutdotUOutFile (def->sdef_number);
} else if (DoDebug){
if (def->sdef_kind==IMPRULE)
PutSSdotUOutFile (label->lab_pref,def->sdef_name,def->sdef_number);
......@@ -275,7 +381,7 @@ static void GenDescriptorOrNodeEntryLabel (Label label)
PutSOutFile (label->lab_name);
}
if (label->lab_post!=0)
PutSUOutFile (".",label->lab_post);
PutdotUOutFile (label->lab_post);
}
#if !BINARY_ABC
......@@ -1301,7 +1407,7 @@ static void GenUnboxedRecordLabelsReversed (StateS state)
else
PutSUOutFile (" " R_PREFIX,record_sdef->sdef_number);
} else
FPrintF (OutFile, " e_%s_" R_PREFIX "%s",record_sdef->sdef_module,record_sdef->sdef_name);
put_space_label_module_r_name (record_sdef->sdef_module,record_sdef->sdef_name);
return;
}
case ArrayState:
......@@ -2003,15 +2109,15 @@ static void GenFieldLabel (Label label,char *record_name)
def = (SymbDef) label->lab_name;
if (label->lab_mod){
put_label_module_prefix (label->lab_mod);
PutSSdotSOutFile (label->lab_pref,record_name,def->sdef_name);
put_label_module_prefix_name (label->lab_mod,label->lab_pref,record_name);
PutdotSOutFile (def->sdef_name);
} else if (ExportLocalLabels){
put_label_module_prefix (CurrentModule);
PutSSdotSOutFile (label->lab_pref,record_name,def->sdef_name);
put_label_module_prefix_name (CurrentModule,label->lab_pref,record_name);
PutdotSOutFile (def->sdef_name);
} else if (DoDebug){
PutSSdotSOutFile (label->lab_pref,record_name,def->sdef_name);
if (def->sdef_kind==IMPRULE)
PutSUOutFile (".",def->sdef_number);
PutdotUOutFile (def->sdef_number);
} else if (def->sdef_number==0)
PutSSOutFile (label->lab_pref,def->sdef_name);
else if (label->lab_pref[0] == '\0')
......@@ -2332,8 +2438,8 @@ void GenCreate (int arity)
void GenDumpString (char *str)
{
put_instruction_ (Iprint);
FPrintF (OutFile, "\"%s\"", str);
put_instruction (Iprint);
put_space_quoted_string (str);
put_instruction (Ihalt);
}
......@@ -2491,8 +2597,8 @@ void GenImpRecordDesc (char *module_name,char *record_name)
GenImpMod (module_name);
}
put_directive_b (impdesc);
FPrintF (OutFile, "e_%s_" R_PREFIX "%s",module_name,record_name);
put_directiveb (impdesc);
put_space_label_module_r_name (module_name,record_name);
}
void GenImport (SymbDef sdef)
......@@ -2506,12 +2612,12 @@ void GenImport (SymbDef sdef)
case DEFRULE:
case SYSRULE:
if (sdef->sdef_mark & (SDEF_USED_CURRIED_MASK | SDEF_USED_LAZILY_MASK)){
put_directive_b (impdesc);
FPrintF (OutFile, "e_%s_" D_PREFIX "%s",sdef->sdef_module,name);
put_directiveb (impdesc);
put_space_label_module_d_name (sdef->sdef_module,name);
}
if (sdef->sdef_mark & SDEF_USED_STRICTLY_MASK && sdef->sdef_arfun==NoArrayFun){
put_directive_b (implab);
FPrintF (OutFile,"e_%s_" S_PREFIX "%s",sdef->sdef_module,name);
put_directiveb (implab);
put_space_label_module_s_name (sdef->sdef_module,name);
}
break;
case FIELDSELECTOR:
......@@ -2520,16 +2626,18 @@ void GenImport (SymbDef sdef)
record_name = sdef->sdef_type->type_symbol->symb_def->sdef_name;
put_directive_b (impdesc);
FPrintF (OutFile, "e_%s_" D_PREFIX "%s.%s",sdef->sdef_module,record_name,name);
put_directiveb (impdesc);
put_space_label_module_d_name (sdef->sdef_module,record_name);
PutdotSOutFile (name);
put_directive_b (implab);
FPrintF (OutFile, "e_%s_" N_PREFIX "%s.%s",sdef->sdef_module,record_name,name);
put_directiveb (implab);
put_space_label_module_n_name (sdef->sdef_module,record_name);
PutdotSOutFile (name);
if (sdef->sdef_calledwithrootnode)
FPrintF (OutFile, " e_%s_" EA_PREFIX "%s.%s",sdef->sdef_module,record_name,name);
else if (sdef->sdef_returnsnode)
if (sdef->sdef_calledwithrootnode){
put_space_label_module_ea_name (sdef->sdef_module,record_name);
PutdotSOutFile (name);
} else if (sdef->sdef_returnsnode)
PutSOutFile (" _");
}
return;
......@@ -2544,10 +2652,10 @@ void GenImport (SymbDef sdef)
return;
if (sdef->sdef_mark & SDEF_USED_LAZILY_MASK){
put_directive_b (impdesc);
FPrintF (OutFile, "e_%s_" RECORD_D_PREFIX "%s", sdef->sdef_module,name);
put_directive_b (implab);
FPrintF (OutFile, "e_%s_" RECORD_N_PREFIX "%s",sdef->sdef_module,name);
put_directiveb (impdesc);
put_space_label_module_record_d_name (sdef->sdef_module,name);
put_directiveb (implab);
put_space_label_module_record_n_name (sdef->sdef_module,name);
}
return;
case CONSTRUCTOR:
......@@ -2555,19 +2663,19 @@ void GenImport (SymbDef sdef)
return;
if (!sdef->sdef_strict_constructor){
put_directive_b (impdesc);
FPrintF (OutFile, "e_%s_" D_PREFIX "%s", sdef->sdef_module,name);
put_directiveb (impdesc);
put_space_label_module_d_name (sdef->sdef_module,name);
return;
}
if (sdef->sdef_mark & (SDEF_USED_STRICTLY_MASK | SDEF_USED_LAZILY_MASK)){
put_directive_b (impdesc);
FPrintF (OutFile, "e_%s_" CONSTRUCTOR_R_PREFIX "%s",sdef->sdef_module,name);
put_directiveb (impdesc);
put_space_label_module_constructor_r_name (sdef->sdef_module,name);
}
if (sdef->sdef_mark & (SDEF_USED_LAZILY_MASK | SDEF_USED_CURRIED_MASK)){
put_directive_b (impdesc);
FPrintF (OutFile, "e_%s_" D_PREFIX "%s", sdef->sdef_module,name);
put_directiveb (impdesc);
put_space_label_module_d_name (sdef->sdef_module,name);
}
break;
default:
......@@ -2575,13 +2683,13 @@ void GenImport (SymbDef sdef)
}
if (sdef->sdef_mark & SDEF_USED_LAZILY_MASK){
put_directive_b (implab);
FPrintF (OutFile, "e_%s_" N_PREFIX "%s",sdef->sdef_module,name);
put_directiveb (implab);
put_space_label_module_n_name (sdef->sdef_module,name);
if ((sdef->sdef_calledwithrootnode || sdef->sdef_returnsnode) &&
!(sdef->sdef_kind==CONSTRUCTOR && !sdef->sdef_strict_constructor))
{
if (sdef->sdef_calledwithrootnode)
FPrintF (OutFile, " e_%s_" EA_PREFIX "%s",sdef->sdef_module,name);
put_space_label_module_ea_name (sdef->sdef_module,name);
else
PutSOutFile (" _");
}
......@@ -2595,12 +2703,12 @@ void GenExportStrictAndEaEntry (SymbDef sdef)
name = sdef->sdef_name;
put_directive_ (Dexport);
FPrintF (OutFile, "e_%s_" S_PREFIX "%s", CurrentModule,name);
put_directive (Dexport);
put_space_label_module_s_name (CurrentModule,name);
if (sdef->sdef_calledwithrootnode){
put_directive_ (Dexport);
FPrintF (OutFile, "e_%s_%s%s", CurrentModule, ea_pref, name);
put_directive (Dexport);
put_space_label_module_ea_name (CurrentModule,name);
}
}
......@@ -2613,30 +2721,33 @@ void GenExportFieldSelector (SymbDef sdef)
record_name=sdef->sdef_type->type_symbol->symb_def->sdef_name;
put_directive_ (Dexport);
FPrintF (OutFile,"e_%s_" D_PREFIX "%s.%s",CurrentModule,record_name,name);
put_directive_ (Dexport);
FPrintF (OutFile,"e_%s_" N_PREFIX "%s.%s",CurrentModule,record_name,name);
put_directive (Dexport);
put_space_label_module_d_name (CurrentModule,record_name);
PutdotSOutFile (name);
put_directive (Dexport);
put_space_label_module_n_name (CurrentModule,record_name);
PutdotSOutFile (name);
if (sdef->sdef_calledwithrootnode){
put_directive_ (Dexport);
FPrintF (OutFile,"e_%s_" EA_PREFIX "%s.%s",CurrentModule,record_name,name);
put_directive (Dexport);
put_space_label_module_ea_name (CurrentModule,record_name);
PutdotSOutFile (name);
}
}
void GenExportEaEntry (SymbDef sdef)
{
if (sdef->sdef_calledwithrootnode){
put_directive_ (Dexport);
FPrintF (OutFile,"e_%s_" EA_PREFIX "%s",CurrentModule,sdef->sdef_name);
put_directive (Dexport);
put_space_label_module_ea_name (CurrentModule,sdef->sdef_name);
}
}
void GenExportEuEntry (SymbDef sdef)
{
if (sdef->sdef_calledwithrootnode){
put_directive_ (Dexport);
FPrintF (OutFile,"e_%s_" EU_PREFIX "%s",CurrentModule,sdef->sdef_name);
put_directive (Dexport);
put_space_label_module_eu_name (CurrentModule,sdef->sdef_name);
}
}
......@@ -2739,8 +2850,8 @@ void GenNodeEntryDirective (int arity,Label label,Label label2)
}
#ifdef MEMORY_PROFILING_WITH_N_STRING
if (DoProfiling && arity>=0 && !DoParallel){
put_directive_ (Dn_string);
FPrintF (OutFile,"\"%s\"",label->lab_symbol->sdef_name);
put_directive (Dn_string);
put_space_quoted_string (label->lab_symbol->sdef_name);
}
#endif
}
......@@ -2786,8 +2897,8 @@ void GenLazyRecordNodeEntryDirective (int arity,Label label,Label label2)
#ifdef MEMORY_PROFILING_WITH_N_STRING
if (DoProfiling && arity>=0 && !DoParallel){
put_directive_ (Dn_string);
FPrintF (OutFile,"\"%s\"",label->lab_symbol->sdef_name);
put_directive (Dn_string);
put_space_quoted_string (label->lab_symbol->sdef_name);
}
#endif
}
......@@ -2809,8 +2920,8 @@ void GenNodeEntryDirectiveForLabelWithoutSymbol (int arity,Label label,Label lab
#ifdef MEMORY_PROFILING_WITH_N_STRING
if (DoProfiling && arity>=0 && !DoParallel){
put_directive_ (Dn_string);
FPrintF (OutFile,"\"%s\"",label->lab_name);
put_directive (Dn_string);
put_space_quoted_string (label->lab_name);
}
#endif
}
......@@ -2835,8 +2946,8 @@ void GenNodeEntryDirectiveUnboxed (int a_size,int b_size,Label label,Label label
# ifdef MEMORY_PROFILING_WITH_N_STRING
if (DoProfiling && !DoParallel){
put_directive_ (Dn_string);
FPrintF (OutFile,"\"%s\"",label->lab_symbol->sdef_name);
put_directive (Dn_string);
put_space_quoted_string (label->lab_symbol->sdef_name);
}
# endif
}
......@@ -2877,22 +2988,22 @@ void GenConstructorDescriptorAndExport (SymbDef sdef)
add_argument_label=&hnf_lab;
if (sdef->sdef_exported || ExportLocalLabels){
put_directive_ (Dexport);
FPrintF (OutFile, "e_%s_" D_PREFIX "%s",CurrentModule,name);
put_directive_ (Ddesc);
FPrintF (OutFile, "e_%s_" D_PREFIX "%s %s %s %d 0 \"%s\"",
CurrentModule, name, hnf_lab.lab_name, add_argument_label->lab_name,
sdef->sdef_arity, name);
put_directive (Dexport);
put_space_label_module_d_name (CurrentModule,name);
put_directive (Ddesc);
put_space_label_module_d_name (CurrentModule,name);
} else if (DoDebug){
put_directive_ (Ddesc);
FPrintF (OutFile, D_PREFIX "%s %s %s %d 0 \"%s\"",
name,hnf_lab.lab_name, add_argument_label->lab_name, sdef->sdef_arity, name);
put_directive (Ddesc);
PutSSOutFile (" " D_PREFIX, name);
} else {
put_directive_ (Ddesc);
FPrintF (OutFile, LOCAL_D_PREFIX "%u %s %s %d 0 \"%s\"",
sdef->sdef_number, hnf_lab.lab_name, add_argument_label->lab_name,
sdef->sdef_arity, name);
put_directive (Ddesc);
PutSUOutFile (" " LOCAL_D_PREFIX,sdef->sdef_number);
}
Put_SOutFile (hnf_lab.lab_name);
Put_SOutFile (add_argument_label->lab_name);
put_arguments_n_b (sdef->sdef_arity);
PutSOutFile (" 0");
put_space_quoted_string (name);
}
void GenConstructor0DescriptorAndExport (SymbDef sdef,int constructor_n)
......@@ -2902,17 +3013,19 @@ void GenConstructor0DescriptorAndExport (SymbDef sdef,int constructor_n)
name = sdef->sdef_name;
if (sdef->sdef_exported || ExportLocalLabels){
put_directive_ (Dexport);
FPrintF (OutFile, "e_%s_" D_PREFIX "%s",CurrentModule,name);
put_directive_ (Ddesc0);
FPrintF (OutFile, "e_%s_" D_PREFIX "%s %d \"%s\"",CurrentModule, name, constructor_n , name);
put_directive (Dexport);
put_space_label_module_d_name (CurrentModule,name);
put_directive (Ddesc0);
put_space_label_module_d_name (CurrentModule,name);
} else if (DoDebug){
put_directive_ (Ddesc0);
FPrintF (OutFile, D_PREFIX "%s %d \"%s\"",name, constructor_n, name);
put_directive (Ddesc0);
PutSSOutFile (" " D_PREFIX,name);
} else {
put_directive_ (Ddesc0);
FPrintF (OutFile, LOCAL_D_PREFIX "%u %d \"%s\"",sdef->sdef_number, constructor_n, name);
put_directive (Ddesc0);
PutSUOutFile (" " LOCAL_D_PREFIX,sdef->sdef_number);
}
put_arguments_n_b (constructor_n);
put_space_quoted_string (name);
}
void GenRecordDescriptor (SymbDef sdef)
......@@ -2933,24 +3046,25 @@ void GenRecordDescriptor (SymbDef sdef)
name = sdef->sdef_name;
if (sdef->sdef_exported || ExportLocalLabels){
put_directive_ (Dexport);
FPrintF (OutFile, "e_%s_" R_PREFIX "%s",CurrentModule,name);
put_directive_ (Drecord);
FPrintF (OutFile, "e_%s_" R_PREFIX "%s ",CurrentModule,name);
put_directive (Dexport);
put_space_label_module_r_name (CurrentModule,name);
put_directive (Drecord);
put_space_label_module_r_name (CurrentModule,name);
} else if (DoDebug){
put_directive_ (Drecord);
FPrintF (OutFile, R_PREFIX "%s ",name);
put_directive (Drecord);
PutSSOutFile (" " R_PREFIX,name);
} else {
put_directive_ (Drecord);
FPrintF (OutFile, R_PREFIX "%u ",sdef->sdef_number);
put_directive (Drecord);
PutSUOutFile (" " R_PREFIX,sdef->sdef_number);
}
PutCOutFile (' ');
GenABStackElemsOfRecord (recstate);
put_arguments_nn_b (asize,bsize);
if (has_unboxed_record)
GenUnboxedRecordLabelsReversedForRecord (recstate);
FPrintF (OutFile, " \"%s\"",name);
put_space_quoted_string (name);
}
#ifdef STRICT_LISTS
......@@ -2975,11 +3089,9 @@ void GenUnboxedConsRecordDescriptor (SymbDef sdef,int tail_strict)
if (ExportLocalLabels){
put_directive (Dexport);
put_space_label_module_prefix (CurrentModule);
PutSSOutFile (unboxed_record_cons_prefix,name);
put_space_label_module_prefix_name (CurrentModule,unboxed_record_cons_prefix,name);
put_directive (Drecord);
put_space_label_module_prefix (CurrentModule);
PutSSOutFile (unboxed_record_cons_prefix,name);
put_space_label_module_prefix_name (CurrentModule,unboxed_record_cons_prefix,name);
} else {
put_directive_ (Drecord);
PutSSOutFile (unboxed_record_cons_prefix,name);
......@@ -2996,16 +3108,21 @@ void GenUnboxedConsRecordDescriptor (SymbDef sdef,int tail_strict)
if (!sdef->sdef_exported && sdef->sdef_module==CurrentModule && !ExportLocalLabels){
if (DoDebug)
FPrintF (OutFile, " " R_PREFIX "%s ",name);
PutSSOutFile (" " R_PREFIX,name);
else