1 // parse tree functions
2 // Copyright (C) 2005-2010 Red Hat Inc.
4 // This file is part of systemtap, and is free software. You can
5 // redistribute it and/or modify it under the terms of the GNU General
6 // Public License (GPL); either version 2, or (at your option) any
28 expression::expression ():
29 type (pe_unknown
), tok (0)
34 expression::~expression ()
39 statement::statement ():
45 statement::statement (const token
* tok
):
51 null_statement::null_statement (const token
* tok
):
57 statement::~statement ()
68 arrayindex::arrayindex ():
74 functioncall::functioncall ():
80 symboldecl::symboldecl ():
87 symboldecl::~symboldecl ()
91 probe_point::probe_point (std::vector
<component
*> const & comps
):
92 components(comps
), optional (false), sufficient (false),
97 // NB: shallow-copy of compoonents & condition!
98 probe_point::probe_point (const probe_point
& pp
):
99 components(pp
.components
), optional (pp
.optional
), sufficient (pp
.sufficient
),
100 condition (pp
.condition
)
105 probe_point::probe_point ():
106 optional (false), sufficient (false), condition (0)
114 static unsigned last_probeidx
= 0;
115 this->name
= string ("probe_") + lex_cast(last_probeidx
++);
119 probe_point::component::component ():
125 probe_point::component::component (std::string
const & f
, literal
* a
):
132 arity (-1), maxsize(0), init(NULL
), skip_init(false)
138 vardecl::set_arity (int a
)
143 if ((arity
!= a
&& arity
>= 0) || (a
== 0 && maxsize
> 0))
144 throw semantic_error ("inconsistent arity", tok
);
149 index_types
.resize (arity
);
150 for (int i
=0; i
<arity
; i
++)
151 index_types
[i
] = pe_unknown
;
156 vardecl::compatible_arity (int a
)
158 if (a
== 0 && maxsize
> 0)
160 if (arity
== -1 || a
== -1)
166 functiondecl::functiondecl ():
167 body (0), synthetic (false)
172 literal_number::literal_number (int64_t v
, bool hex
)
180 literal_string::literal_string (const string
& v
)
188 operator << (ostream
& o
, const exp_type
& e
)
192 case pe_unknown
: o
<< "unknown"; break;
193 case pe_long
: o
<< "long"; break;
194 case pe_string
: o
<< "string"; break;
195 case pe_stats
: o
<< "stats"; break;
196 default: o
<< "???"; break;
203 target_symbol::assert_no_components(const std::string
& tapset
)
205 if (components
.empty())
208 switch (components
[0].type
)
210 case target_symbol::comp_literal_array_index
:
211 case target_symbol::comp_expression_array_index
:
212 throw semantic_error(tapset
+ " variable '" + base_name
+
213 "' may not be used as array",
215 case target_symbol::comp_struct_member
:
216 throw semantic_error(tapset
+ " variable '" + base_name
+
217 "' may not be used as a structure",
220 throw semantic_error ("invalid use of " + tapset
+
221 " variable '" + base_name
+ "'",
227 void target_symbol::chain (const semantic_error
&er
)
229 semantic_error
* e
= new semantic_error(er
);
232 assert (e
->chain
== 0);
233 e
->chain
= this->saved_conversion_error
;
234 this->saved_conversion_error
= e
;
238 // ------------------------------------------------------------------------
239 // parse tree printing
241 ostream
& operator << (ostream
& o
, const expression
& k
)
248 void literal_string::print (ostream
& o
) const
251 for (unsigned i
=0; i
<value
.size(); i
++)
252 if (value
[i
] == '"') // or other escapeworthy characters?
260 void literal_number::print (ostream
& o
) const
263 o
<< hex
<< showbase
;
266 o
<< dec
<< noshowbase
;
270 void embedded_expr::print (ostream
& o
) const
272 o
<< "%{ " << code
<< " %}";
276 void binary_expression::print (ostream
& o
) const
278 o
<< "(" << *left
<< ") "
280 << " (" << *right
<< ")";
284 void unary_expression::print (ostream
& o
) const
286 o
<< op
<< '(' << *operand
<< ")";
289 void array_in::print (ostream
& o
) const
292 for (unsigned i
=0; i
<operand
->indexes
.size(); i
++)
294 if (i
> 0) o
<< ", ";
295 operand
->indexes
[i
]->print (o
);
298 operand
->base
->print_indexable (o
);
301 void post_crement::print (ostream
& o
) const
303 o
<< '(' << *operand
<< ")" << op
;
307 void ternary_expression::print (ostream
& o
) const
309 o
<< "(" << *cond
<< ")?("
310 << *truevalue
<< "):("
311 << *falsevalue
<< ")";
315 void symbol::print (ostream
& o
) const
321 void target_symbol::component::print (ostream
& o
) const
325 case comp_struct_member
:
328 case comp_literal_array_index
:
329 o
<< '[' << num_index
<< ']';
331 case comp_expression_array_index
:
332 o
<< '[' << *expr_index
<< ']';
338 std::ostream
& operator << (std::ostream
& o
, const target_symbol::component
& c
)
345 void target_symbol::print (ostream
& o
) const
350 for (unsigned i
= 0; i
< components
.size(); ++i
)
355 void cast_op::print (ostream
& o
) const
359 o
<< base_name
<< '(' << *operand
;
360 o
<< ", " << lex_cast_qstring (type
);
361 if (module
.length() > 0)
362 o
<< ", " << lex_cast_qstring (module
);
364 for (unsigned i
= 0; i
< components
.size(); ++i
)
369 void defined_op::print (ostream
& o
) const
371 o
<< "@defined(" << *operand
<< ")";
375 void vardecl::print (ostream
& o
) const
379 o
<< "[" << maxsize
<< "]";
380 if (arity
> 0 || index_types
.size() > 0)
390 void vardecl::printsig (ostream
& o
) const
394 o
<< "[" << maxsize
<< "]";
396 if (index_types
.size() > 0)
399 for (unsigned i
=0; i
<index_types
.size(); i
++)
400 o
<< (i
>0 ? ", " : "") << index_types
[i
];
406 void functiondecl::print (ostream
& o
) const
408 o
<< "function " << name
<< " (";
409 for (unsigned i
=0; i
<formal_args
.size(); i
++)
410 o
<< (i
>0 ? ", " : "") << *formal_args
[i
];
416 void functiondecl::printsig (ostream
& o
) const
418 o
<< name
<< ":" << type
<< " (";
419 for (unsigned i
=0; i
<formal_args
.size(); i
++)
420 o
<< (i
>0 ? ", " : "")
423 << formal_args
[i
]->type
;
428 void arrayindex::print (ostream
& o
) const
430 base
->print_indexable (o
);
432 for (unsigned i
=0; i
<indexes
.size(); i
++)
433 o
<< (i
>0 ? ", " : "") << *indexes
[i
];
438 void functioncall::print (ostream
& o
) const
440 o
<< function
<< "(";
441 for (unsigned i
=0; i
<args
.size(); i
++)
442 o
<< (i
>0 ? ", " : "") << *args
[i
];
448 print_format::create(const token
*t
)
450 bool stream
, format
, delim
, newline
, _char
;
451 const char *n
= t
->content
.c_str();
454 format
= delim
= newline
= _char
= false;
456 if (strcmp(n
, "print_char") == 0)
466 if (0 != strncmp(n
, "print", 5))
483 if (*n
== 'l' && *(n
+1) == 'n')
494 print_format
*pf
= new print_format(stream
, format
, delim
, newline
, _char
);
501 print_format::components_to_string(vector
<format_component
> const & components
)
505 for (vector
<format_component
>::const_iterator i
= components
.begin();
506 i
!= components
.end(); ++i
)
509 assert (i
->type
!= conv_unspecified
);
511 if (i
->type
== conv_literal
)
513 assert(!i
->literal_string
.empty());
514 for (string::const_iterator j
= i
->literal_string
.begin();
515 j
!= i
->literal_string
.end(); ++j
)
517 // See also: c_unparser::visit_literal_string and lex_cast_qstring
529 if (i
->flags
& static_cast<unsigned long>(fmt_flag_zeropad
))
532 if (i
->flags
& static_cast<unsigned long>(fmt_flag_plus
))
535 if (i
->flags
& static_cast<unsigned long>(fmt_flag_space
))
538 if (i
->flags
& static_cast<unsigned long>(fmt_flag_left
))
541 if (i
->flags
& static_cast<unsigned long>(fmt_flag_special
))
544 if (i
->widthtype
== width_dynamic
)
546 else if (i
->widthtype
!= width_unspecified
&& i
->width
> 0)
549 if (i
->prectype
== prec_dynamic
)
551 else if (i
->prectype
!= prec_unspecified
&& i
->precision
> 0)
552 oss
<< '.' << i
->precision
;
564 case conv_signed_decimal
:
568 case conv_unsigned_decimal
:
572 case conv_unsigned_octal
:
576 case conv_unsigned_ptr
:
580 case conv_unsigned_uppercase_hex
:
584 case conv_unsigned_lowercase_hex
:
596 case conv_memory_hex
:
608 vector
<print_format::format_component
>
609 print_format::string_to_components(string
const & str
)
611 format_component curr
;
612 vector
<format_component
> res
;
616 string::const_iterator i
= str
.begin();
618 while (i
!= str
.end())
622 assert (curr
.type
== conv_unspecified
|| curr
.type
== conv_literal
);
623 curr
.type
= conv_literal
;
624 curr
.literal_string
+= *i
;
628 else if (i
+1 == str
.end() || *(i
+1) == '%')
631 // *i == '%' and *(i+1) == '%'; append only one '%' to the literal string
632 assert (curr
.type
== conv_unspecified
|| curr
.type
== conv_literal
);
633 curr
.type
= conv_literal
;
634 curr
.literal_string
+= '%';
641 if (curr
.type
!= conv_unspecified
)
643 // Flush any component we were previously accumulating
644 assert (curr
.type
== conv_literal
);
654 // Now we are definitely parsing a conversion.
655 // Begin by parsing flags (which are optional).
660 curr
.flags
|= static_cast<unsigned long>(fmt_flag_zeropad
);
665 curr
.flags
|= static_cast<unsigned long>(fmt_flag_plus
);
670 curr
.flags
|= static_cast<unsigned long>(fmt_flag_left
);
675 curr
.flags
|= static_cast<unsigned long>(fmt_flag_space
);
680 curr
.flags
|= static_cast<unsigned long>(fmt_flag_special
);
691 // Parse optional width
694 curr
.widthtype
= width_dynamic
;
697 else if (isdigit(*i
))
699 curr
.widthtype
= width_static
;
704 curr
.width
+= (*i
- '0');
707 while (i
!= str
.end() && isdigit(*i
));
713 // Parse optional precision
721 curr
.prectype
= prec_dynamic
;
724 else if (isdigit(*i
))
726 curr
.prectype
= prec_static
;
730 curr
.precision
*= 10;
731 curr
.precision
+= (*i
- '0');
734 while (i
!= str
.end() && isdigit(*i
));
741 // Parse the actual conversion specifier (bcsmdioupxXn)
744 // Valid conversion types
746 curr
.type
= conv_binary
;
750 curr
.type
= conv_char
;
754 curr
.type
= conv_string
;
758 curr
.type
= conv_memory
;
762 curr
.type
= conv_memory_hex
;
767 curr
.type
= conv_signed_decimal
;
771 curr
.type
= conv_unsigned_octal
;
775 curr
.type
= conv_unsigned_decimal
;
779 curr
.type
= conv_unsigned_ptr
;
783 curr
.type
= conv_unsigned_uppercase_hex
;
787 curr
.type
= conv_unsigned_lowercase_hex
;
794 if (curr
.type
== conv_unspecified
)
795 throw parse_error("invalid or missing conversion specifier");
802 // If there's a remaining partly-composed conversion, fail.
803 if (!curr
.is_empty())
805 if (curr
.type
== conv_literal
)
808 throw parse_error("trailing incomplete print format conversion");
815 void print_format::print (ostream
& o
) const
817 o
<< tok
->content
<< "(";
818 if (print_with_format
)
819 o
<< lex_cast_qstring (raw_components
);
820 if (print_with_delim
)
821 o
<< lex_cast_qstring (delimiter
.literal_string
);
824 for (vector
<expression
*>::const_iterator i
= args
.begin();
825 i
!= args
.end(); ++i
)
827 if (i
!= args
.begin() || print_with_format
|| print_with_delim
)
834 void stat_op::print (ostream
& o
) const
864 hist_op::print (ostream
& o
) const
870 assert(params
.size() == 3);
873 for (size_t i
= 0; i
< params
.size(); ++i
)
875 o
<< ", " << params
[i
];
881 assert(params
.size() == 0);
889 ostream
& operator << (ostream
& o
, const statement
& k
)
896 void embeddedcode::print (ostream
&o
) const
903 void block::print (ostream
& o
) const
906 for (unsigned i
=0; i
<statements
.size(); i
++)
907 o
<< *statements
[i
] << endl
;
911 block::block (statement
* car
, statement
* cdr
)
913 statements
.push_back(car
);
914 statements
.push_back(cdr
);
915 this->tok
= car
->tok
;
920 void try_block::print (ostream
& o
) const
922 o
<< "try {" << endl
;
923 if (try_block
) o
<< *try_block
<< endl
;
925 if (catch_error_var
) o
<< "(" << *catch_error_var
<< ") ";
927 if (catch_block
) o
<< *catch_block
<< endl
;
932 void for_loop::print (ostream
& o
) const
935 if (init
) init
->print (o
);
939 if (incr
) incr
->print (o
);
945 void foreach_loop::print (ostream
& o
) const
954 for (unsigned i
=0; i
<indexes
.size(); i
++)
956 if (i
> 0) o
<< ", ";
957 indexes
[i
]->print (o
);
958 if (sort_direction
!= 0 && sort_column
== i
+1)
959 o
<< (sort_direction
> 0 ? "+" : "-");
962 base
->print_indexable (o
);
963 if (sort_direction
!= 0 && sort_column
== 0)
964 o
<< (sort_direction
> 0 ? "+" : "-");
975 void null_statement::print (ostream
& o
) const
981 void expr_statement::print (ostream
& o
) const
987 void return_statement::print (ostream
& o
) const
989 o
<< "return " << *value
;
993 void delete_statement::print (ostream
& o
) const
995 o
<< "delete " << *value
;
998 void next_statement::print (ostream
& o
) const
1003 void break_statement::print (ostream
& o
) const
1008 void continue_statement::print (ostream
& o
) const
1013 void if_statement::print (ostream
& o
) const
1015 o
<< "if (" << *condition
<< ") "
1016 << *thenblock
<< endl
;
1018 o
<< "else " << *elseblock
<< endl
;
1022 void stapfile::print (ostream
& o
) const
1024 o
<< "# file " << name
<< endl
;
1026 for (unsigned i
=0; i
<embeds
.size(); i
++)
1027 embeds
[i
]->print (o
);
1029 for (unsigned i
=0; i
<globals
.size(); i
++)
1032 globals
[i
]->print (o
);
1036 for (unsigned i
=0; i
<aliases
.size(); i
++)
1038 aliases
[i
]->print (o
);
1042 for (unsigned i
=0; i
<probes
.size(); i
++)
1044 probes
[i
]->print (o
);
1048 for (unsigned j
= 0; j
< functions
.size(); j
++)
1050 functions
[j
]->print (o
);
1056 void probe::print (ostream
& o
) const
1064 void probe::printsig (ostream
& o
) const
1066 const probe_alias
*alias
= get_alias ();
1069 alias
->printsig (o
);
1073 for (unsigned i
=0; i
<locations
.size(); i
++)
1075 if (i
> 0) o
<< ",";
1076 locations
[i
]->print (o
);
1082 probe::collect_derivation_chain (std::vector
<probe
*> &probes_list
)
1084 probes_list
.push_back(this);
1088 void probe_point::print (ostream
& o
) const
1090 for (unsigned i
=0; i
<components
.size(); i
++)
1093 probe_point::component
* c
= components
[i
];
1096 o
<< "(" << *c
->arg
<< ")";
1100 else if (optional
) // sufficient implies optional
1103 o
<< " if (" << *condition
<< ")";
1106 string
probe_point::str ()
1114 probe_alias::probe_alias(std::vector
<probe_point
*> const & aliases
):
1115 probe (), alias_names (aliases
)
1119 void probe_alias::printsig (ostream
& o
) const
1121 for (unsigned i
=0; i
<alias_names
.size(); i
++)
1123 o
<< (i
>0 ? " = " : "");
1124 alias_names
[i
]->print (o
);
1127 for (unsigned i
=0; i
<locations
.size(); i
++)
1129 if (i
> 0) o
<< ", ";
1130 locations
[i
]->print (o
);
1135 ostream
& operator << (ostream
& o
, const probe_point
& k
)
1142 ostream
& operator << (ostream
& o
, const symboldecl
& k
)
1150 // ------------------------------------------------------------------------
1155 block::visit (visitor
* u
)
1157 u
->visit_block (this);
1162 try_block::visit (visitor
* u
)
1164 u
->visit_try_block (this);
1169 embeddedcode::visit (visitor
* u
)
1171 u
->visit_embeddedcode (this);
1176 for_loop::visit (visitor
* u
)
1178 u
->visit_for_loop (this);
1182 foreach_loop::visit (visitor
* u
)
1184 u
->visit_foreach_loop (this);
1188 null_statement::visit (visitor
* u
)
1190 u
->visit_null_statement (this);
1194 expr_statement::visit (visitor
* u
)
1196 u
->visit_expr_statement (this);
1200 return_statement::visit (visitor
* u
)
1202 u
->visit_return_statement (this);
1206 delete_statement::visit (visitor
* u
)
1208 u
->push_active_lvalue (this->value
);
1209 u
->visit_delete_statement (this);
1210 u
->pop_active_lvalue ();
1214 if_statement::visit (visitor
* u
)
1216 u
->visit_if_statement (this);
1220 next_statement::visit (visitor
* u
)
1222 u
->visit_next_statement (this);
1226 break_statement::visit (visitor
* u
)
1228 u
->visit_break_statement (this);
1232 continue_statement::visit (visitor
* u
)
1234 u
->visit_continue_statement (this);
1238 literal_string::visit(visitor
* u
)
1240 u
->visit_literal_string (this);
1244 literal_number::visit(visitor
* u
)
1246 u
->visit_literal_number (this);
1250 binary_expression::visit (visitor
* u
)
1252 u
->visit_binary_expression (this);
1256 embedded_expr::visit (visitor
* u
)
1258 u
->visit_embedded_expr (this);
1262 unary_expression::visit (visitor
* u
)
1264 u
->visit_unary_expression (this);
1268 pre_crement::visit (visitor
* u
)
1270 u
->push_active_lvalue (this->operand
);
1271 u
->visit_pre_crement (this);
1272 u
->pop_active_lvalue ();
1276 post_crement::visit (visitor
* u
)
1278 u
->push_active_lvalue (this->operand
);
1279 u
->visit_post_crement (this);
1280 u
->pop_active_lvalue ();
1284 logical_or_expr::visit (visitor
* u
)
1286 u
->visit_logical_or_expr (this);
1290 logical_and_expr::visit (visitor
* u
)
1292 u
->visit_logical_and_expr (this);
1296 array_in::visit (visitor
* u
)
1298 u
->visit_array_in (this);
1302 comparison::visit (visitor
* u
)
1304 u
->visit_comparison (this);
1308 concatenation::visit (visitor
* u
)
1310 u
->visit_concatenation (this);
1314 ternary_expression::visit (visitor
* u
)
1316 u
->visit_ternary_expression (this);
1320 assignment::visit (visitor
* u
)
1322 u
->push_active_lvalue (this->left
);
1323 u
->visit_assignment (this);
1324 u
->pop_active_lvalue ();
1328 symbol::visit (visitor
* u
)
1330 u
->visit_symbol (this);
1334 target_symbol::visit (visitor
* u
)
1336 u
->visit_target_symbol(this);
1340 target_symbol::visit_components (visitor
* u
)
1342 for (unsigned i
= 0; i
< components
.size(); ++i
)
1343 if (components
[i
].type
== comp_expression_array_index
)
1344 components
[i
].expr_index
->visit (u
);
1348 target_symbol::visit_components (update_visitor
* u
)
1350 for (unsigned i
= 0; i
< components
.size(); ++i
)
1351 if (components
[i
].type
== comp_expression_array_index
)
1352 u
->replace (components
[i
].expr_index
);
1356 cast_op::visit (visitor
* u
)
1358 u
->visit_cast_op(this);
1363 defined_op::visit (visitor
* u
)
1365 u
->visit_defined_op(this);
1370 arrayindex::visit (visitor
* u
)
1372 u
->visit_arrayindex (this);
1376 functioncall::visit (visitor
* u
)
1378 u
->visit_functioncall (this);
1382 print_format::visit (visitor
*u
)
1384 u
->visit_print_format (this);
1388 stat_op::visit (visitor
*u
)
1390 u
->visit_stat_op (this);
1394 hist_op::visit (visitor
*u
)
1396 u
->visit_hist_op (this);
1400 indexable::print_indexable (std::ostream
& o
) const
1403 const hist_op
*hist
;
1404 classify_const_indexable(this, sym
, hist
);
1415 indexable::visit_indexable (visitor
* u
)
1419 classify_indexable(this, sym
, hist
);
1431 indexable::is_symbol(symbol
*& sym_out
)
1438 indexable::is_hist_op(hist_op
*& hist_out
)
1445 indexable::is_const_symbol(const symbol
*& sym_out
) const
1452 indexable::is_const_hist_op(const hist_op
*& hist_out
) const
1459 symbol::is_symbol(symbol
*& sym_out
)
1466 symbol::is_const_symbol(const symbol
*& sym_out
) const
1473 symbol::get_tok() const
1479 hist_op::is_hist_op(hist_op
*& hist_out
)
1486 hist_op::is_const_hist_op(const hist_op
*& hist_out
) const
1493 hist_op::get_tok() const
1499 classify_indexable(indexable
* ix
,
1500 symbol
*& array_out
,
1501 hist_op
*& hist_out
)
1505 if (!(ix
->is_symbol (array_out
) || ix
->is_hist_op (hist_out
)))
1506 throw semantic_error("Expecting symbol or histogram operator", ix
->get_tok());
1507 if (ix
&& !(hist_out
|| array_out
))
1508 throw semantic_error("Failed to classify indexable", ix
->get_tok());
1512 classify_const_indexable(const indexable
* ix
,
1513 const symbol
*& array_out
,
1514 const hist_op
*& hist_out
)
1518 if (!(ix
->is_const_symbol(array_out
) || ix
->is_const_hist_op(hist_out
)))
1519 throw semantic_error("Expecting symbol or histogram operator", ix
->get_tok());
1522 // ------------------------------------------------------------------------
1525 visitor::is_active_lvalue(expression
*e
)
1527 for (unsigned i
= 0; i
< active_lvalues
.size(); ++i
)
1529 if (active_lvalues
[i
] == e
)
1536 visitor::push_active_lvalue(expression
*e
)
1538 active_lvalues
.push_back(e
);
1542 visitor::pop_active_lvalue()
1544 assert(!active_lvalues
.empty());
1545 active_lvalues
.pop_back();
1550 // ------------------------------------------------------------------------
1553 traversing_visitor::visit_block (block
* s
)
1555 for (unsigned i
=0; i
<s
->statements
.size(); i
++)
1556 s
->statements
[i
]->visit (this);
1560 traversing_visitor::visit_try_block (try_block
* s
)
1563 s
->try_block
->visit (this);
1564 if (s
->catch_error_var
)
1565 s
->catch_error_var
->visit (this);
1567 s
->catch_block
->visit (this);
1571 traversing_visitor::visit_embeddedcode (embeddedcode
*)
1576 traversing_visitor::visit_null_statement (null_statement
*)
1581 traversing_visitor::visit_expr_statement (expr_statement
* s
)
1583 s
->value
->visit (this);
1587 traversing_visitor::visit_if_statement (if_statement
* s
)
1589 s
->condition
->visit (this);
1590 s
->thenblock
->visit (this);
1592 s
->elseblock
->visit (this);
1596 traversing_visitor::visit_for_loop (for_loop
* s
)
1598 if (s
->init
) s
->init
->visit (this);
1599 s
->cond
->visit (this);
1600 if (s
->incr
) s
->incr
->visit (this);
1601 s
->block
->visit (this);
1605 traversing_visitor::visit_foreach_loop (foreach_loop
* s
)
1607 symbol
*array
= NULL
;
1608 hist_op
*hist
= NULL
;
1609 classify_indexable (s
->base
, array
, hist
);
1615 for (unsigned i
=0; i
<s
->indexes
.size(); i
++)
1616 s
->indexes
[i
]->visit (this);
1619 s
->value
->visit (this);
1622 s
->limit
->visit (this);
1624 s
->block
->visit (this);
1628 traversing_visitor::visit_return_statement (return_statement
* s
)
1630 s
->value
->visit (this);
1634 traversing_visitor::visit_delete_statement (delete_statement
* s
)
1636 s
->value
->visit (this);
1640 traversing_visitor::visit_next_statement (next_statement
*)
1645 traversing_visitor::visit_break_statement (break_statement
*)
1650 traversing_visitor::visit_continue_statement (continue_statement
*)
1655 traversing_visitor::visit_literal_string (literal_string
*)
1660 traversing_visitor::visit_literal_number (literal_number
*)
1665 traversing_visitor::visit_embedded_expr (embedded_expr
*)
1670 traversing_visitor::visit_binary_expression (binary_expression
* e
)
1672 e
->left
->visit (this);
1673 e
->right
->visit (this);
1677 traversing_visitor::visit_unary_expression (unary_expression
* e
)
1679 e
->operand
->visit (this);
1683 traversing_visitor::visit_pre_crement (pre_crement
* e
)
1685 e
->operand
->visit (this);
1689 traversing_visitor::visit_post_crement (post_crement
* e
)
1691 e
->operand
->visit (this);
1696 traversing_visitor::visit_logical_or_expr (logical_or_expr
* e
)
1698 e
->left
->visit (this);
1699 e
->right
->visit (this);
1703 traversing_visitor::visit_logical_and_expr (logical_and_expr
* e
)
1705 e
->left
->visit (this);
1706 e
->right
->visit (this);
1710 traversing_visitor::visit_array_in (array_in
* e
)
1712 e
->operand
->visit (this);
1716 traversing_visitor::visit_comparison (comparison
* e
)
1718 e
->left
->visit (this);
1719 e
->right
->visit (this);
1723 traversing_visitor::visit_concatenation (concatenation
* e
)
1725 e
->left
->visit (this);
1726 e
->right
->visit (this);
1730 traversing_visitor::visit_ternary_expression (ternary_expression
* e
)
1732 e
->cond
->visit (this);
1733 e
->truevalue
->visit (this);
1734 e
->falsevalue
->visit (this);
1738 traversing_visitor::visit_assignment (assignment
* e
)
1740 e
->left
->visit (this);
1741 e
->right
->visit (this);
1745 traversing_visitor::visit_symbol (symbol
*)
1750 traversing_visitor::visit_target_symbol (target_symbol
* e
)
1752 e
->visit_components (this);
1756 traversing_visitor::visit_cast_op (cast_op
* e
)
1758 e
->operand
->visit (this);
1759 e
->visit_components (this);
1763 traversing_visitor::visit_defined_op (defined_op
* e
)
1765 e
->operand
->visit (this);
1770 traversing_visitor::visit_arrayindex (arrayindex
* e
)
1772 for (unsigned i
=0; i
<e
->indexes
.size(); i
++)
1773 e
->indexes
[i
]->visit (this);
1775 symbol
*array
= NULL
;
1776 hist_op
*hist
= NULL
;
1777 classify_indexable(e
->base
, array
, hist
);
1779 return array
->visit(this);
1781 return hist
->visit(this);
1785 traversing_visitor::visit_functioncall (functioncall
* e
)
1787 for (unsigned i
=0; i
<e
->args
.size(); i
++)
1788 e
->args
[i
]->visit (this);
1792 traversing_visitor::visit_print_format (print_format
* e
)
1794 for (unsigned i
=0; i
<e
->args
.size(); i
++)
1795 e
->args
[i
]->visit (this);
1797 e
->hist
->visit(this);
1801 traversing_visitor::visit_stat_op (stat_op
* e
)
1803 e
->stat
->visit (this);
1807 traversing_visitor::visit_hist_op (hist_op
* e
)
1809 e
->stat
->visit (this);
1814 functioncall_traversing_visitor::visit_functioncall (functioncall
* e
)
1816 traversing_visitor::visit_functioncall (e
);
1818 // prevent infinite recursion
1819 if (traversed
.find (e
->referent
) == traversed
.end ())
1821 traversed
.insert (e
->referent
);
1823 functiondecl
* last_current_function
= current_function
;
1824 current_function
= e
->referent
;
1825 e
->referent
->body
->visit (this);
1826 current_function
= last_current_function
;
1832 varuse_collecting_visitor::visit_try_block (try_block
*s
)
1835 s
->try_block
->visit (this);
1836 if (s
->catch_error_var
)
1837 written
.insert (s
->catch_error_var
->referent
);
1839 s
->catch_block
->visit (this);
1841 // NB: don't functioncall_traversing_visitor::visit_try_block (s);
1842 // since that would count s->catch_error_var as a read also.
1847 varuse_collecting_visitor::visit_embeddedcode (embeddedcode
*s
)
1849 assert (current_function
); // only they get embedded code
1851 // Don't allow embedded C functions in unprivileged mode unless
1852 // they are tagged with /* unprivileged */
1853 if (session
.unprivileged
&& s
->code
.find ("/* unprivileged */") == string::npos
)
1854 throw semantic_error ("function may not be used when --unprivileged is specified",
1855 current_function
->tok
);
1857 // Don't allow /* guru */ functions unless -g is active.
1858 if (!session
.guru_mode
&& s
->code
.find ("/* guru */") != string::npos
)
1859 throw semantic_error ("function may not be used unless -g is specified",
1860 current_function
->tok
);
1862 // We want to elide embedded-C functions when possible. For
1863 // example, each $target variable access is expanded to an
1864 // embedded-C function call. Yet, for safety reasons, we should
1865 // presume that embedded-C functions have intentional side-effects.
1867 // To tell these two types of functions apart, we apply a
1868 // Kludge(tm): we look for a magic string within the function body.
1869 // $target variables as rvalues will have this; lvalues won't.
1870 // Also, explicit side-effect-free tapset functions will have this.
1872 if (s
->code
.find ("/* pure */") != string::npos
)
1875 embedded_seen
= true;
1879 // About the same case as above.
1881 varuse_collecting_visitor::visit_embedded_expr (embedded_expr
*e
)
1883 // Don't allow embedded C functions in unprivileged mode unless
1884 // they are tagged with /* unprivileged */
1885 if (session
.unprivileged
&& e
->code
.find ("/* unprivileged */") == string::npos
)
1886 throw semantic_error ("embedded expression may not be used when --unprivileged is specified",
1889 // Don't allow /* guru */ functions unless -g is active.
1890 if (!session
.guru_mode
&& e
->code
.find ("/* guru */") != string::npos
)
1891 throw semantic_error ("embedded expression may not be used unless -g is specified",
1894 // We want to elide embedded-C functions when possible. For
1895 // example, each $target variable access is expanded to an
1896 // embedded-C function call. Yet, for safety reasons, we should
1897 // presume that embedded-C functions have intentional side-effects.
1899 // To tell these two types of functions apart, we apply a
1900 // Kludge(tm): we look for a magic string within the function body.
1901 // $target variables as rvalues will have this; lvalues won't.
1902 // Also, explicit side-effect-free tapset functions will have this.
1904 if (e
->code
.find ("/* pure */") != string::npos
)
1907 embedded_seen
= true;
1912 varuse_collecting_visitor::visit_target_symbol (target_symbol
*e
)
1914 // Still-unresolved target symbol assignments get treated as
1915 // generating side-effects like embedded-C, to prevent premature
1916 // elision and later error message suppression (PR5516). rvalue use
1917 // of unresolved target symbols is OTOH not considered a side-effect.
1919 if (is_active_lvalue (e
))
1920 embedded_seen
= true;
1922 functioncall_traversing_visitor::visit_target_symbol (e
);
1926 varuse_collecting_visitor::visit_cast_op (cast_op
*e
)
1928 // As with target_symbols, unresolved cast assignments need to preserved
1929 // for later error handling.
1930 if (is_active_lvalue (e
))
1931 embedded_seen
= true;
1933 functioncall_traversing_visitor::visit_cast_op (e
);
1937 varuse_collecting_visitor::visit_defined_op (defined_op
*e
)
1940 functioncall_traversing_visitor::visit_defined_op (e
);
1945 varuse_collecting_visitor::visit_print_format (print_format
* e
)
1947 // NB: Instead of being top-level statements, "print" and "printf"
1948 // are implemented as statement-expressions containing a
1949 // print_format. They have side-effects, but not via the
1950 // embedded-code detection method above.
1952 // But sprint and sprintf don't have side-effects.
1954 if (e
->print_to_stream
)
1955 embedded_seen
= true; // a proxy for "has unknown side-effects"
1957 functioncall_traversing_visitor::visit_print_format (e
);
1962 varuse_collecting_visitor::visit_assignment (assignment
*e
)
1964 if (e
->op
== "=" || e
->op
== "<<<") // pure writes
1966 expression
* last_lvalue
= current_lvalue
;
1967 current_lvalue
= e
->left
; // leave a mark for ::visit_symbol
1968 functioncall_traversing_visitor::visit_assignment (e
);
1969 current_lvalue
= last_lvalue
;
1971 else // read-modify-writes
1973 expression
* last_lrvalue
= current_lrvalue
;
1974 current_lrvalue
= e
->left
; // leave a mark for ::visit_symbol
1975 functioncall_traversing_visitor::visit_assignment (e
);
1976 current_lrvalue
= last_lrvalue
;
1981 varuse_collecting_visitor::visit_symbol (symbol
*e
)
1983 if (e
->referent
== 0)
1984 throw semantic_error ("symbol without referent", e
->tok
);
1986 // We could handle initialized globals by marking them as "written".
1987 // However, this current visitor may be called for a function or
1988 // probe body, from the point of view of which this global is
1989 // already initialized, so not written.
1991 if (e->referent->init)
1992 written.insert (e->referent);
1995 if (current_lvalue
== e
|| current_lrvalue
== e
)
1997 written
.insert (e
->referent
);
1998 // clog << "write ";
2000 if (current_lvalue
!= e
|| current_lrvalue
== e
)
2002 read
.insert (e
->referent
);
2005 // clog << *e->tok << endl;
2008 // NB: stat_op need not be overridden, since it will get to
2009 // visit_symbol and only as a possible rvalue.
2013 varuse_collecting_visitor::visit_arrayindex (arrayindex
*e
)
2015 // Hooking this callback is necessary because of the hacky
2016 // statistics representation. For the expression "i[4] = 5", the
2017 // incoming lvalue will point to this arrayindex. However, the
2018 // symbol corresponding to the "i[4]" is multiply inherited with
2019 // arrayindex. If the symbol base part of this object is not at
2020 // offset 0, then static_cast<symbol*>(e) may result in a different
2021 // address, and not match lvalue by number when we recurse that way.
2022 // So we explicitly override the incoming lvalue/lrvalue values to
2023 // point at the embedded objects' actual base addresses.
2025 expression
* last_lrvalue
= current_lrvalue
;
2026 expression
* last_lvalue
= current_lvalue
;
2028 symbol
*array
= NULL
;
2029 hist_op
*hist
= NULL
;
2030 classify_indexable(e
->base
, array
, hist
);
2034 if (current_lrvalue
== e
) current_lrvalue
= array
;
2035 if (current_lvalue
== e
) current_lvalue
= array
;
2036 functioncall_traversing_visitor::visit_arrayindex (e
);
2040 if (current_lrvalue
== e
) current_lrvalue
= hist
->stat
;
2041 if (current_lvalue
== e
) current_lvalue
= hist
->stat
;
2042 functioncall_traversing_visitor::visit_arrayindex (e
);
2045 current_lrvalue
= last_lrvalue
;
2046 current_lvalue
= last_lvalue
;
2051 varuse_collecting_visitor::visit_pre_crement (pre_crement
*e
)
2053 // PR6954: regard as pure writes
2054 expression
* last_lvalue
= current_lvalue
;
2055 current_lvalue
= e
->operand
; // leave a mark for ::visit_symbol
2056 functioncall_traversing_visitor::visit_pre_crement (e
);
2057 current_lvalue
= last_lvalue
;
2061 varuse_collecting_visitor::visit_post_crement (post_crement
*e
)
2063 // PR6954: regard as pure writes
2064 expression
* last_lvalue
= current_lvalue
;
2065 current_lvalue
= e
->operand
; // leave a mark for ::visit_symbol
2066 functioncall_traversing_visitor::visit_post_crement (e
);
2067 current_lvalue
= last_lvalue
;
2071 varuse_collecting_visitor::visit_foreach_loop (foreach_loop
* s
)
2073 // NB: we duplicate so don't bother call
2074 // functioncall_traversing_visitor::visit_foreach_loop (s);
2076 symbol
*array
= NULL
;
2077 hist_op
*hist
= NULL
;
2078 classify_indexable (s
->base
, array
, hist
);
2084 // If the collection is sorted, imply a "write" access to the
2085 // array in addition to the "read" one already noted above.
2086 if (s
->sort_direction
)
2088 symbol
*array
= NULL
;
2089 hist_op
*hist
= NULL
;
2090 classify_indexable (s
->base
, array
, hist
);
2091 if (array
) this->written
.insert (array
->referent
);
2092 // XXX: Can hist_op iterations be sorted?
2095 // NB: don't forget to visit the index expressions, which are lvalues.
2096 for (unsigned i
=0; i
<s
->indexes
.size(); i
++)
2098 expression
* last_lvalue
= current_lvalue
;
2099 current_lvalue
= s
->indexes
[i
]; // leave a mark for ::visit_symbol
2100 s
->indexes
[i
]->visit (this);
2101 current_lvalue
= last_lvalue
;
2104 // The value is an lvalue too
2107 expression
* last_lvalue
= current_lvalue
;
2108 current_lvalue
= s
->value
; // leave a mark for ::visit_symbol
2109 s
->value
->visit (this);
2110 current_lvalue
= last_lvalue
;
2114 s
->limit
->visit (this);
2116 s
->block
->visit (this);
2121 varuse_collecting_visitor::visit_delete_statement (delete_statement
* s
)
2123 // Ideally, this would be treated like an assignment: a plain write
2124 // to the underlying value ("lvalue"). XXX: However, the
2125 // optimization pass is not smart enough to remove an unneeded
2126 // "delete" yet, so we pose more like a *crement ("lrvalue"). This
2127 // should protect the underlying value from optimizional mischief.
2128 expression
* last_lrvalue
= current_lrvalue
;
2129 current_lrvalue
= s
->value
; // leave a mark for ::visit_symbol
2130 functioncall_traversing_visitor::visit_delete_statement (s
);
2131 current_lrvalue
= last_lrvalue
;
2135 varuse_collecting_visitor::side_effect_free ()
2137 return (written
.empty() && !embedded_seen
);
2142 varuse_collecting_visitor::side_effect_free_wrt (const set
<vardecl
*>& vars
)
2144 // A looser notion of side-effect-freeness with respect to a given
2145 // list of variables.
2147 // That's useful because the written list may consist of local
2148 // variables of called functions. But visible side-effects only
2149 // occur if the client's locals, or any globals are written-to.
2151 set
<vardecl
*> intersection
;
2152 insert_iterator
<set
<vardecl
*> > int_it (intersection
, intersection
.begin());
2153 set_intersection (written
.begin(), written
.end(),
2154 vars
.begin(), vars
.end(),
2157 return (intersection
.empty() && !embedded_seen
);
2163 // ------------------------------------------------------------------------
2166 throwing_visitor::throwing_visitor (const std::string
& m
): msg (m
) {}
2167 throwing_visitor::throwing_visitor (): msg ("invalid element") {}
2171 throwing_visitor::throwone (const token
* t
)
2173 throw semantic_error (msg
, t
);
2177 throwing_visitor::visit_block (block
* s
)
2183 throwing_visitor::visit_try_block (try_block
* s
)
2190 throwing_visitor::visit_embeddedcode (embeddedcode
* s
)
2196 throwing_visitor::visit_null_statement (null_statement
* s
)
2202 throwing_visitor::visit_expr_statement (expr_statement
* s
)
2208 throwing_visitor::visit_if_statement (if_statement
* s
)
2214 throwing_visitor::visit_for_loop (for_loop
* s
)
2220 throwing_visitor::visit_foreach_loop (foreach_loop
* s
)
2226 throwing_visitor::visit_return_statement (return_statement
* s
)
2232 throwing_visitor::visit_delete_statement (delete_statement
* s
)
2238 throwing_visitor::visit_next_statement (next_statement
* s
)
2244 throwing_visitor::visit_break_statement (break_statement
* s
)
2250 throwing_visitor::visit_continue_statement (continue_statement
* s
)
2256 throwing_visitor::visit_literal_string (literal_string
* e
)
2262 throwing_visitor::visit_literal_number (literal_number
* e
)
2268 throwing_visitor::visit_embedded_expr (embedded_expr
* e
)
2274 throwing_visitor::visit_binary_expression (binary_expression
* e
)
2280 throwing_visitor::visit_unary_expression (unary_expression
* e
)
2286 throwing_visitor::visit_pre_crement (pre_crement
* e
)
2292 throwing_visitor::visit_post_crement (post_crement
* e
)
2299 throwing_visitor::visit_logical_or_expr (logical_or_expr
* e
)
2305 throwing_visitor::visit_logical_and_expr (logical_and_expr
* e
)
2311 throwing_visitor::visit_array_in (array_in
* e
)
2317 throwing_visitor::visit_comparison (comparison
* e
)
2323 throwing_visitor::visit_concatenation (concatenation
* e
)
2329 throwing_visitor::visit_ternary_expression (ternary_expression
* e
)
2335 throwing_visitor::visit_assignment (assignment
* e
)
2341 throwing_visitor::visit_symbol (symbol
* e
)
2347 throwing_visitor::visit_target_symbol (target_symbol
* e
)
2353 throwing_visitor::visit_cast_op (cast_op
* e
)
2359 throwing_visitor::visit_defined_op (defined_op
* e
)
2366 throwing_visitor::visit_arrayindex (arrayindex
* e
)
2372 throwing_visitor::visit_functioncall (functioncall
* e
)
2378 throwing_visitor::visit_print_format (print_format
* e
)
2384 throwing_visitor::visit_stat_op (stat_op
* e
)
2390 throwing_visitor::visit_hist_op (hist_op
* e
)
2396 // ------------------------------------------------------------------------
2400 update_visitor::visit_block (block
* s
)
2402 for (unsigned i
= 0; i
< s
->statements
.size(); ++i
)
2403 replace (s
->statements
[i
]);
2408 update_visitor::visit_try_block (try_block
* s
)
2410 replace (s
->try_block
);
2411 replace (s
->catch_error_var
);
2412 replace (s
->catch_block
);
2417 update_visitor::visit_embeddedcode (embeddedcode
* s
)
2423 update_visitor::visit_null_statement (null_statement
* s
)
2429 update_visitor::visit_expr_statement (expr_statement
* s
)
2436 update_visitor::visit_if_statement (if_statement
* s
)
2438 replace (s
->condition
);
2439 replace (s
->thenblock
);
2440 replace (s
->elseblock
);
2445 update_visitor::visit_for_loop (for_loop
* s
)
2455 update_visitor::visit_foreach_loop (foreach_loop
* s
)
2457 for (unsigned i
= 0; i
< s
->indexes
.size(); ++i
)
2458 replace (s
->indexes
[i
]);
2467 update_visitor::visit_return_statement (return_statement
* s
)
2474 update_visitor::visit_delete_statement (delete_statement
* s
)
2481 update_visitor::visit_next_statement (next_statement
* s
)
2487 update_visitor::visit_break_statement (break_statement
* s
)
2493 update_visitor::visit_continue_statement (continue_statement
* s
)
2499 update_visitor::visit_literal_string (literal_string
* e
)
2505 update_visitor::visit_literal_number (literal_number
* e
)
2511 update_visitor::visit_embedded_expr (embedded_expr
* e
)
2517 update_visitor::visit_binary_expression (binary_expression
* e
)
2525 update_visitor::visit_unary_expression (unary_expression
* e
)
2527 replace (e
->operand
);
2532 update_visitor::visit_pre_crement (pre_crement
* e
)
2534 replace (e
->operand
);
2539 update_visitor::visit_post_crement (post_crement
* e
)
2541 replace (e
->operand
);
2547 update_visitor::visit_logical_or_expr (logical_or_expr
* e
)
2555 update_visitor::visit_logical_and_expr (logical_and_expr
* e
)
2563 update_visitor::visit_array_in (array_in
* e
)
2565 replace (e
->operand
);
2570 update_visitor::visit_comparison (comparison
* e
)
2578 update_visitor::visit_concatenation (concatenation
* e
)
2586 update_visitor::visit_ternary_expression (ternary_expression
* e
)
2589 replace (e
->truevalue
);
2590 replace (e
->falsevalue
);
2595 update_visitor::visit_assignment (assignment
* e
)
2603 update_visitor::visit_symbol (symbol
* e
)
2609 update_visitor::visit_target_symbol (target_symbol
* e
)
2611 e
->visit_components (this);
2616 update_visitor::visit_cast_op (cast_op
* e
)
2618 replace (e
->operand
);
2619 e
->visit_components (this);
2624 update_visitor::visit_defined_op (defined_op
* e
)
2626 replace (e
->operand
);
2631 update_visitor::visit_arrayindex (arrayindex
* e
)
2634 for (unsigned i
= 0; i
< e
->indexes
.size(); ++i
)
2635 replace (e
->indexes
[i
]);
2640 update_visitor::visit_functioncall (functioncall
* e
)
2642 for (unsigned i
= 0; i
< e
->args
.size(); ++i
)
2643 replace (e
->args
[i
]);
2648 update_visitor::visit_print_format (print_format
* e
)
2650 for (unsigned i
= 0; i
< e
->args
.size(); ++i
)
2651 replace (e
->args
[i
]);
2657 update_visitor::visit_stat_op (stat_op
* e
)
2664 update_visitor::visit_hist_op (hist_op
* e
)
2670 template <> indexable
*
2671 update_visitor::require
<indexable
> (indexable
* src
, bool clearok
)
2673 indexable
*dst
= NULL
;
2676 symbol
*array_src
=NULL
;
2677 hist_op
*hist_src
=NULL
;
2679 classify_indexable(src
, array_src
, hist_src
);
2682 dst
= require (array_src
);
2684 dst
= require (hist_src
);
2685 assert(clearok
|| dst
);
2691 // ------------------------------------------------------------------------
2695 deep_copy_visitor::visit_block (block
* s
)
2697 update_visitor::visit_block(new block(*s
));
2701 deep_copy_visitor::visit_try_block (try_block
* s
)
2703 update_visitor::visit_try_block(new try_block(*s
));
2707 deep_copy_visitor::visit_embeddedcode (embeddedcode
* s
)
2709 update_visitor::visit_embeddedcode(new embeddedcode(*s
));
2713 deep_copy_visitor::visit_null_statement (null_statement
* s
)
2715 update_visitor::visit_null_statement(new null_statement(*s
));
2719 deep_copy_visitor::visit_expr_statement (expr_statement
* s
)
2721 update_visitor::visit_expr_statement(new expr_statement(*s
));
2725 deep_copy_visitor::visit_if_statement (if_statement
* s
)
2727 update_visitor::visit_if_statement(new if_statement(*s
));
2731 deep_copy_visitor::visit_for_loop (for_loop
* s
)
2733 update_visitor::visit_for_loop(new for_loop(*s
));
2737 deep_copy_visitor::visit_foreach_loop (foreach_loop
* s
)
2739 update_visitor::visit_foreach_loop(new foreach_loop(*s
));
2743 deep_copy_visitor::visit_return_statement (return_statement
* s
)
2745 update_visitor::visit_return_statement(new return_statement(*s
));
2749 deep_copy_visitor::visit_delete_statement (delete_statement
* s
)
2751 update_visitor::visit_delete_statement(new delete_statement(*s
));
2755 deep_copy_visitor::visit_next_statement (next_statement
* s
)
2757 update_visitor::visit_next_statement(new next_statement(*s
));
2761 deep_copy_visitor::visit_break_statement (break_statement
* s
)
2763 update_visitor::visit_break_statement(new break_statement(*s
));
2767 deep_copy_visitor::visit_continue_statement (continue_statement
* s
)
2769 update_visitor::visit_continue_statement(new continue_statement(*s
));
2773 deep_copy_visitor::visit_literal_string (literal_string
* e
)
2775 update_visitor::visit_literal_string(new literal_string(*e
));
2779 deep_copy_visitor::visit_literal_number (literal_number
* e
)
2781 update_visitor::visit_literal_number(new literal_number(*e
));
2785 deep_copy_visitor::visit_embedded_expr (embedded_expr
* e
)
2787 update_visitor::visit_embedded_expr(new embedded_expr(*e
));
2791 deep_copy_visitor::visit_binary_expression (binary_expression
* e
)
2793 update_visitor::visit_binary_expression(new binary_expression(*e
));
2797 deep_copy_visitor::visit_unary_expression (unary_expression
* e
)
2799 update_visitor::visit_unary_expression(new unary_expression(*e
));
2803 deep_copy_visitor::visit_pre_crement (pre_crement
* e
)
2805 update_visitor::visit_pre_crement(new pre_crement(*e
));
2809 deep_copy_visitor::visit_post_crement (post_crement
* e
)
2811 update_visitor::visit_post_crement(new post_crement(*e
));
2816 deep_copy_visitor::visit_logical_or_expr (logical_or_expr
* e
)
2818 update_visitor::visit_logical_or_expr(new logical_or_expr(*e
));
2822 deep_copy_visitor::visit_logical_and_expr (logical_and_expr
* e
)
2824 update_visitor::visit_logical_and_expr(new logical_and_expr(*e
));
2828 deep_copy_visitor::visit_array_in (array_in
* e
)
2830 update_visitor::visit_array_in(new array_in(*e
));
2834 deep_copy_visitor::visit_comparison (comparison
* e
)
2836 update_visitor::visit_comparison(new comparison(*e
));
2840 deep_copy_visitor::visit_concatenation (concatenation
* e
)
2842 update_visitor::visit_concatenation(new concatenation(*e
));
2846 deep_copy_visitor::visit_ternary_expression (ternary_expression
* e
)
2848 update_visitor::visit_ternary_expression(new ternary_expression(*e
));
2852 deep_copy_visitor::visit_assignment (assignment
* e
)
2854 update_visitor::visit_assignment(new assignment(*e
));
2858 deep_copy_visitor::visit_symbol (symbol
* e
)
2860 symbol
* n
= new symbol(*e
);
2861 n
->referent
= NULL
; // don't copy!
2862 update_visitor::visit_symbol(n
);
2866 deep_copy_visitor::visit_target_symbol (target_symbol
* e
)
2868 target_symbol
* n
= new target_symbol(*e
);
2869 n
->referent
= NULL
; // don't copy!
2870 update_visitor::visit_target_symbol(n
);
2874 deep_copy_visitor::visit_cast_op (cast_op
* e
)
2876 update_visitor::visit_cast_op(new cast_op(*e
));
2880 deep_copy_visitor::visit_defined_op (defined_op
* e
)
2882 update_visitor::visit_defined_op(new defined_op(*e
));
2886 deep_copy_visitor::visit_arrayindex (arrayindex
* e
)
2888 update_visitor::visit_arrayindex(new arrayindex(*e
));
2892 deep_copy_visitor::visit_functioncall (functioncall
* e
)
2894 functioncall
* n
= new functioncall(*e
);
2895 n
->referent
= NULL
; // don't copy!
2896 update_visitor::visit_functioncall(n
);
2900 deep_copy_visitor::visit_print_format (print_format
* e
)
2902 update_visitor::visit_print_format(new print_format(*e
));
2906 deep_copy_visitor::visit_stat_op (stat_op
* e
)
2908 update_visitor::visit_stat_op(new stat_op(*e
));
2912 deep_copy_visitor::visit_hist_op (hist_op
* e
)
2914 update_visitor::visit_hist_op(new hist_op(*e
));
2917 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */