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

Merge remote-tracking branch 'origin/master' into itask

parents 8f5cd120 b4e127f5
......@@ -115,7 +115,7 @@ NewTypeNode (Annotation annot, AttributeKind attr, SymbolP symb, TypeArgs args,
node->type_node_arity = arity;
if (arity > MaxNodeArity)
StaticMessage (True, "<type node>", "\"%S\" %s", symb, "Too many arguments (> 32)");
StaticErrorMessage_s_Ss ("<type node>", symb, " Too many arguments (> 32)");
#if 0
node->type_node_state.state_arity = 1;
node->type_node_state.state_kind = OnA;
......@@ -158,7 +158,7 @@ NewNodeByKind (NodeKind nodeKind, SymbolP symb, Args args, int arity)
node->node_arity = arity;
if (arity > MaxNodeArity)
StaticMessage (True, "<node>", "\"%S\" %s", symb, "Too many arguments (> 32)");
StaticErrorMessage_s_Ss ("<node>", symb, " Too many arguments (> 32)");
return (node);
} /* NewNodeByKind */
......
......@@ -72,7 +72,7 @@ static Parameters CalculateOffsetsOfParameters (Parameters params,States results
if (params)
params = CalculateOffsetsOfParameter (params,resultstates[arity],asp_p,bsp_p);
else {
StaticMessage (True,CurrentAltLabel.lab_symbol->sdef_name,ECodeBlock);
StaticMessage_s_s (True,CurrentAltLabel.lab_symbol->sdef_name,ECodeBlock);
break;
}
}
......@@ -118,7 +118,7 @@ static void GenCodeBlock (CodeBlock code, int asp, int bsp, StateS resultstate)
}
if (nextparam)
StaticMessage (True,CurrentAltLabel.lab_symbol->sdef_name, ECodeBlock);
StaticMessage_s_s (True,CurrentAltLabel.lab_symbol->sdef_name, ECodeBlock);
GenParameters (True, code->co_parin, asp, bsp);
GenInstructions (code->co_instr);
......@@ -963,7 +963,7 @@ static void CodeRule (ImpRuleP rule)
CurrentLine=rule->rule_alts->alt_line;
if (FunctionMayFailWarningOrError!=0)
StaticMessage (FunctionMayFailWarningOrError==2, "%S", "function may fail", CurrentSymbol);
StaticMessage_S_s (FunctionMayFailWarningOrError==2, CurrentSymbol, "function may fail");
MatchError (asize,bsize,rule_sdef,root_node_needed,0);
}
......@@ -1183,7 +1183,7 @@ void CodeGeneration (ImpMod imod, char *fname)
ImpRuleS *rule;
if (!OpenABCFile (fname)){
StaticMessage (True, "<open file>","Can't create abc file '%s'",fname);
StaticErrorMessage_s_ss ("<open file>","Can't create abc file: ",fname);
return;
}
......
......@@ -279,7 +279,7 @@ Coercions CoerceStateKind (StateKind dem_state_kind, StateKind off_state_kind)
if (dem_state_kind == OnA)
return AToA;
else
StaticMessage (False, "","parallel annotation in strict context ignored");
StaticMessage_s_s (False, "","parallel annotation in strict context ignored");
return Reduce;
case UnderEval:
if (dem_state_kind == OnA)
......@@ -333,7 +333,7 @@ Coercions CoerceSimpleStateArgument (StateS demstate,StateKind offkind,int ainde
break;
case CyclicSpine:
GenReduceError ();
StaticMessage (False,CurrentAltLabel.lab_symbol->sdef_name,Co_Wspine);
StaticMessage_s_s (False,CurrentAltLabel.lab_symbol->sdef_name,Co_Wspine);
*ontop = False;
break;
default:
......@@ -949,7 +949,7 @@ static void ReduceSemiStrictNodes (const NodeDefs nds,int asp)
GenJsrEval (asp - nd->def_id->nid_a_index);
break;
case Parallel:
StaticMessage (False, "","parallel annotation ignored(?)");
StaticMessage_s_s (False, "","parallel annotation ignored(?)");
break;
}
}
......@@ -3663,7 +3663,7 @@ static void FillNormalNode (Node node,int *asp_p,int *bsp_p,NodeId update_node_i
}
}
} else {
StaticMessage (False,CurrentAltLabel.lab_symbol->sdef_name,Co_Wtype);
StaticMessage_s_s (False,CurrentAltLabel.lab_symbol->sdef_name,Co_Wtype);
GenTypeError();
}
}
......
......@@ -214,7 +214,7 @@ void RedirectResultAndReturn (int asp,int bsp,int source_a_index,int source_b_in
break;
case CyclicSpine:
GenReduceError ();
StaticMessage (False,CurrentAltLabel.lab_symbol->sdef_name,Co_Wspine);
StaticMessage_s_s (False,CurrentAltLabel.lab_symbol->sdef_name,Co_Wspine);
break;
default:
error_in_function ("RedirectResultAndReturn");
......@@ -1027,7 +1027,7 @@ static void CodeNormalRootNode (Node root,NodeId rootid,int asp,int bsp,CodeGenN
case_def_s.sdef_name = rootsymb->symb_string;
if (FunctionMayFailWarningOrError!=0)
StaticMessage (FunctionMayFailWarningOrError==2, "%D", "case may fail", &case_def_s);
StaticMessage_D_s (FunctionMayFailWarningOrError==2, &case_def_s, "case may fail");
if (! (IsOnBStack (resultstate) ||
(IsSimpleState (resultstate) && resultstate.state_kind==StrictRedirection)))
......@@ -1110,7 +1110,7 @@ static void CodeNormalRootNode (Node root,NodeId rootid,int asp,int bsp,CodeGenN
GenRtn (1, 0, OnAState);
}
} else {
StaticMessage (False,CurrentAltLabel.lab_symbol->sdef_name,Co_Wtype);
StaticMessage_s_s (False,CurrentAltLabel.lab_symbol->sdef_name,Co_Wtype);
GenTypeError();
GenRtn (0, 0, OnAState);
}
......
......@@ -275,163 +275,145 @@ static char *FindFormatSpecifier (char * format_string)
for (; *format_string != '\0' && *format_string != '%'; format_string++)
;
return format_string;
}
#ifdef GNU_C
void StaticMessage (Bool error, char *symbol_format1, char *message_format1, ...)
void StaticMessage_D_s (Bool error,struct symbol_def *symb_def_p,char *message)
{
char *format, format_spec;
char symbol_format [256], message_format [256];
if (! (error || DoWarning))
return;
va_list ap;
strcpy (symbol_format, symbol_format1);
strcpy (message_format, message_format1);
FPutS (error ? "Error [" : "Warning [", StdError);
FPutS (CurrentModule, StdError);
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
PrintSymbolOfIdent (symb_def_p->sdef_name, 0, StdError);
FPutS ("]: ", StdError);
va_start (ap, message_format1);
FPutS (message, StdError);
#else
FPutC ('\n', StdError);
if (error)
CompilerError = True;
}
void StaticMessage (Bool error, char *symbol_format, char *message_format, ...)
void StaticMessage_S_s (Bool error,struct symbol *symbol_p,char *message)
{
char *format, format_spec;
if (! (error || DoWarning))
return;
va_list ap;
va_start (ap, message_format);
FPutS (error ? "Error [" : "Warning [", StdError);
FPutS (CurrentModule, StdError);
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
PrintSymbol (symbol_p, StdError);
FPutS ("]: ", StdError);
#endif
FPutS (message, StdError);
FPutC ('\n', StdError);
if (error)
CompilerError = True;
}
void StaticMessage_S_Ss (Bool error,struct symbol *symbol_p1,struct symbol *symbol_p2,char *message)
{
if (! (error || DoWarning))
return;
#ifdef MAKE_MPW_TOOL
FPutS ("### ",StdError);
#endif
FPutS (error ? "Error [" : "Warning [", StdError);
FPutS (CurrentModule, StdError);
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
PrintSymbol (symbol_p1, StdError);
FPutS ("]: ", StdError);
PrintSymbol (symbol_p2, StdError);
FPutS (message, StdError);
FPutC ('\n', StdError);
if (error)
CompilerError = True;
}
void StaticMessage_s_s (Bool error,char *symbol_s,char *message)
{
if (! (error || DoWarning))
return;
FPutS (error ? "Error [" : "Warning [", StdError);
FPutS (CurrentModule, StdError);
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
FPutS (symbol_s, StdError);
FPutS ("]: ", StdError);
#ifdef MAKE_MPW_TOOL
FPutS ("File ",StdError);
#endif
FPutS (message, StdError);
FPutC ('\n', StdError);
if (error)
CompilerError = True;
}
void StaticErrorMessage_S_ss (struct symbol *symbol_p,char *message1,char *message2)
{
FPutS ("Error [", StdError);
FPutS (CurrentModule, StdError);
if (CurrentLine > 0){
#ifdef MAKE_MPW_TOOL
FPrintF (StdError, "; Line %u", CurrentLine);
#else
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
#endif
}
FPutC (',', StdError);
PrintSymbol (symbol_p, StdError);
FPutS ("]: ", StdError);
#ifdef MAKE_MPW_TOOL
FPutS ("] ", StdError);
#else
FPutS (message1, StdError);
FPutS (message2, StdError);
FPutC ('\n', StdError);
CompilerError = True;
}
void StaticErrorMessage_s_Ss (char *symbol_s,struct symbol *symbol_p,char *message)
{
FPutS ("Error [", StdError);
FPutS (CurrentModule, StdError);
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
#endif
FPutS (symbol_s, StdError);
FPutS ("]: ", StdError);
for (format = symbol_format; ;)
{ char *tail_format = FindFormatSpecifier (format);
if (*tail_format == '\0')
{ FPutS (format, StdError);
break;
}
else
{ *tail_format = '\0';
FPutS (format, StdError);
*tail_format = '%';
format_spec = * (++tail_format);
if (format_spec == '\0')
{ FPutC ('%', StdError);
break;
}
else
{ switch (format_spec)
{
case 's':
{ char * message = va_arg (ap, char *);
if (message != NULL)
FPutS (message, StdError);
break;
}
case 'D':
{
SymbDef def = va_arg (ap, SymbDef);
PrintSymbolOfIdent (def->sdef_name, 0, StdError);
break;
}
case 'S':
PrintSymbol (va_arg (ap, Symbol), StdError);
break;
default:
FPutC ('%', StdError);
FPutC (format_spec, StdError);
break;
}
format = ++tail_format;
}
}
}
PrintSymbol (symbol_p, StdError);
FPutS (message, StdError);
#ifdef MAKE_MPW_TOOL
FPutS (": ", StdError);
#else
FPutC ('\n', StdError);
CompilerError = True;
}
void StaticErrorMessage_s_ss (char *symbol_s,char *message1,char *message2)
{
FPutS ("Error [", StdError);
FPutS (CurrentModule, StdError);
if (CurrentLine > 0)
FPrintF (StdError, ",%u", CurrentLine);
FPutC (',', StdError);
FPutS (symbol_s, StdError);
FPutS ("]: ", StdError);
#endif
for (format = message_format; ;)
{ char *tail_format = FindFormatSpecifier (format);
if (*tail_format == '\0')
{ FPutS (format, StdError);
break;
}
else
{ *tail_format = '\0';
FPutS (format, StdError);
*tail_format = '%';
format_spec = * (++tail_format);
if (format_spec == '\0')
{ FPutC ('%', StdError);
break;
}
else
{ switch (format_spec)
{
case 's':
{ char * message = va_arg (ap, char *);
if (message != NULL)
FPutS (message, StdError);
break;
}
case 'd':
{ int nr = va_arg (ap, int);
FPrintF (StdError, "%d", nr);
break;
}
case 'S':
PrintSymbol (va_arg (ap, Symbol), StdError);
break;
default:
FPutC ('%', StdError);
FPutC (format_spec, StdError);
break;
}
format = ++tail_format;
}
}
}
FPutS (message1, StdError);
FPutS (message2, StdError);
FPutC ('\n', StdError);
va_end (ap);
if (error)
CompilerError = True;
CompilerError = True;
}
static char Init[] = "Compiler initialization";
......
......@@ -13,7 +13,13 @@
#define MINIMUM(a,b) (((a)<(b)) ? (a) : (b))
#define MAXIMUM(a,b) (((a)>(b)) ? (a) : (b))
extern void StaticMessage (Bool error, char *symbol_format, char *message_format, ...);
extern void StaticMessage_D_s (Bool error,struct symbol_def *symb_def_p,char *message);
extern void StaticMessage_S_Ss (Bool error,struct symbol *symbol_p1,struct symbol *symbol_p2,char *message);
extern void StaticMessage_S_s (Bool error,struct symbol *symbol_p,char *message);
extern void StaticMessage_s_s (Bool error,char *symbol_s,char *message);
extern void StaticErrorMessage_S_ss (struct symbol *symbol_p,char *message1,char *message2);
extern void StaticErrorMessage_s_Ss (char *symbol_s,struct symbol *symbol_p,char *message);
extern void StaticErrorMessage_s_ss (char *symbol_s,char *message1,char *message2);
struct symbol;
extern void PrintSymbol (struct symbol *symbol,File file);
......
......@@ -128,7 +128,7 @@ void CloseABCFile (char *fname)
CompilerError = True;
CurrentLine = 0;
StaticMessage (True, "<open file>", "Write error (disk full?)");
StaticMessage_s_s (True, "<open file>", "Write error (disk full?)");
}
if (CompilerError)
FDelete (fname);
......
This diff is collapsed.
......@@ -219,9 +219,9 @@ static void GiveStrictWarning (char *f, char *msg)
#if 1
CurrentLine=0;
if (f)
StaticMessage (False,"%s","%s",f,msg);
StaticMessage_s_s (False,f,msg);
else
StaticMessage (False,"","%s",msg);
StaticMessage_s_s (False,"",msg);
#else
if (f)
FPrintF (StdError, "Warning [%s%s,%s]: %s\n", CurrentModule, CurrentExt, f, msg);
......
......@@ -399,7 +399,7 @@ static void GenRecordState (SymbDef sdef)
} else if (sdef->sdef_checkstatus == ConvertedToState)
return;
else
StaticMessage (True, "%S", "%s cyclic strict field dependencies are not allowed", CurrentSymbol, sdef->sdef_name);
StaticErrorMessage_S_ss (CurrentSymbol, sdef->sdef_name, " cyclic strict field dependencies are not allowed");
}
static void GenResultStatesOfLazyFields (SymbDef sdef)
......@@ -444,8 +444,8 @@ static void ChangeFieldRecordStateForStrictAbsTypeFields (SymbDef icl_sdef,SymbD
(icl_fieldstate_p->state_type!=SimpleState ||
icl_fieldstate_p->state_kind!=dcl_fieldstate_p->state_kind))
{
StaticMessage (False, "%S", "%S strict field is boxed because the field type is an abstract type",
CurrentSymbol, icl_field->fl_symbol);
StaticMessage_S_Ss (False, CurrentSymbol, icl_field->fl_symbol,
" strict field is boxed because the field type is an abstract type");
*icl_fieldstate_p=*dcl_fieldstate_p;
}
......@@ -550,8 +550,8 @@ static void ChangeElementStateForStrictAbsTypeFields (SymbDef icl_sdef,SymbDef d
if (dcl_arg_state_p->state_type==SimpleState &&
(icl_arg_state_p->state_type!=SimpleState || icl_arg_state_p->state_kind!=dcl_arg_state_p->state_kind))
{
StaticMessage (False, "%S", "%S element is boxed because its type is an abstract type",
CurrentSymbol, icl_element_node->type_node_symbol);
StaticMessage_S_Ss (False, CurrentSymbol, icl_element_node->type_node_symbol,
" element is boxed because its type is an abstract type");
*icl_arg_state_p=*dcl_arg_state_p;
}
......@@ -662,12 +662,12 @@ static StateS DetermineStatesOfRuleType (TypeAlts ruletype,StateS *const functio
CurrentLine = 0 /*ruletype->type_alt_line*/;
if (lhsroot->type_node_annotation!=NoAnnot)
StaticMessage (False, "%S", Wrootannot, CurrentSymbol);
StaticMessage_S_s (False, CurrentSymbol, Wrootannot);
arg_state_p=function_state_p;
for_l (type_arg,lhsroot->type_node_arguments,type_arg_next){
if (!(type_arg->type_arg_node->type_node_annotation==NoAnnot || type_arg->type_arg_node->type_node_annotation==StrictAnnot))
StaticMessage (False, "%S", Wtypeannot, CurrentSymbol);
StaticMessage_S_s (False, CurrentSymbol, Wtypeannot);
if (!type_arg->type_arg_node->type_node_is_var)
ConvertTypeToState (type_arg->type_arg_node,arg_state_p,type_arg->type_arg_node->type_node_annotation==NoAnnot ? OnA : StrictOnA);
......@@ -1044,7 +1044,7 @@ static void GenStatesInLhsNode (Node node,StateP arg_state_p)
static void GenStatesInLhsSubArg (Node arg_node,StateP arg_state_p)
{
if (arg_node->node_annotation!=NoAnnot)
StaticMessage (True, "%S", Elhsannots, CurrentSymbol);
StaticMessage_S_s (True, CurrentSymbol, Elhsannots);
switch (arg_state_p->state_type){
case RecordState:
......@@ -2706,7 +2706,7 @@ static Bool NodeInASemiStrictContext (Node node,int local_scope)
static void DetermineStatesOfNonIfRootNode (Node root,NodeId root_id,StateS demstate,int local_scope)
{
if (root->node_state.state_kind != OnA){
StaticMessage (False, "%S", Wrootannot, CurrentSymbol);
StaticMessage_S_s (False, CurrentSymbol, Wrootannot);
root->node_state.state_kind = OnA;
}
......@@ -3405,7 +3405,7 @@ void GenerateStatesForRule (ImpRuleS *rule)
set_states_of_array_selects_in_pattern (alt);
#endif
} else if (rule->rule_type==NULL)
StaticMessage (True, "%S", ECodeBlock, CurrentSymbol);
StaticMessage_S_s (True, CurrentSymbol, ECodeBlock);
if (rule_sdef->sdef_arity==1 &&
function_state_p[-1].state_type==SimpleState && function_state_p[-1].state_kind==OnB && function_state_p[-1].state_object==BoolObj &&
......@@ -3469,7 +3469,7 @@ void DetermineNodeState (Node node)
if (DoParallel)
/* node->node_attribute = AnnotHasDeferAttr (node->node_annotation->annot_kind) */;
else {
StaticMessage (False, "%S", Wparannot, CurrentSymbol);
StaticMessage_S_s (False, CurrentSymbol, Wparannot);
node->node_state.state_kind = OnA;
}
}
......
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