File tree Expand file tree Collapse file tree 5 files changed +50
-0
lines changed Expand file tree Collapse file tree 5 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 23
23
24
24
class ansi_c_declarationt ;
25
25
class c_bit_field_typet ;
26
+ class mathematical_function_typet ;
26
27
class shift_exprt ;
27
28
28
29
class c_typecheck_baset :
@@ -261,6 +262,7 @@ class c_typecheck_baset:
261
262
virtual void typecheck_code_type (code_typet &type);
262
263
virtual void typecheck_typedef_type (typet &type);
263
264
virtual void typecheck_c_bit_field_type (c_bit_field_typet &type);
265
+ virtual void typecheck_map_type (mathematical_function_typet &);
264
266
virtual void typecheck_typeof_type (typet &type);
265
267
virtual void typecheck_array_type (array_typet &type);
266
268
virtual void typecheck_vector_type (typet &type);
Original file line number Diff line number Diff line change @@ -111,6 +111,10 @@ void c_typecheck_baset::typecheck_type(typet &type)
111
111
{
112
112
typecheck_vector_type (type);
113
113
}
114
+ else if (type.id () == ID_mathematical_function)
115
+ {
116
+ typecheck_map_type (to_mathematical_function_type (type));
117
+ }
114
118
else if (type.id ()==ID_custom_unsignedbv ||
115
119
type.id ()==ID_custom_signedbv ||
116
120
type.id ()==ID_custom_floatbv ||
@@ -726,6 +730,14 @@ void c_typecheck_baset::typecheck_vector_type(typet &type)
726
730
type = new_type.with_source_location (source_location);
727
731
}
728
732
733
+ void c_typecheck_baset::typecheck_map_type (mathematical_function_typet &type)
734
+ {
735
+ for (auto &t : type.domain ())
736
+ typecheck_type (t);
737
+
738
+ typecheck_type (type.codomain ());
739
+ }
740
+
729
741
void c_typecheck_baset::typecheck_compound_type (struct_union_typet &type)
730
742
{
731
743
// These get replaced by symbol types later.
Original file line number Diff line number Diff line change @@ -612,6 +612,27 @@ std::string expr2ct::convert_rec(
612
612
613
613
return q+dest+d;
614
614
}
615
+ else if (src.id () == ID_mathematical_function)
616
+ {
617
+ const mathematical_function_typet &function_type =
618
+ to_mathematical_function_type (src);
619
+ std::string dest = CPROVER_PREFIX " map " ;
620
+ bool first = true ;
621
+ for (auto &t : function_type.domain ())
622
+ {
623
+ if (first)
624
+ first = false ;
625
+ else
626
+ dest += " , " ;
627
+
628
+ dest += convert (t);
629
+ }
630
+
631
+ dest += " -> " ;
632
+ dest += convert (function_type.codomain ());
633
+
634
+ return q + dest + d;
635
+ }
615
636
else if (src.id ()==ID_constructor ||
616
637
src.id ()==ID_destructor)
617
638
{
Original file line number Diff line number Diff line change @@ -206,6 +206,7 @@ int yyansi_cerror(const std::string &error);
206
206
%token TOK_CPROVER_BITVECTOR " __CPROVER_bitvector"
207
207
%token TOK_CPROVER_FLOATBV " __CPROVER_floatbv"
208
208
%token TOK_CPROVER_FIXEDBV " __CPROVER_fixedbv"
209
+ %token TOK_CPROVER_MAP " __CPROVER_map"
209
210
%token TOK_CPROVER_ATOMIC " __CPROVER_atomic"
210
211
%token TOK_CPROVER_BOOL " __CPROVER_bool"
211
212
%token TOK_CPROVER_THROW " __CPROVER_throw"
@@ -1111,6 +1112,7 @@ type_specifier:
1111
1112
| typedef_type_specifier
1112
1113
| typeof_type_specifier
1113
1114
| atomic_type_specifier
1115
+ | map_type_specifier
1114
1116
;
1115
1117
1116
1118
declaration_qualifier_list :
@@ -1554,6 +1556,18 @@ array_of_construct:
1554
1556
{ $$ =$1 ; stack_type($$ ).add_subtype().swap(parser_stack($2 )); }
1555
1557
;
1556
1558
1559
+ map_type_specifier :
1560
+ TOK_CPROVER_MAP ' (' type_specifier ' ,' type_specifier ' )'
1561
+ {
1562
+ $$ =$1 ;
1563
+ parser_stack ($$).id(ID_mathematical_function);
1564
+ irept domain;
1565
+ domain.move_to_sub(parser_stack($2 ));
1566
+ parser_stack ($$).move_to_sub(domain);
1567
+ mts ($$, $4 );
1568
+ }
1569
+ ;
1570
+
1557
1571
pragma_packed :
1558
1572
{
1559
1573
init ($$);
Original file line number Diff line number Diff line change @@ -1324,6 +1324,7 @@ __decltype { if(PARSER.cpp98 &&
1324
1324
{CPROVER_PREFIX }" bitvector" { loc (); return TOK_CPROVER_BITVECTOR; }
1325
1325
{CPROVER_PREFIX }" floatbv" { loc (); return TOK_CPROVER_FLOATBV; }
1326
1326
{CPROVER_PREFIX }" fixedbv" { loc (); return TOK_CPROVER_FIXEDBV; }
1327
+ {CPROVER_PREFIX }" map" { loc (); return TOK_CPROVER_MAP; }
1327
1328
{CPROVER_PREFIX }" bool" { loc (); return TOK_CPROVER_BOOL; }
1328
1329
{CPROVER_PREFIX }" throw" { loc (); return TOK_CPROVER_THROW; }
1329
1330
{CPROVER_PREFIX }" catch" { loc (); return TOK_CPROVER_CATCH; }
You can’t perform that action at this time.
0 commit comments