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

rename PrintSymbol in comsupport.c to WriteSymbolToStdError and PrintSymbol in...

rename PrintSymbol in comsupport.c to WriteSymbolToStdError and PrintSymbol in instructions.c to WriteSymbolToOutFile, without file argument
parent 93bdffeb
......@@ -351,7 +351,7 @@ void NodeDefComment (NodeDefs nd, char *msg)
if (nd->def_node && (nd->def_node->node_kind==NormalNode || nd->def_node->node_kind==SelectorNode)){
PutSOutFile (": ");
PrintSymbol (nd->def_node->node_symbol, OutFile);
WriteSymbolToOutFile (nd->def_node->node_symbol);
}
PutSOutFile (" (");
PutSOutFile (msg);
......@@ -398,11 +398,11 @@ void ArgComment (Args arg)
if (node->node_kind==NormalNode || node->node_kind==SelectorNode){
PutSOutFile (": ");
PrintSymbol (node->node_symbol, OutFile);
WriteSymbolToOutFile (node->node_symbol);
}
}
} else if (arg_node->node_kind==NormalNode || arg_node->node_kind==SelectorNode)
PrintSymbol (arg->arg_node->node_symbol, OutFile);
WriteSymbolToOutFile (arg->arg_node->node_symbol);
}
}
......@@ -420,7 +420,7 @@ void NodeIdComment (NodeId node_id)
if (node->node_kind==NormalNode || node->node_kind==SelectorNode){
PutSOutFile (": ");
PrintSymbol (node->node_symbol, OutFile);
WriteSymbolToOutFile (node->node_symbol);
}
}
}
......
......@@ -300,7 +300,7 @@ static char *ConvertSymbolKindToString (SymbKind skind)
}
/* do not use if symb_kind==definition */
static char *symbol_to_string (Symbol symbol)
char *symbol_to_string (Symbol symbol)
{
switch (symbol->symb_kind){
case int_denot:
......@@ -334,11 +334,11 @@ static char *symbol_to_string (Symbol symbol)
}
}
static void print_compiler_generated_function_name (char *name, char *name_end, unsigned line_nr, File file)
static void write_compiler_generated_function_name_to_std_error (char *name, char *name_end, unsigned line_nr)
{
char *parsed_digits;
FPutS (name,file);
FPutS (name,StdError);
parsed_digits=NULL;
if (name_end[0]==';' && isdigit (name_end[1])){
......@@ -352,24 +352,24 @@ static void print_compiler_generated_function_name (char *name, char *name_end,
}
if (line_nr>0){
FPrintF (file,"[line: %u]", line_nr);
FPrintF (StdError,"[line: %u]", line_nr);
if (parsed_digits)
name_end=parsed_digits;
} else
if (parsed_digits){
char *d_p;
FPutS ("[line:",file);
FPutS ("[line:",StdError);
for (d_p=name_end+1; d_p<parsed_digits; ++d_p)
FPutC (*d_p,file);
FPutC (']',file);
FPutC (*d_p,StdError);
FPutC (']',StdError);
name_end=parsed_digits;
}
FPutS (name_end,file);
FPutS (name_end,StdError);
}
static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
static void WriteSymbolOfIdentToStdError (char *name, unsigned line_nr)
{
char *name_end;
......@@ -377,16 +377,16 @@ static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
;
if (*name=='\\' && name+1==name_end){
print_compiler_generated_function_name ("<lambda>",name_end,line_nr,file);
write_compiler_generated_function_name_to_std_error ("<lambda>",name_end,line_nr);
return;
}
if (*name == '_'){
if (name+2==name_end && name[1]=='c'){
print_compiler_generated_function_name ("<case>",name_end,line_nr,file);
write_compiler_generated_function_name_to_std_error ("<case>",name_end,line_nr);
return;
} else if (name+3==name_end && name[1]=='i' && name[2]=='f'){
print_compiler_generated_function_name ("<if>",name_end,line_nr,file);
write_compiler_generated_function_name_to_std_error ("<if>",name_end,line_nr);
return;
}
} else
......@@ -394,12 +394,12 @@ static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
char *end_name;
for (; name!=name_end; name++)
FPutC (*name, file);
FPutC (*name, StdError);
for (end_name = name_end + 2; *end_name!=';' && *end_name!='\0'; end_name++)
;
FPrintF (file, " [line: %u]", line_nr);
FPrintF (StdError, " [line: %u]", line_nr);
if (*end_name == '\0')
return;
......@@ -407,15 +407,15 @@ static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
name = end_name;
}
FPutS (name, file);
FPutS (name, StdError);
}
void PrintSymbol (Symbol symbol, File file)
void WriteSymbolToStdError (Symbol symbol)
{
if (symbol->symb_kind==definition)
PrintSymbolOfIdent (symbol->symb_def->sdef_name, 0, file);
WriteSymbolOfIdentToStdError (symbol->symb_def->sdef_name, 0);
else
FPutS (symbol_to_string (symbol), file);
FPutS (symbol_to_string (symbol), StdError);
}
void StaticMessage_D_s (Bool error,struct symbol_def *symb_def_p,char *message)
......@@ -428,7 +428,7 @@ void StaticMessage_D_s (Bool error,struct symbol_def *symb_def_p,char *message)
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
PrintSymbolOfIdent (symb_def_p->sdef_name, 0, StdError);
WriteSymbolOfIdentToStdError (symb_def_p->sdef_name, 0);
FPutS ("]: ", StdError);
FPutS (message, StdError);
......@@ -449,7 +449,7 @@ void StaticMessage_S_s (Bool error,struct symbol *symbol_p,char *message)
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
PrintSymbol (symbol_p, StdError);
WriteSymbolToStdError (symbol_p);
FPutS ("]: ", StdError);
FPutS (message, StdError);
......@@ -470,10 +470,10 @@ void StaticMessage_S_Ss (Bool error,struct symbol *symbol_p1,struct symbol *symb
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
PrintSymbol (symbol_p1, StdError);
WriteSymbolToStdError (symbol_p1);
FPutS ("]: ", StdError);
PrintSymbol (symbol_p2, StdError);
WriteSymbolToStdError (symbol_p2);
FPutS (message, StdError);
FPutC ('\n', StdError);
......@@ -510,7 +510,7 @@ void StaticErrorMessage_S_ss (struct symbol *symbol_p,char *message1,char *messa
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
PrintSymbol (symbol_p, StdError);
WriteSymbolToStdError (symbol_p);
FPutS ("]: ", StdError);
FPutS (message1, StdError);
......@@ -531,7 +531,7 @@ void StaticErrorMessage_s_Ss (char *symbol_s,struct symbol *symbol_p,char *messa
FPutS (symbol_s, StdError);
FPutS ("]: ", StdError);
PrintSymbol (symbol_p, StdError);
WriteSymbolToStdError (symbol_p);
FPutS (message, StdError);
FPutC ('\n', StdError);
......
......@@ -22,7 +22,11 @@ extern void StaticErrorMessage_s_Ss (char *symbol_s,struct symbol *symbol_p,char
extern void StaticErrorMessage_s_ss (char *symbol_s,char *message1,char *message2);
struct symbol;
extern void PrintSymbol (struct symbol *symbol,File file);
/* do not use if symb_kind==definition */
extern char *symbol_to_string (struct symbol *symbol);
extern void WriteSymbolToStdError (struct symbol *symbol);
extern Bool CompilerError;
extern char *CurrentModule, *CompilerVersion;
......@@ -48,7 +52,6 @@ extern void int_to_string (char *s,long i);
extern void FatalCompError (char *mod, char *proc, char *mess);
extern void InitSettings (void);
extern void InitCompiler (void);
extern void ExitCompiler (void);
......
......@@ -143,6 +143,90 @@ static void PrintArguments (Args args, char separator, Bool brackets,int n_leadi
}
}
static void print_compiler_generated_function_name (char *name, char *name_end, unsigned line_nr, File file)
{
char *parsed_digits;
FPutS (name,file);
parsed_digits=NULL;
if (name_end[0]==';' && isdigit (name_end[1])){
char *s;
s=name_end+2;
while (isdigit (*s))
++s;
if (*s==';')
parsed_digits=s;
}
if (line_nr>0){
FPrintF (file,"[line: %u]", line_nr);
if (parsed_digits)
name_end=parsed_digits;
} else
if (parsed_digits){
char *d_p;
FPutS ("[line:",file);
for (d_p=name_end+1; d_p<parsed_digits; ++d_p)
FPutC (*d_p,file);
FPutC (']',file);
name_end=parsed_digits;
}
FPutS (name_end,file);
}
static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
{
char *name_end;
for (name_end=name; *name_end!=';' && *name_end!='\0'; ++name_end)
;
if (*name=='\\' && name+1==name_end){
print_compiler_generated_function_name ("<lambda>",name_end,line_nr,file);
return;
}
if (*name == '_'){
if (name+2==name_end && name[1]=='c'){
print_compiler_generated_function_name ("<case>",name_end,line_nr,file);
return;
} else if (name+3==name_end && name[1]=='i' && name[2]=='f'){
print_compiler_generated_function_name ("<if>",name_end,line_nr,file);
return;
}
} else
if (line_nr > 0 && *name_end == ';' && isdigit (name_end[1])){
char *end_name;
for (; name!=name_end; name++)
FPutC (*name, file);
for (end_name = name_end + 2; *end_name!=';' && *end_name!='\0'; end_name++)
;
FPrintF (file, " [line: %u]", line_nr);
if (*end_name == '\0')
return;
name = end_name;
}
FPutS (name, file);
}
static void PrintSymbol (Symbol symbol, File file)
{
if (symbol->symb_kind==definition)
PrintSymbolOfIdent (symbol->symb_def->sdef_name, 0, file);
else
FPutS (symbol_to_string (symbol), file);
}
void PrintRuleNode (Node node,Bool brackets,int n_leading_spaces,File file)
{
/*
......@@ -665,7 +749,7 @@ static void PrintAttribute (AttributeKind attr, File file)
}
void PrintTypeAlt (TypeAlts type_alts, File file, Bool with_equats)
void PrintTypeAlt (TypeAlts type_alts, File file)
{
TypeNode lhs_root = type_alts -> type_alt_lhs;
......
......@@ -7,7 +7,7 @@ extern void PrintImpRule (ImpRules rule,int n_leading_spaces,File file);
extern void PrintTypeNode (TypeNode node, File file);
extern void DPrintNodeId (NodeId nid, File file);
extern void DPrintNodeIdS (char *s,NodeId nid, File file);
extern void PrintTypeAlt (TypeAlts type_alts, File file, Bool with_equats);
extern void PrintTypeAlt (TypeAlts type_alts, File file);
extern void PrintState (StateS state, File file);
extern void PrintRules (ImpRules rules,File file);
......@@ -793,11 +793,11 @@ static void put_instruction_code (int instruction_code)
PutCOutFile (instruction_code);
}
static void print_compiler_generated_function_name (char *name, char *name_end, unsigned line_nr, File file)
static void write_compiler_generated_function_name_to_out_file (char *name, char *name_end, unsigned line_nr)
{
char *parsed_digits;
FPutS (name,file);
FPutS (name,OutFile);
parsed_digits=NULL;
if (name_end[0]==';' && isdigit (name_end[1])){
......@@ -811,24 +811,26 @@ static void print_compiler_generated_function_name (char *name, char *name_end,
}
if (line_nr>0){
FPrintF (file,"[line: %u]", line_nr);
PutSOutFile ("[line: ");
PutIOutFile ((int)line_nr);
PutCOutFile (']');
if (parsed_digits)
name_end=parsed_digits;
} else
if (parsed_digits){
char *d_p;
FPutS ("[line:",file);
PutSOutFile ("[line:");
for (d_p=name_end+1; d_p<parsed_digits; ++d_p)
FPutC (*d_p,file);
FPutC (']',file);
PutCOutFile (*d_p);
PutCOutFile (']');
name_end=parsed_digits;
}
FPutS (name_end,file);
PutSOutFile (name_end);
}
static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
static void WriteSymbolOfIdentToOutFile (char *name, unsigned line_nr)
{
char *name_end;
......@@ -836,16 +838,16 @@ static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
;
if (*name=='\\' && name+1==name_end){
print_compiler_generated_function_name ("<lambda>",name_end,line_nr,file);
write_compiler_generated_function_name_to_out_file ("<lambda>",name_end,line_nr);
return;
}
if (*name == '_'){
if (name+2==name_end && name[1]=='c'){
print_compiler_generated_function_name ("<case>",name_end,line_nr,file);
write_compiler_generated_function_name_to_out_file ("<case>",name_end,line_nr);
return;
} else if (name+3==name_end && name[1]=='i' && name[2]=='f'){
print_compiler_generated_function_name ("<if>",name_end,line_nr,file);
write_compiler_generated_function_name_to_out_file ("<if>",name_end,line_nr);
return;
}
} else
......@@ -853,20 +855,30 @@ static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
char *end_name;
for (; name!=name_end; name++)
FPutC (*name, file);
PutCOutFile (*name);
for (end_name = name_end + 2; *end_name!=';' && *end_name!='\0'; end_name++)
;
FPrintF (file, " [line: %u]", line_nr);
PutSOutFile (" [line: ");
PutIOutFile ((int)line_nr);
PutCOutFile (']');
if (*end_name == '\0')
return;
name = end_name;
}
FPutS (name, file);
FPutS (name, OutFile);
}
void WriteSymbolToOutFile (Symbol symbol)
{
if (symbol->symb_kind==definition)
WriteSymbolOfIdentToOutFile (symbol->symb_def->sdef_name, 0);
else
PutSOutFile (symbol_to_string (symbol));
}
static void GenGetWL (int offset)
......@@ -3221,7 +3233,7 @@ void GenStrictConstructorDescriptor (SymbDef sdef,StateP constructor_arg_states)
if (has_unboxed_record)
for (arg_n=state_arity-1; arg_n>=0; --arg_n)
GenUnboxedRecordLabelsReversed (constructor_arg_states[arg_n]);
put_space_quoted_string (name);
put_space_quoted_string (name);
}
void GenArrayFunctionDescriptor (SymbDef arr_fun_def, Label desclab, int arity)
......@@ -3374,7 +3386,7 @@ void GenFunctionDescriptorAndExportNodeAndDescriptor (SymbDef sdef)
else
PutSdotUOutFile (name,sdef->sdef_number);
} else
PrintSymbolOfIdent (name, 0, OutFile);
WriteSymbolOfIdentToOutFile (name, 0);
PutCOutFile ('\"');
}
......@@ -3454,7 +3466,7 @@ void GenConstructorFunctionDescriptorAndExportNodeAndDescriptor (SymbDef sdef)
put_arguments_n_b (sdef->sdef_arity);
PutSOutFile (" 0 \"");
PrintSymbolOfIdent (name, 0, OutFile);
WriteSymbolOfIdentToOutFile (name, 0);
PutCOutFile ('\"');
}
......@@ -3486,7 +3498,7 @@ void GenFunctionDescriptorForLazyTupleRecursion (SymbDef sdef,int tuple_result_a
put_arguments_n_b (sdef->sdef_arity+tuple_result_arity);
PutSOutFile (" 0 \"");
PrintSymbolOfIdent (name,0,OutFile);
WriteSymbolOfIdentToOutFile (name,0);
PutCOutFile ('\"');
# if 1
......@@ -3511,7 +3523,7 @@ void GenFunctionDescriptorForLazyTupleRecursion (SymbDef sdef,int tuple_result_a
put_arguments_n_b (sdef->sdef_arity+tuple_result_arity);
PutSOutFile (" 0 \"");
PrintSymbolOfIdent (name,0,OutFile);
WriteSymbolOfIdentToOutFile (name,0);
PutCOutFile ('\"');
# endif
}
......@@ -3868,7 +3880,7 @@ void GenNoMatchError (SymbDef sdef,int asp,int bsp,int string_already_generated)
put_directive (Dstring);
PutSUOutFile (" x_",sdef->sdef_number);
PutSOutFile (" \"");
PrintSymbolOfIdent (sdef->sdef_name,0,OutFile);
WriteSymbolOfIdentToOutFile (sdef->sdef_name,0);
PutSOutFile ("\"");
}
}
......@@ -3893,7 +3905,7 @@ void GenCaseNoMatchError (SymbDefP case_def,int asp,int bsp)
put_directive (Dstring);
PutSUOutFile (" case_fail",CaseFailNumber);
PutSOutFile (" \"");
PrintSymbolOfIdent (case_def->sdef_name,0,OutFile);
WriteSymbolOfIdentToOutFile (case_def->sdef_name,0);
PutSOutFile ("\"");
CaseFailNumber++;
......@@ -4215,7 +4227,7 @@ void GenPB_ident (char *ident_name,unsigned int line_n)
{
put_directive_ (Dpb);
PutCOutFile ('\"');
PrintSymbolOfIdent (ident_name,line_n,OutFile);
WriteSymbolOfIdentToOutFile (ident_name,line_n);
PutCOutFile ('\"');
}
......
......@@ -11,6 +11,8 @@ extern File OutFile;
#define PutCOutFile(s) FPutC ((s),OutFile)
extern void PutIOutFile (long i);
extern void WriteSymbolToOutFile (Symbol symbol);
void BuildBasicFromB (ObjectKind kind,int b_offset);
void FillBasicFromB (ObjectKind kind, int boffs, int aoffs, FillKind fkind);
void BuildBasic (ObjectKind obj,SymbValue val);
......
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