Skip to content

Commit b05f4c1

Browse files
author
Daniel Kroening
committed
use new messaging API in typecheckers
1 parent 3018e8f commit b05f4c1

File tree

4 files changed

+105
-95
lines changed

4 files changed

+105
-95
lines changed

src/jsil/jsil_typecheck.cpp

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void jsil_typecheckt::make_type_compatible(
117117
if(type.id().empty() || type.is_nil())
118118
{
119119
err_location(expr);
120-
str << "make_type_compatible got empty type: " << expr.pretty();
120+
error() << "make_type_compatible got empty type: " << expr.pretty() << eom;
121121
throw 0;
122122
}
123123

@@ -133,10 +133,10 @@ void jsil_typecheckt::make_type_compatible(
133133
if(jsil_incompatible_types(expr.type(), type))
134134
{
135135
err_location(expr);
136-
str << "failed to typecheck expr "
137-
<< expr.pretty() << " with type "
138-
<< expr.type().pretty()
139-
<< "; required type " << type.pretty();
136+
error() << "failed to typecheck expr "
137+
<< expr.pretty() << " with type "
138+
<< expr.type().pretty()
139+
<< "; required type " << type.pretty() << eom;
140140
throw 0;
141141
}
142142
}
@@ -190,8 +190,8 @@ void jsil_typecheckt::typecheck_type(typet &type)
190190

191191
if(symbol_table.add(new_symbol))
192192
{
193-
str << "failed to add parameter symbol `"
194-
<< new_symbol.name << "' in the symbol table";
193+
error() << "failed to add parameter symbol `"
194+
<< new_symbol.name << "' in the symbol table" << eom;
195195
throw 0;
196196
}
197197
}
@@ -254,7 +254,7 @@ void jsil_typecheckt::typecheck_expr_main(exprt &expr)
254254
if(expr.id()==ID_code)
255255
{
256256
err_location(expr);
257-
str << "typecheck_expr_main got code: " << expr.pretty();
257+
error() << "typecheck_expr_main got code: " << expr.pretty() << eom;
258258
throw 0;
259259
}
260260
else if(expr.id()==ID_symbol)
@@ -359,7 +359,7 @@ void jsil_typecheckt::typecheck_expr_main(exprt &expr)
359359
else
360360
{
361361
err_location(expr);
362-
str << "unexpected expression: " << expr.pretty();
362+
error() << "unexpected expression: " << expr.pretty() << eom;
363363
throw 0;
364364
}
365365
}
@@ -425,7 +425,8 @@ void jsil_typecheckt::typecheck_expr_proto_field(exprt &expr)
425425
if(expr.operands().size()!=2)
426426
{
427427
err_location(expr);
428-
str << "operator `" << expr.id() << "' expects two operands";
428+
error() << "operator `" << expr.id()
429+
<< "' expects two operands" << eom;
429430
throw 0;
430431
}
431432

@@ -452,7 +453,8 @@ void jsil_typecheckt::typecheck_expr_proto_obj(exprt &expr)
452453
if(expr.operands().size()!=2)
453454
{
454455
err_location(expr);
455-
str << "operator `" << expr.id() << "' expects two operands";
456+
error() << "operator `" << expr.id()
457+
<< "' expects two operands";
456458
throw 0;
457459
}
458460

@@ -479,7 +481,8 @@ void jsil_typecheckt::typecheck_expr_delete(exprt &expr)
479481
if(expr.operands().size()!=2)
480482
{
481483
err_location(expr);
482-
str << "operator `" << expr.id() << "' expects two operands";
484+
error() << "operator `" << expr.id()
485+
<< "' expects two operands" << eom;
483486
throw 0;
484487
}
485488

@@ -506,7 +509,8 @@ void jsil_typecheckt::typecheck_expr_index(exprt &expr)
506509
if(expr.operands().size()!=2)
507510
{
508511
err_location(expr);
509-
str << "operator `" << expr.id() << "' expects two operands";
512+
error() << "operator `" << expr.id()
513+
<< "' expects two operands" << eom;
510514
throw 0;
511515
}
512516

@@ -537,7 +541,8 @@ void jsil_typecheckt::typecheck_expr_has_field(exprt &expr)
537541
if(expr.operands().size()!=2)
538542
{
539543
err_location(expr);
540-
str << "operator `" << expr.id() << "' expects two operands";
544+
error() << "operator `" << expr.id()
545+
<< "' expects two operands" << eom;
541546
throw 0;
542547
}
543548

@@ -564,7 +569,8 @@ void jsil_typecheckt::typecheck_expr_field(exprt &expr)
564569
if(expr.operands().size()!=1)
565570
{
566571
err_location(expr);
567-
str << "operator `" << expr.id() << "' expects single operand";
572+
error() << "operator `" << expr.id()
573+
<< "' expects single operand" << eom;
568574
throw 0;
569575
}
570576

@@ -590,7 +596,8 @@ void jsil_typecheckt::typecheck_expr_base(exprt &expr)
590596
if(expr.operands().size()!=1)
591597
{
592598
err_location(expr);
593-
str << "operator `" << expr.id() << "' expects single operand";
599+
error() << "operator `" << expr.id()
600+
<< "' expects single operand" << eom;
594601
throw 0;
595602
}
596603

@@ -616,7 +623,8 @@ void jsil_typecheckt::typecheck_expr_ref(exprt &expr)
616623
if(expr.operands().size()!=3)
617624
{
618625
err_location(expr);
619-
str << "operator `" << expr.id() << "' expects three operands";
626+
error() << "operator `" << expr.id()
627+
<< "' expects three operands" << eom;
620628
throw 0;
621629
}
622630

@@ -633,9 +641,9 @@ void jsil_typecheckt::typecheck_expr_ref(exprt &expr)
633641
else
634642
{
635643
err_location(expr);
636-
str << "operator `" << expr.id()
637-
<< "' expects reference type in the third parameter. Got:"
638-
<< operand3.pretty();
644+
error() << "operator `" << expr.id()
645+
<< "' expects reference type in the third parameter. Got:"
646+
<< operand3.pretty() << eom;
639647
throw 0;
640648
}
641649
}
@@ -657,7 +665,8 @@ void jsil_typecheckt::typecheck_expr_concatenation(exprt &expr)
657665
if(expr.operands().size()!=2)
658666
{
659667
err_location(expr);
660-
str << "operator `" << expr.id() << "' expects two operands";
668+
error() << "operator `" << expr.id()
669+
<< "' expects two operands" << eom;
661670
throw 0;
662671
}
663672

@@ -684,7 +693,8 @@ void jsil_typecheckt::typecheck_expr_subtype(exprt &expr)
684693
if(expr.operands().size()!=2)
685694
{
686695
err_location(expr);
687-
str << "operator `" << expr.id() << "' expects two operands";
696+
error() << "operator `" << expr.id()
697+
<< "' expects two operands" << eom;
688698
throw 0;
689699
}
690700

@@ -711,7 +721,8 @@ void jsil_typecheckt::typecheck_expr_binary_boolean(exprt &expr)
711721
if(expr.operands().size()!=2)
712722
{
713723
err_location(expr);
714-
str << "operator `" << expr.id() << "' expects two operands";
724+
error() << "operator `" << expr.id()
725+
<< "' expects two operands" << eom;
715726
throw 0;
716727
}
717728

@@ -738,7 +749,8 @@ void jsil_typecheckt::typecheck_expr_binary_arith(exprt &expr)
738749
if(expr.operands().size()!=2)
739750
{
740751
err_location(expr);
741-
str << "operator `" << expr.id() << "' expects two operands";
752+
error() << "operator `" << expr.id()
753+
<< "' expects two operands" << eom;
742754
throw 0;
743755
}
744756

@@ -766,7 +778,8 @@ void jsil_typecheckt::typecheck_exp_binary_equal(exprt &expr)
766778
if(expr.operands().size()!=2)
767779
{
768780
err_location(expr);
769-
str << "operator `" << expr.id() << "' expects two operands";
781+
error() << "operator `" << expr.id()
782+
<< "' expects two operands" << eom;
770783
throw 0;
771784
}
772785

@@ -792,7 +805,8 @@ void jsil_typecheckt::typecheck_expr_binary_compare(exprt &expr)
792805
if(expr.operands().size()!=2)
793806
{
794807
err_location(expr);
795-
str << "operator `" << expr.id() << "' expects two operands";
808+
error() << "operator `" << expr.id()
809+
<< "' expects two operands" << eom;
796810
throw 0;
797811
}
798812

@@ -819,7 +833,8 @@ void jsil_typecheckt::typecheck_expr_unary_boolean(exprt &expr)
819833
if(expr.operands().size()!=1)
820834
{
821835
err_location(expr);
822-
str << "operator `" << expr.id() << "' expects one operand";
836+
error() << "operator `" << expr.id()
837+
<< "' expects one operand" << eom;
823838
throw 0;
824839
}
825840

@@ -845,7 +860,8 @@ void jsil_typecheckt::typecheck_expr_unary_string(exprt &expr)
845860
if(expr.operands().size()!=1)
846861
{
847862
err_location(expr);
848-
str << "operator `" << expr.id() << "' expects one operand";
863+
error() << "operator `" << expr.id()
864+
<< "' expects one operand" << eom;
849865
throw 0;
850866
}
851867

@@ -871,7 +887,8 @@ void jsil_typecheckt::typecheck_expr_unary_num(exprt &expr)
871887
if(expr.operands().size()!=1)
872888
{
873889
err_location(expr);
874-
str << "operator `" << expr.id() << "' expects one operand";
890+
error() << "operator `" << expr.id()
891+
<< "' expects one operand" << eom;
875892
throw 0;
876893
}
877894

@@ -946,8 +963,9 @@ void jsil_typecheckt::typecheck_symbol_expr(symbol_exprt &symbol_expr)
946963

947964
if(symbol_table.add(new_symbol))
948965
{
949-
str << "failed to add symbol `"
950-
<< new_symbol.name << "' in the symbol table";
966+
error() << "failed to add symbol `"
967+
<< new_symbol.name << "' in the symbol table"
968+
<< eom;
951969
throw 0;
952970
}
953971
}
@@ -1014,7 +1032,7 @@ void jsil_typecheckt::typecheck_code(codet &code)
10141032
else
10151033
{
10161034
err_location(code);
1017-
str << "unexpected statement: " << statement;
1035+
error() << "unexpected statement: " << statement << eom;
10181036
throw 0;
10191037
}
10201038
}
@@ -1363,19 +1381,17 @@ bool jsil_typecheck(
13631381

13641382
catch(int e)
13651383
{
1366-
jsil_typecheck.error_msg();
1384+
jsil_typecheck.error();
13671385
}
13681386

13691387
catch(const char *e)
13701388
{
1371-
jsil_typecheck.str << e;
1372-
jsil_typecheck.error_msg();
1389+
jsil_typecheck.error() << e << messaget::eom;
13731390
}
13741391

13751392
catch(const std::string &e)
13761393
{
1377-
jsil_typecheck.str << e;
1378-
jsil_typecheck.error_msg();
1394+
jsil_typecheck.error() << e << messaget::eom;
13791395
}
13801396

13811397
return jsil_typecheck.get_error_found();

src/jsil/jsil_typecheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ bool jsil_typecheck(
2525
message_handlert &message_handler,
2626
const namespacet &ns);
2727

28-
class jsil_typecheckt:public legacy_typecheckt
28+
class jsil_typecheckt:public typecheckt
2929
{
3030
public:
3131
jsil_typecheckt(
3232
symbol_tablet &_symbol_table,
3333
message_handlert &_message_handler):
34-
legacy_typecheckt(_message_handler),
34+
typecheckt(_message_handler),
3535
symbol_table(_symbol_table),
3636
ns(symbol_table),
3737
proc_name()

0 commit comments

Comments
 (0)