1 // parse tree functions
2 // Copyright (C) 2005-2011 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 ():
81 tok (0), systemtap_v_conditional (0),
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)
111 unsigned probe::last_probeidx
= 0;
114 body (0), tok (0), systemtap_v_conditional (0)
116 this->name
= string ("probe_") + lex_cast(last_probeidx
++);
120 // Copy constructor, but with overriding probe-point. To be used when
121 // mapping script-level probe points to another one, early during pass
122 // 2. There should be no symbol resolution done yet.
123 probe::probe(const probe
& p
, probe_point
* l
)
125 this->name
= string ("probe_") + lex_cast(last_probeidx
++);
127 this->locations
.push_back(l
);
128 this->body
= p
.body
; // NB: not needed to be copied yet; a later derived_probe will
129 this->privileged
= p
.privileged
;
130 this->systemtap_v_conditional
= p
.systemtap_v_conditional
;
131 assert (p
.locals
.size() == 0);
132 assert (p
.unused_locals
.size() == 0);
136 probe_point::component::component ():
142 probe_point::component::component (std::string
const & f
, literal
* a
):
149 arity_tok(0), arity (-1), maxsize(0), init(NULL
), skip_init(false)
155 vardecl::set_arity (int a
, const token
* t
)
160 if (a
== 0 && maxsize
> 0)
161 throw semantic_error ("inconsistent arity", tok
);
163 if (arity
!= a
&& arity
>= 0)
165 semantic_error
err ("inconsistent arity (" + lex_cast(arity
) +
166 " vs. " + lex_cast(a
) + ")", t
?:tok
);
168 err
.chain
= new semantic_error ("arity " + lex_cast(arity
) +
169 " first inferred here", arity_tok
);
177 index_types
.resize (arity
);
178 for (int i
=0; i
<arity
; i
++)
179 index_types
[i
] = pe_unknown
;
184 vardecl::compatible_arity (int a
)
186 if (a
== 0 && maxsize
> 0)
188 if (arity
== -1 || a
== -1)
194 functiondecl::functiondecl ():
195 body (0), synthetic (false)
200 functiondecl::join (systemtap_session
& s
)
203 throw semantic_error ("internal error, joining a non-synthetic function", tok
);
204 if (!s
.functions
.insert (make_pair (name
, this)).second
)
205 throw semantic_error ("synthetic function '" + name
+
206 "' conflicts with an existing function", tok
);
207 tok
->location
.file
->functions
.push_back (this);
211 literal_number::literal_number (int64_t v
, bool hex
)
219 literal_string::literal_string (const string
& v
)
227 operator << (ostream
& o
, const exp_type
& e
)
231 case pe_unknown
: o
<< "unknown"; break;
232 case pe_long
: o
<< "long"; break;
233 case pe_string
: o
<< "string"; break;
234 case pe_stats
: o
<< "stats"; break;
235 default: o
<< "???"; break;
242 target_symbol::assert_no_components(const std::string
& tapset
, bool pretty_ok
)
244 if (components
.empty())
247 switch (components
[0].type
)
249 case comp_literal_array_index
:
250 case comp_expression_array_index
:
251 throw semantic_error(tapset
+ " variable '" + name
+
252 "' may not be used as array",
254 case comp_struct_member
:
255 throw semantic_error(tapset
+ " variable '" + name
+
256 "' may not be used as a structure",
258 case comp_pretty_print
:
260 throw semantic_error(tapset
+ " variable '" + name
+
261 "' may not be pretty-printed",
265 throw semantic_error ("invalid use of " + tapset
+
266 " variable '" + name
+ "'",
272 void target_symbol::chain (const semantic_error
&er
)
274 semantic_error
* e
= new semantic_error(er
);
277 assert (e
->chain
== 0);
278 e
->chain
= this->saved_conversion_error
;
279 this->saved_conversion_error
= e
;
283 // ------------------------------------------------------------------------
284 // parse tree printing
286 ostream
& operator << (ostream
& o
, const expression
& k
)
293 void literal_string::print (ostream
& o
) const
296 for (unsigned i
=0; i
<value
.size(); i
++)
297 if (value
[i
] == '"') // or other escapeworthy characters?
305 void literal_number::print (ostream
& o
) const
308 o
<< hex
<< showbase
;
311 o
<< dec
<< noshowbase
;
315 void embedded_expr::print (ostream
& o
) const
317 o
<< "%{ " << code
<< " %}";
321 void binary_expression::print (ostream
& o
) const
323 o
<< "(" << *left
<< ") "
325 << " (" << *right
<< ")";
329 void unary_expression::print (ostream
& o
) const
331 o
<< op
<< '(' << *operand
<< ")";
334 void array_in::print (ostream
& o
) const
337 for (unsigned i
=0; i
<operand
->indexes
.size(); i
++)
339 if (i
> 0) o
<< ", ";
340 operand
->indexes
[i
]->print (o
);
343 operand
->base
->print_indexable (o
);
346 void post_crement::print (ostream
& o
) const
348 o
<< '(' << *operand
<< ")" << op
;
352 void ternary_expression::print (ostream
& o
) const
354 o
<< "(" << *cond
<< ")?("
355 << *truevalue
<< "):("
356 << *falsevalue
<< ")";
360 void symbol::print (ostream
& o
) const
366 void target_symbol::component::print (ostream
& o
) const
370 case comp_pretty_print
:
371 case comp_struct_member
:
374 case comp_literal_array_index
:
375 o
<< '[' << num_index
<< ']';
377 case comp_expression_array_index
:
378 o
<< '[' << *expr_index
<< ']';
384 std::ostream
& operator << (std::ostream
& o
, const target_symbol::component
& c
)
391 void target_symbol::print (ostream
& o
) const
396 for (unsigned i
= 0; i
< components
.size(); ++i
)
401 void cast_op::print (ostream
& o
) const
405 o
<< name
<< '(' << *operand
;
406 o
<< ", " << lex_cast_qstring (type_name
);
407 if (module
.length() > 0)
408 o
<< ", " << lex_cast_qstring (module
);
410 for (unsigned i
= 0; i
< components
.size(); ++i
)
415 void defined_op::print (ostream
& o
) const
417 o
<< "@defined(" << *operand
<< ")";
421 void entry_op::print (ostream
& o
) const
423 o
<< "@entry(" << *operand
<< ")";
427 void vardecl::print (ostream
& o
) const
431 o
<< "[" << maxsize
<< "]";
432 if (arity
> 0 || index_types
.size() > 0)
442 void vardecl::printsig (ostream
& o
) const
446 o
<< "[" << maxsize
<< "]";
448 if (index_types
.size() > 0)
451 for (unsigned i
=0; i
<index_types
.size(); i
++)
452 o
<< (i
>0 ? ", " : "") << index_types
[i
];
458 void functiondecl::print (ostream
& o
) const
460 o
<< "function " << name
<< " (";
461 for (unsigned i
=0; i
<formal_args
.size(); i
++)
462 o
<< (i
>0 ? ", " : "") << *formal_args
[i
];
468 void functiondecl::printsig (ostream
& o
) const
470 o
<< name
<< ":" << type
<< " (";
471 for (unsigned i
=0; i
<formal_args
.size(); i
++)
472 o
<< (i
>0 ? ", " : "")
475 << formal_args
[i
]->type
;
480 void arrayindex::print (ostream
& o
) const
482 base
->print_indexable (o
);
484 for (unsigned i
=0; i
<indexes
.size(); i
++)
485 o
<< (i
>0 ? ", " : "") << *indexes
[i
];
490 void functioncall::print (ostream
& o
) const
492 o
<< function
<< "(";
493 for (unsigned i
=0; i
<args
.size(); i
++)
494 o
<< (i
>0 ? ", " : "") << *args
[i
];
500 print_format::create(const token
*t
)
502 bool stream
, format
, delim
, newline
, _char
;
503 const char *n
= t
->content
.c_str();
506 format
= delim
= newline
= _char
= false;
508 if (strcmp(n
, "print_char") == 0)
518 if (0 != strncmp(n
, "print", 5))
535 if (*n
== 'l' && *(n
+1) == 'n')
546 print_format
*pf
= new print_format(stream
, format
, delim
, newline
, _char
);
553 print_format::components_to_string(vector
<format_component
> const & components
)
557 for (vector
<format_component
>::const_iterator i
= components
.begin();
558 i
!= components
.end(); ++i
)
561 assert (i
->type
!= conv_unspecified
);
563 if (i
->type
== conv_literal
)
565 assert(!i
->literal_string
.empty());
566 for (string::const_iterator j
= i
->literal_string
.begin();
567 j
!= i
->literal_string
.end(); ++j
)
569 // See also: c_unparser::visit_literal_string and lex_cast_qstring
581 if (i
->flags
& static_cast<unsigned long>(fmt_flag_zeropad
))
584 if (i
->flags
& static_cast<unsigned long>(fmt_flag_plus
))
587 if (i
->flags
& static_cast<unsigned long>(fmt_flag_space
))
590 if (i
->flags
& static_cast<unsigned long>(fmt_flag_left
))
593 if (i
->flags
& static_cast<unsigned long>(fmt_flag_special
))
596 if (i
->widthtype
== width_dynamic
)
598 else if (i
->widthtype
!= width_unspecified
&& i
->width
> 0)
601 if (i
->prectype
== prec_dynamic
)
603 else if (i
->prectype
!= prec_unspecified
&& i
->precision
> 0)
604 oss
<< '.' << i
->precision
;
616 case conv_signed_decimal
:
620 case conv_unsigned_decimal
:
624 case conv_unsigned_octal
:
628 case conv_unsigned_ptr
:
632 case conv_unsigned_uppercase_hex
:
636 case conv_unsigned_lowercase_hex
:
648 case conv_memory_hex
:
660 vector
<print_format::format_component
>
661 print_format::string_to_components(string
const & str
)
663 format_component curr
;
664 vector
<format_component
> res
;
668 string::const_iterator i
= str
.begin();
670 while (i
!= str
.end())
674 assert (curr
.type
== conv_unspecified
|| curr
.type
== conv_literal
);
675 curr
.type
= conv_literal
;
676 curr
.literal_string
+= *i
;
680 else if (i
+1 == str
.end() || *(i
+1) == '%')
683 // *i == '%' and *(i+1) == '%'; append only one '%' to the literal string
684 assert (curr
.type
== conv_unspecified
|| curr
.type
== conv_literal
);
685 curr
.type
= conv_literal
;
686 curr
.literal_string
+= '%';
693 if (curr
.type
!= conv_unspecified
)
695 // Flush any component we were previously accumulating
696 assert (curr
.type
== conv_literal
);
706 // Now we are definitely parsing a conversion.
707 // Begin by parsing flags (which are optional).
712 curr
.flags
|= static_cast<unsigned long>(fmt_flag_zeropad
);
717 curr
.flags
|= static_cast<unsigned long>(fmt_flag_plus
);
722 curr
.flags
|= static_cast<unsigned long>(fmt_flag_left
);
727 curr
.flags
|= static_cast<unsigned long>(fmt_flag_space
);
732 curr
.flags
|= static_cast<unsigned long>(fmt_flag_special
);
743 // Parse optional width
746 curr
.widthtype
= width_dynamic
;
749 else if (isdigit(*i
))
751 curr
.widthtype
= width_static
;
756 curr
.width
+= (*i
- '0');
759 while (i
!= str
.end() && isdigit(*i
));
765 // Parse optional precision
773 curr
.prectype
= prec_dynamic
;
776 else if (isdigit(*i
))
778 curr
.prectype
= prec_static
;
782 curr
.precision
*= 10;
783 curr
.precision
+= (*i
- '0');
786 while (i
!= str
.end() && isdigit(*i
));
793 // Parse the type modifier
804 // Parse the actual conversion specifier (bcsmdioupxXn)
807 // Valid conversion types
809 curr
.type
= conv_binary
;
813 curr
.type
= conv_char
;
817 curr
.type
= conv_string
;
821 curr
.type
= conv_memory
;
825 curr
.type
= conv_memory_hex
;
830 curr
.type
= conv_signed_decimal
;
834 curr
.type
= conv_unsigned_octal
;
838 curr
.type
= conv_unsigned_decimal
;
842 curr
.type
= conv_unsigned_ptr
;
846 curr
.type
= conv_unsigned_uppercase_hex
;
850 curr
.type
= conv_unsigned_lowercase_hex
;
857 if (curr
.type
== conv_unspecified
)
858 throw parse_error("invalid or missing conversion specifier");
865 // If there's a remaining partly-composed conversion, fail.
866 if (!curr
.is_empty())
868 if (curr
.type
== conv_literal
)
871 throw parse_error("trailing incomplete print format conversion");
878 void print_format::print (ostream
& o
) const
880 o
<< tok
->content
<< "(";
881 if (print_with_format
)
882 o
<< lex_cast_qstring (raw_components
);
883 if (print_with_delim
)
884 o
<< lex_cast_qstring (delimiter
.literal_string
);
887 for (vector
<expression
*>::const_iterator i
= args
.begin();
888 i
!= args
.end(); ++i
)
890 if (i
!= args
.begin() || print_with_format
|| print_with_delim
)
897 void stat_op::print (ostream
& o
) const
927 hist_op::print (ostream
& o
) const
933 assert(params
.size() == 3);
936 for (size_t i
= 0; i
< params
.size(); ++i
)
938 o
<< ", " << params
[i
];
944 assert(params
.size() == 0);
952 ostream
& operator << (ostream
& o
, const statement
& k
)
959 void embeddedcode::print (ostream
&o
) const
966 void block::print (ostream
& o
) const
969 for (unsigned i
=0; i
<statements
.size(); i
++)
970 o
<< *statements
[i
] << endl
;
974 block::block (statement
* car
, statement
* cdr
)
976 statements
.push_back(car
);
977 statements
.push_back(cdr
);
978 this->tok
= car
->tok
;
983 void try_block::print (ostream
& o
) const
985 o
<< "try {" << endl
;
986 if (try_block
) o
<< *try_block
<< endl
;
988 if (catch_error_var
) o
<< "(" << *catch_error_var
<< ") ";
990 if (catch_block
) o
<< *catch_block
<< endl
;
995 void for_loop::print (ostream
& o
) const
998 if (init
) init
->print (o
);
1002 if (incr
) incr
->print (o
);
1008 void foreach_loop::print (ostream
& o
) const
1017 for (unsigned i
=0; i
<indexes
.size(); i
++)
1019 if (i
> 0) o
<< ", ";
1020 indexes
[i
]->print (o
);
1021 if (sort_direction
!= 0 && sort_column
== i
+1)
1022 o
<< (sort_direction
> 0 ? "+" : "-");
1025 base
->print_indexable (o
);
1026 if (sort_direction
!= 0 && sort_column
== 0)
1027 o
<< (sort_direction
> 0 ? "+" : "-");
1038 void null_statement::print (ostream
& o
) const
1044 void expr_statement::print (ostream
& o
) const
1050 void return_statement::print (ostream
& o
) const
1052 o
<< "return " << *value
;
1056 void delete_statement::print (ostream
& o
) const
1058 o
<< "delete " << *value
;
1061 void next_statement::print (ostream
& o
) const
1066 void break_statement::print (ostream
& o
) const
1071 void continue_statement::print (ostream
& o
) const
1076 void if_statement::print (ostream
& o
) const
1078 o
<< "if (" << *condition
<< ") "
1079 << *thenblock
<< endl
;
1081 o
<< "else " << *elseblock
<< endl
;
1085 void stapfile::print (ostream
& o
) const
1087 o
<< "# file " << name
<< endl
;
1089 for (unsigned i
=0; i
<embeds
.size(); i
++)
1090 embeds
[i
]->print (o
);
1092 for (unsigned i
=0; i
<globals
.size(); i
++)
1095 globals
[i
]->print (o
);
1099 for (unsigned i
=0; i
<aliases
.size(); i
++)
1101 aliases
[i
]->print (o
);
1105 for (unsigned i
=0; i
<probes
.size(); i
++)
1107 probes
[i
]->print (o
);
1111 for (unsigned j
= 0; j
< functions
.size(); j
++)
1113 functions
[j
]->print (o
);
1119 void probe::print (ostream
& o
) const
1127 void probe::printsig (ostream
& o
) const
1129 const probe_alias
*alias
= get_alias ();
1132 alias
->printsig (o
);
1136 for (unsigned i
=0; i
<locations
.size(); i
++)
1138 if (i
> 0) o
<< ",";
1139 locations
[i
]->print (o
);
1145 probe::collect_derivation_chain (std::vector
<probe
*> &probes_list
)
1147 probes_list
.push_back(this);
1151 void probe_point::print (ostream
& o
, bool print_extras
) const
1153 for (unsigned i
=0; i
<components
.size(); i
++)
1156 probe_point::component
* c
= components
[i
];
1159 o
<< "(" << *c
->arg
<< ")";
1165 else if (optional
) // sufficient implies optional
1168 o
<< " if (" << *condition
<< ")";
1171 string
probe_point::str (bool print_extras
) const
1174 print(o
, print_extras
);
1179 probe_alias::probe_alias(std::vector
<probe_point
*> const & aliases
):
1180 probe (), alias_names (aliases
)
1184 void probe_alias::printsig (ostream
& o
) const
1186 for (unsigned i
=0; i
<alias_names
.size(); i
++)
1188 o
<< (i
>0 ? " = " : "");
1189 alias_names
[i
]->print (o
);
1192 for (unsigned i
=0; i
<locations
.size(); i
++)
1194 if (i
> 0) o
<< ", ";
1195 locations
[i
]->print (o
);
1200 ostream
& operator << (ostream
& o
, const probe_point
& k
)
1207 ostream
& operator << (ostream
& o
, const symboldecl
& k
)
1215 // ------------------------------------------------------------------------
1220 block::visit (visitor
* u
)
1222 u
->visit_block (this);
1227 try_block::visit (visitor
* u
)
1229 u
->visit_try_block (this);
1234 embeddedcode::visit (visitor
* u
)
1236 u
->visit_embeddedcode (this);
1241 for_loop::visit (visitor
* u
)
1243 u
->visit_for_loop (this);
1247 foreach_loop::visit (visitor
* u
)
1249 u
->visit_foreach_loop (this);
1253 null_statement::visit (visitor
* u
)
1255 u
->visit_null_statement (this);
1259 expr_statement::visit (visitor
* u
)
1261 u
->visit_expr_statement (this);
1265 return_statement::visit (visitor
* u
)
1267 u
->visit_return_statement (this);
1271 delete_statement::visit (visitor
* u
)
1273 u
->push_active_lvalue (this->value
);
1274 u
->visit_delete_statement (this);
1275 u
->pop_active_lvalue ();
1279 if_statement::visit (visitor
* u
)
1281 u
->visit_if_statement (this);
1285 next_statement::visit (visitor
* u
)
1287 u
->visit_next_statement (this);
1291 break_statement::visit (visitor
* u
)
1293 u
->visit_break_statement (this);
1297 continue_statement::visit (visitor
* u
)
1299 u
->visit_continue_statement (this);
1303 literal_string::visit(visitor
* u
)
1305 u
->visit_literal_string (this);
1309 literal_number::visit(visitor
* u
)
1311 u
->visit_literal_number (this);
1315 binary_expression::visit (visitor
* u
)
1317 u
->visit_binary_expression (this);
1321 embedded_expr::visit (visitor
* u
)
1323 u
->visit_embedded_expr (this);
1327 unary_expression::visit (visitor
* u
)
1329 u
->visit_unary_expression (this);
1333 pre_crement::visit (visitor
* u
)
1335 u
->push_active_lvalue (this->operand
);
1336 u
->visit_pre_crement (this);
1337 u
->pop_active_lvalue ();
1341 post_crement::visit (visitor
* u
)
1343 u
->push_active_lvalue (this->operand
);
1344 u
->visit_post_crement (this);
1345 u
->pop_active_lvalue ();
1349 logical_or_expr::visit (visitor
* u
)
1351 u
->visit_logical_or_expr (this);
1355 logical_and_expr::visit (visitor
* u
)
1357 u
->visit_logical_and_expr (this);
1361 array_in::visit (visitor
* u
)
1363 u
->visit_array_in (this);
1367 comparison::visit (visitor
* u
)
1369 u
->visit_comparison (this);
1373 concatenation::visit (visitor
* u
)
1375 u
->visit_concatenation (this);
1379 ternary_expression::visit (visitor
* u
)
1381 u
->visit_ternary_expression (this);
1385 assignment::visit (visitor
* u
)
1387 u
->push_active_lvalue (this->left
);
1388 u
->visit_assignment (this);
1389 u
->pop_active_lvalue ();
1393 symbol::visit (visitor
* u
)
1395 u
->visit_symbol (this);
1399 target_symbol::visit (visitor
* u
)
1401 u
->visit_target_symbol(this);
1405 target_symbol::visit_components (visitor
* u
)
1407 for (unsigned i
= 0; i
< components
.size(); ++i
)
1408 if (components
[i
].type
== comp_expression_array_index
)
1409 components
[i
].expr_index
->visit (u
);
1413 target_symbol::visit_components (update_visitor
* u
)
1415 for (unsigned i
= 0; i
< components
.size(); ++i
)
1416 if (components
[i
].type
== comp_expression_array_index
)
1417 u
->replace (components
[i
].expr_index
);
1421 cast_op::visit (visitor
* u
)
1423 u
->visit_cast_op(this);
1428 defined_op::visit (visitor
* u
)
1430 u
->visit_defined_op(this);
1435 entry_op::visit (visitor
* u
)
1437 u
->visit_entry_op(this);
1442 arrayindex::visit (visitor
* u
)
1444 u
->visit_arrayindex (this);
1448 functioncall::visit (visitor
* u
)
1450 u
->visit_functioncall (this);
1454 print_format::visit (visitor
*u
)
1456 u
->visit_print_format (this);
1460 stat_op::visit (visitor
*u
)
1462 u
->visit_stat_op (this);
1466 hist_op::visit (visitor
*u
)
1468 u
->visit_hist_op (this);
1472 indexable::print_indexable (std::ostream
& o
) const
1475 const hist_op
*hist
;
1476 classify_const_indexable(this, sym
, hist
);
1487 indexable::visit_indexable (visitor
* u
)
1491 classify_indexable(this, sym
, hist
);
1503 indexable::is_symbol(symbol
*& sym_out
)
1510 indexable::is_hist_op(hist_op
*& hist_out
)
1517 indexable::is_const_symbol(const symbol
*& sym_out
) const
1524 indexable::is_const_hist_op(const hist_op
*& hist_out
) const
1531 symbol::is_symbol(symbol
*& sym_out
)
1538 symbol::is_const_symbol(const symbol
*& sym_out
) const
1545 symbol::get_tok() const
1551 hist_op::is_hist_op(hist_op
*& hist_out
)
1558 hist_op::is_const_hist_op(const hist_op
*& hist_out
) const
1565 hist_op::get_tok() const
1571 classify_indexable(indexable
* ix
,
1572 symbol
*& array_out
,
1573 hist_op
*& hist_out
)
1577 if (!(ix
->is_symbol (array_out
) || ix
->is_hist_op (hist_out
)))
1578 throw semantic_error("Expecting symbol or histogram operator", ix
->get_tok());
1579 if (ix
&& !(hist_out
|| array_out
))
1580 throw semantic_error("Failed to classify indexable", ix
->get_tok());
1584 classify_const_indexable(const indexable
* ix
,
1585 const symbol
*& array_out
,
1586 const hist_op
*& hist_out
)
1590 if (!(ix
->is_const_symbol(array_out
) || ix
->is_const_hist_op(hist_out
)))
1591 throw semantic_error("Expecting symbol or histogram operator", ix
->get_tok());
1594 // ------------------------------------------------------------------------
1597 visitor::is_active_lvalue(expression
*e
)
1599 for (unsigned i
= 0; i
< active_lvalues
.size(); ++i
)
1601 if (active_lvalues
[i
] == e
)
1608 visitor::push_active_lvalue(expression
*e
)
1610 active_lvalues
.push_back(e
);
1614 visitor::pop_active_lvalue()
1616 assert(!active_lvalues
.empty());
1617 active_lvalues
.pop_back();
1622 // ------------------------------------------------------------------------
1625 traversing_visitor::visit_block (block
* s
)
1627 for (unsigned i
=0; i
<s
->statements
.size(); i
++)
1628 s
->statements
[i
]->visit (this);
1632 traversing_visitor::visit_try_block (try_block
* s
)
1635 s
->try_block
->visit (this);
1636 if (s
->catch_error_var
)
1637 s
->catch_error_var
->visit (this);
1639 s
->catch_block
->visit (this);
1643 traversing_visitor::visit_embeddedcode (embeddedcode
*)
1648 traversing_visitor::visit_null_statement (null_statement
*)
1653 traversing_visitor::visit_expr_statement (expr_statement
* s
)
1655 s
->value
->visit (this);
1659 traversing_visitor::visit_if_statement (if_statement
* s
)
1661 s
->condition
->visit (this);
1662 s
->thenblock
->visit (this);
1664 s
->elseblock
->visit (this);
1668 traversing_visitor::visit_for_loop (for_loop
* s
)
1670 if (s
->init
) s
->init
->visit (this);
1671 s
->cond
->visit (this);
1672 if (s
->incr
) s
->incr
->visit (this);
1673 s
->block
->visit (this);
1677 traversing_visitor::visit_foreach_loop (foreach_loop
* s
)
1679 symbol
*array
= NULL
;
1680 hist_op
*hist
= NULL
;
1681 classify_indexable (s
->base
, array
, hist
);
1687 for (unsigned i
=0; i
<s
->indexes
.size(); i
++)
1688 s
->indexes
[i
]->visit (this);
1691 s
->value
->visit (this);
1694 s
->limit
->visit (this);
1696 s
->block
->visit (this);
1700 traversing_visitor::visit_return_statement (return_statement
* s
)
1702 s
->value
->visit (this);
1706 traversing_visitor::visit_delete_statement (delete_statement
* s
)
1708 s
->value
->visit (this);
1712 traversing_visitor::visit_next_statement (next_statement
*)
1717 traversing_visitor::visit_break_statement (break_statement
*)
1722 traversing_visitor::visit_continue_statement (continue_statement
*)
1727 traversing_visitor::visit_literal_string (literal_string
*)
1732 traversing_visitor::visit_literal_number (literal_number
*)
1737 traversing_visitor::visit_embedded_expr (embedded_expr
*)
1742 traversing_visitor::visit_binary_expression (binary_expression
* e
)
1744 e
->left
->visit (this);
1745 e
->right
->visit (this);
1749 traversing_visitor::visit_unary_expression (unary_expression
* e
)
1751 e
->operand
->visit (this);
1755 traversing_visitor::visit_pre_crement (pre_crement
* e
)
1757 e
->operand
->visit (this);
1761 traversing_visitor::visit_post_crement (post_crement
* e
)
1763 e
->operand
->visit (this);
1768 traversing_visitor::visit_logical_or_expr (logical_or_expr
* e
)
1770 e
->left
->visit (this);
1771 e
->right
->visit (this);
1775 traversing_visitor::visit_logical_and_expr (logical_and_expr
* e
)
1777 e
->left
->visit (this);
1778 e
->right
->visit (this);
1782 traversing_visitor::visit_array_in (array_in
* e
)
1784 e
->operand
->visit (this);
1788 traversing_visitor::visit_comparison (comparison
* e
)
1790 e
->left
->visit (this);
1791 e
->right
->visit (this);
1795 traversing_visitor::visit_concatenation (concatenation
* e
)
1797 e
->left
->visit (this);
1798 e
->right
->visit (this);
1802 traversing_visitor::visit_ternary_expression (ternary_expression
* e
)
1804 e
->cond
->visit (this);
1805 e
->truevalue
->visit (this);
1806 e
->falsevalue
->visit (this);
1810 traversing_visitor::visit_assignment (assignment
* e
)
1812 e
->left
->visit (this);
1813 e
->right
->visit (this);
1817 traversing_visitor::visit_symbol (symbol
*)
1822 traversing_visitor::visit_target_symbol (target_symbol
* e
)
1824 e
->visit_components (this);
1828 traversing_visitor::visit_cast_op (cast_op
* e
)
1830 e
->operand
->visit (this);
1831 e
->visit_components (this);
1835 traversing_visitor::visit_defined_op (defined_op
* e
)
1837 e
->operand
->visit (this);
1841 traversing_visitor::visit_entry_op (entry_op
* e
)
1843 e
->operand
->visit (this);
1848 traversing_visitor::visit_arrayindex (arrayindex
* e
)
1850 for (unsigned i
=0; i
<e
->indexes
.size(); i
++)
1851 e
->indexes
[i
]->visit (this);
1853 symbol
*array
= NULL
;
1854 hist_op
*hist
= NULL
;
1855 classify_indexable(e
->base
, array
, hist
);
1857 return array
->visit(this);
1859 return hist
->visit(this);
1863 traversing_visitor::visit_functioncall (functioncall
* e
)
1865 for (unsigned i
=0; i
<e
->args
.size(); i
++)
1866 e
->args
[i
]->visit (this);
1870 traversing_visitor::visit_print_format (print_format
* e
)
1872 for (unsigned i
=0; i
<e
->args
.size(); i
++)
1873 e
->args
[i
]->visit (this);
1875 e
->hist
->visit(this);
1879 traversing_visitor::visit_stat_op (stat_op
* e
)
1881 e
->stat
->visit (this);
1885 traversing_visitor::visit_hist_op (hist_op
* e
)
1887 e
->stat
->visit (this);
1892 functioncall_traversing_visitor::visit_functioncall (functioncall
* e
)
1894 traversing_visitor::visit_functioncall (e
);
1896 // prevent infinite recursion
1897 if (traversed
.find (e
->referent
) == traversed
.end ())
1899 traversed
.insert (e
->referent
);
1901 functiondecl
* last_current_function
= current_function
;
1902 current_function
= e
->referent
;
1903 e
->referent
->body
->visit (this);
1904 current_function
= last_current_function
;
1910 varuse_collecting_visitor::visit_try_block (try_block
*s
)
1913 s
->try_block
->visit (this);
1914 if (s
->catch_error_var
)
1915 written
.insert (s
->catch_error_var
->referent
);
1917 s
->catch_block
->visit (this);
1919 // NB: don't functioncall_traversing_visitor::visit_try_block (s);
1920 // since that would count s->catch_error_var as a read also.
1925 varuse_collecting_visitor::visit_embeddedcode (embeddedcode
*s
)
1927 assert (current_function
); // only they get embedded code
1929 // Don't allow embedded C functions in unprivileged mode unless
1930 // they are tagged with /* unprivileged */ or /* myproc-unprivileged */
1931 if (session
.unprivileged
&&
1932 s
->code
.find ("/* unprivileged */") == string::npos
&&
1933 s
->code
.find ("/* myproc-unprivileged */") == string::npos
)
1934 throw semantic_error ("function may not be used when --unprivileged is specified",
1935 current_function
->tok
);
1937 // Don't allow /* guru */ functions unless -g is active.
1938 if (!session
.guru_mode
&& s
->code
.find ("/* guru */") != string::npos
)
1939 throw semantic_error ("function may not be used unless -g is specified",
1940 current_function
->tok
);
1942 // We want to elide embedded-C functions when possible. For
1943 // example, each $target variable access is expanded to an
1944 // embedded-C function call. Yet, for safety reasons, we should
1945 // presume that embedded-C functions have intentional side-effects.
1947 // To tell these two types of functions apart, we apply a
1948 // Kludge(tm): we look for a magic string within the function body.
1949 // $target variables as rvalues will have this; lvalues won't.
1950 // Also, explicit side-effect-free tapset functions will have this.
1952 if (s
->code
.find ("/* pure */") != string::npos
)
1955 embedded_seen
= true;
1959 // About the same case as above.
1961 varuse_collecting_visitor::visit_embedded_expr (embedded_expr
*e
)
1963 // Don't allow embedded C functions in unprivileged mode unless
1964 // they are tagged with /* unprivileged */
1965 if (session
.unprivileged
&&
1966 e
->code
.find ("/* unprivileged */") == string::npos
&&
1967 e
->code
.find ("/* myproc-unprivileged */") == string::npos
)
1968 throw semantic_error ("embedded expression may not be used when --unprivileged is specified",
1971 // Don't allow /* guru */ functions unless -g is active.
1972 if (!session
.guru_mode
&& e
->code
.find ("/* guru */") != string::npos
)
1973 throw semantic_error ("embedded expression may not be used unless -g is specified",
1976 // We want to elide embedded-C functions when possible. For
1977 // example, each $target variable access is expanded to an
1978 // embedded-C function call. Yet, for safety reasons, we should
1979 // presume that embedded-C functions have intentional side-effects.
1981 // To tell these two types of functions apart, we apply a
1982 // Kludge(tm): we look for a magic string within the function body.
1983 // $target variables as rvalues will have this; lvalues won't.
1984 // Also, explicit side-effect-free tapset functions will have this.
1986 if (e
->code
.find ("/* pure */") != string::npos
)
1989 embedded_seen
= true;
1994 varuse_collecting_visitor::visit_target_symbol (target_symbol
*e
)
1996 // Still-unresolved target symbol assignments get treated as
1997 // generating side-effects like embedded-C, to prevent premature
1998 // elision and later error message suppression (PR5516). rvalue use
1999 // of unresolved target symbols is OTOH not considered a side-effect.
2001 if (is_active_lvalue (e
))
2002 embedded_seen
= true;
2004 functioncall_traversing_visitor::visit_target_symbol (e
);
2008 varuse_collecting_visitor::visit_cast_op (cast_op
*e
)
2010 // As with target_symbols, unresolved cast assignments need to preserved
2011 // for later error handling.
2012 if (is_active_lvalue (e
))
2013 embedded_seen
= true;
2015 functioncall_traversing_visitor::visit_cast_op (e
);
2019 varuse_collecting_visitor::visit_defined_op (defined_op
*e
)
2022 functioncall_traversing_visitor::visit_defined_op (e
);
2026 varuse_collecting_visitor::visit_entry_op (entry_op
*e
)
2029 functioncall_traversing_visitor::visit_entry_op (e
);
2034 varuse_collecting_visitor::visit_print_format (print_format
* e
)
2036 // NB: Instead of being top-level statements, "print" and "printf"
2037 // are implemented as statement-expressions containing a
2038 // print_format. They have side-effects, but not via the
2039 // embedded-code detection method above.
2041 // But sprint and sprintf don't have side-effects.
2043 if (e
->print_to_stream
)
2044 embedded_seen
= true; // a proxy for "has unknown side-effects"
2046 functioncall_traversing_visitor::visit_print_format (e
);
2051 varuse_collecting_visitor::visit_assignment (assignment
*e
)
2053 if (e
->op
== "=" || e
->op
== "<<<") // pure writes
2055 expression
* last_lvalue
= current_lvalue
;
2056 current_lvalue
= e
->left
; // leave a mark for ::visit_symbol
2057 functioncall_traversing_visitor::visit_assignment (e
);
2058 current_lvalue
= last_lvalue
;
2060 else // read-modify-writes
2062 expression
* last_lrvalue
= current_lrvalue
;
2063 current_lrvalue
= e
->left
; // leave a mark for ::visit_symbol
2064 functioncall_traversing_visitor::visit_assignment (e
);
2065 current_lrvalue
= last_lrvalue
;
2070 varuse_collecting_visitor::visit_symbol (symbol
*e
)
2072 if (e
->referent
== 0)
2073 throw semantic_error ("symbol without referent", e
->tok
);
2075 // We could handle initialized globals by marking them as "written".
2076 // However, this current visitor may be called for a function or
2077 // probe body, from the point of view of which this global is
2078 // already initialized, so not written.
2080 if (e->referent->init)
2081 written.insert (e->referent);
2084 if (current_lvalue
== e
|| current_lrvalue
== e
)
2086 written
.insert (e
->referent
);
2087 // clog << "write ";
2089 if (current_lvalue
!= e
|| current_lrvalue
== e
)
2091 read
.insert (e
->referent
);
2094 // clog << *e->tok << endl;
2097 // NB: stat_op need not be overridden, since it will get to
2098 // visit_symbol and only as a possible rvalue.
2102 varuse_collecting_visitor::visit_arrayindex (arrayindex
*e
)
2104 // Hooking this callback is necessary because of the hacky
2105 // statistics representation. For the expression "i[4] = 5", the
2106 // incoming lvalue will point to this arrayindex. However, the
2107 // symbol corresponding to the "i[4]" is multiply inherited with
2108 // arrayindex. If the symbol base part of this object is not at
2109 // offset 0, then static_cast<symbol*>(e) may result in a different
2110 // address, and not match lvalue by number when we recurse that way.
2111 // So we explicitly override the incoming lvalue/lrvalue values to
2112 // point at the embedded objects' actual base addresses.
2114 expression
* last_lrvalue
= current_lrvalue
;
2115 expression
* last_lvalue
= current_lvalue
;
2117 symbol
*array
= NULL
;
2118 hist_op
*hist
= NULL
;
2119 classify_indexable(e
->base
, array
, hist
);
2123 if (current_lrvalue
== e
) current_lrvalue
= array
;
2124 if (current_lvalue
== e
) current_lvalue
= array
;
2125 functioncall_traversing_visitor::visit_arrayindex (e
);
2129 if (current_lrvalue
== e
) current_lrvalue
= hist
->stat
;
2130 if (current_lvalue
== e
) current_lvalue
= hist
->stat
;
2131 functioncall_traversing_visitor::visit_arrayindex (e
);
2134 current_lrvalue
= last_lrvalue
;
2135 current_lvalue
= last_lvalue
;
2140 varuse_collecting_visitor::visit_pre_crement (pre_crement
*e
)
2142 expression
* last_lrvalue
= current_lrvalue
;
2143 current_lrvalue
= e
->operand
; // leave a mark for ::visit_symbol
2144 functioncall_traversing_visitor::visit_pre_crement (e
);
2145 current_lrvalue
= last_lrvalue
;
2149 varuse_collecting_visitor::visit_post_crement (post_crement
*e
)
2151 expression
* last_lrvalue
= current_lrvalue
;
2152 current_lrvalue
= e
->operand
; // leave a mark for ::visit_symbol
2153 functioncall_traversing_visitor::visit_post_crement (e
);
2154 current_lrvalue
= last_lrvalue
;
2158 varuse_collecting_visitor::visit_foreach_loop (foreach_loop
* s
)
2160 // NB: we duplicate so don't bother call
2161 // functioncall_traversing_visitor::visit_foreach_loop (s);
2163 symbol
*array
= NULL
;
2164 hist_op
*hist
= NULL
;
2165 classify_indexable (s
->base
, array
, hist
);
2171 // If the collection is sorted, imply a "write" access to the
2172 // array in addition to the "read" one already noted above.
2173 if (s
->sort_direction
)
2175 symbol
*array
= NULL
;
2176 hist_op
*hist
= NULL
;
2177 classify_indexable (s
->base
, array
, hist
);
2178 if (array
) this->written
.insert (array
->referent
);
2179 // XXX: Can hist_op iterations be sorted?
2182 // NB: don't forget to visit the index expressions, which are lvalues.
2183 for (unsigned i
=0; i
<s
->indexes
.size(); i
++)
2185 expression
* last_lvalue
= current_lvalue
;
2186 current_lvalue
= s
->indexes
[i
]; // leave a mark for ::visit_symbol
2187 s
->indexes
[i
]->visit (this);
2188 current_lvalue
= last_lvalue
;
2191 // The value is an lvalue too
2194 expression
* last_lvalue
= current_lvalue
;
2195 current_lvalue
= s
->value
; // leave a mark for ::visit_symbol
2196 s
->value
->visit (this);
2197 current_lvalue
= last_lvalue
;
2201 s
->limit
->visit (this);
2203 s
->block
->visit (this);
2208 varuse_collecting_visitor::visit_delete_statement (delete_statement
* s
)
2210 // Ideally, this would be treated like an assignment: a plain write
2211 // to the underlying value ("lvalue"). XXX: However, the
2212 // optimization pass is not smart enough to remove an unneeded
2213 // "delete" yet, so we pose more like a *crement ("lrvalue"). This
2214 // should protect the underlying value from optimizional mischief.
2215 expression
* last_lrvalue
= current_lrvalue
;
2216 current_lrvalue
= s
->value
; // leave a mark for ::visit_symbol
2217 functioncall_traversing_visitor::visit_delete_statement (s
);
2218 current_lrvalue
= last_lrvalue
;
2222 varuse_collecting_visitor::side_effect_free ()
2224 return (written
.empty() && !embedded_seen
);
2229 varuse_collecting_visitor::side_effect_free_wrt (const set
<vardecl
*>& vars
)
2231 // A looser notion of side-effect-freeness with respect to a given
2232 // list of variables.
2234 // That's useful because the written list may consist of local
2235 // variables of called functions. But visible side-effects only
2236 // occur if the client's locals, or any globals are written-to.
2238 set
<vardecl
*> intersection
;
2239 insert_iterator
<set
<vardecl
*> > int_it (intersection
, intersection
.begin());
2240 set_intersection (written
.begin(), written
.end(),
2241 vars
.begin(), vars
.end(),
2244 return (intersection
.empty() && !embedded_seen
);
2250 // ------------------------------------------------------------------------
2253 throwing_visitor::throwing_visitor (const std::string
& m
): msg (m
) {}
2254 throwing_visitor::throwing_visitor (): msg ("invalid element") {}
2258 throwing_visitor::throwone (const token
* t
)
2260 throw semantic_error (msg
, t
);
2264 throwing_visitor::visit_block (block
* s
)
2270 throwing_visitor::visit_try_block (try_block
* s
)
2277 throwing_visitor::visit_embeddedcode (embeddedcode
* s
)
2283 throwing_visitor::visit_null_statement (null_statement
* s
)
2289 throwing_visitor::visit_expr_statement (expr_statement
* s
)
2295 throwing_visitor::visit_if_statement (if_statement
* s
)
2301 throwing_visitor::visit_for_loop (for_loop
* s
)
2307 throwing_visitor::visit_foreach_loop (foreach_loop
* s
)
2313 throwing_visitor::visit_return_statement (return_statement
* s
)
2319 throwing_visitor::visit_delete_statement (delete_statement
* s
)
2325 throwing_visitor::visit_next_statement (next_statement
* s
)
2331 throwing_visitor::visit_break_statement (break_statement
* s
)
2337 throwing_visitor::visit_continue_statement (continue_statement
* s
)
2343 throwing_visitor::visit_literal_string (literal_string
* e
)
2349 throwing_visitor::visit_literal_number (literal_number
* e
)
2355 throwing_visitor::visit_embedded_expr (embedded_expr
* e
)
2361 throwing_visitor::visit_binary_expression (binary_expression
* e
)
2367 throwing_visitor::visit_unary_expression (unary_expression
* e
)
2373 throwing_visitor::visit_pre_crement (pre_crement
* e
)
2379 throwing_visitor::visit_post_crement (post_crement
* e
)
2386 throwing_visitor::visit_logical_or_expr (logical_or_expr
* e
)
2392 throwing_visitor::visit_logical_and_expr (logical_and_expr
* e
)
2398 throwing_visitor::visit_array_in (array_in
* e
)
2404 throwing_visitor::visit_comparison (comparison
* e
)
2410 throwing_visitor::visit_concatenation (concatenation
* e
)
2416 throwing_visitor::visit_ternary_expression (ternary_expression
* e
)
2422 throwing_visitor::visit_assignment (assignment
* e
)
2428 throwing_visitor::visit_symbol (symbol
* e
)
2434 throwing_visitor::visit_target_symbol (target_symbol
* e
)
2440 throwing_visitor::visit_cast_op (cast_op
* e
)
2446 throwing_visitor::visit_defined_op (defined_op
* e
)
2452 throwing_visitor::visit_entry_op (entry_op
* e
)
2459 throwing_visitor::visit_arrayindex (arrayindex
* e
)
2465 throwing_visitor::visit_functioncall (functioncall
* e
)
2471 throwing_visitor::visit_print_format (print_format
* e
)
2477 throwing_visitor::visit_stat_op (stat_op
* e
)
2483 throwing_visitor::visit_hist_op (hist_op
* e
)
2489 // ------------------------------------------------------------------------
2493 update_visitor::visit_block (block
* s
)
2495 for (unsigned i
= 0; i
< s
->statements
.size(); ++i
)
2496 replace (s
->statements
[i
]);
2501 update_visitor::visit_try_block (try_block
* s
)
2503 replace (s
->try_block
);
2504 replace (s
->catch_error_var
);
2505 replace (s
->catch_block
);
2510 update_visitor::visit_embeddedcode (embeddedcode
* s
)
2516 update_visitor::visit_null_statement (null_statement
* s
)
2522 update_visitor::visit_expr_statement (expr_statement
* s
)
2529 update_visitor::visit_if_statement (if_statement
* s
)
2531 replace (s
->condition
);
2532 replace (s
->thenblock
);
2533 replace (s
->elseblock
);
2538 update_visitor::visit_for_loop (for_loop
* s
)
2548 update_visitor::visit_foreach_loop (foreach_loop
* s
)
2550 for (unsigned i
= 0; i
< s
->indexes
.size(); ++i
)
2551 replace (s
->indexes
[i
]);
2560 update_visitor::visit_return_statement (return_statement
* s
)
2567 update_visitor::visit_delete_statement (delete_statement
* s
)
2574 update_visitor::visit_next_statement (next_statement
* s
)
2580 update_visitor::visit_break_statement (break_statement
* s
)
2586 update_visitor::visit_continue_statement (continue_statement
* s
)
2592 update_visitor::visit_literal_string (literal_string
* e
)
2598 update_visitor::visit_literal_number (literal_number
* e
)
2604 update_visitor::visit_embedded_expr (embedded_expr
* e
)
2610 update_visitor::visit_binary_expression (binary_expression
* e
)
2618 update_visitor::visit_unary_expression (unary_expression
* e
)
2620 replace (e
->operand
);
2625 update_visitor::visit_pre_crement (pre_crement
* e
)
2627 replace (e
->operand
);
2632 update_visitor::visit_post_crement (post_crement
* e
)
2634 replace (e
->operand
);
2640 update_visitor::visit_logical_or_expr (logical_or_expr
* e
)
2648 update_visitor::visit_logical_and_expr (logical_and_expr
* e
)
2656 update_visitor::visit_array_in (array_in
* e
)
2658 replace (e
->operand
);
2663 update_visitor::visit_comparison (comparison
* e
)
2671 update_visitor::visit_concatenation (concatenation
* e
)
2679 update_visitor::visit_ternary_expression (ternary_expression
* e
)
2682 replace (e
->truevalue
);
2683 replace (e
->falsevalue
);
2688 update_visitor::visit_assignment (assignment
* e
)
2696 update_visitor::visit_symbol (symbol
* e
)
2702 update_visitor::visit_target_symbol (target_symbol
* e
)
2704 e
->visit_components (this);
2709 update_visitor::visit_cast_op (cast_op
* e
)
2711 replace (e
->operand
);
2712 e
->visit_components (this);
2717 update_visitor::visit_defined_op (defined_op
* e
)
2719 replace (e
->operand
);
2724 update_visitor::visit_entry_op (entry_op
* e
)
2726 replace (e
->operand
);
2731 update_visitor::visit_arrayindex (arrayindex
* e
)
2734 for (unsigned i
= 0; i
< e
->indexes
.size(); ++i
)
2735 replace (e
->indexes
[i
]);
2740 update_visitor::visit_functioncall (functioncall
* e
)
2742 for (unsigned i
= 0; i
< e
->args
.size(); ++i
)
2743 replace (e
->args
[i
]);
2748 update_visitor::visit_print_format (print_format
* e
)
2750 for (unsigned i
= 0; i
< e
->args
.size(); ++i
)
2751 replace (e
->args
[i
]);
2757 update_visitor::visit_stat_op (stat_op
* e
)
2764 update_visitor::visit_hist_op (hist_op
* e
)
2770 template <> indexable
*
2771 update_visitor::require
<indexable
> (indexable
* src
, bool clearok
)
2773 indexable
*dst
= NULL
;
2776 symbol
*array_src
=NULL
;
2777 hist_op
*hist_src
=NULL
;
2779 classify_indexable(src
, array_src
, hist_src
);
2782 dst
= require (array_src
);
2784 dst
= require (hist_src
);
2785 assert(clearok
|| dst
);
2791 // ------------------------------------------------------------------------
2795 deep_copy_visitor::visit_block (block
* s
)
2797 update_visitor::visit_block(new block(*s
));
2801 deep_copy_visitor::visit_try_block (try_block
* s
)
2803 update_visitor::visit_try_block(new try_block(*s
));
2807 deep_copy_visitor::visit_embeddedcode (embeddedcode
* s
)
2809 update_visitor::visit_embeddedcode(new embeddedcode(*s
));
2813 deep_copy_visitor::visit_null_statement (null_statement
* s
)
2815 update_visitor::visit_null_statement(new null_statement(*s
));
2819 deep_copy_visitor::visit_expr_statement (expr_statement
* s
)
2821 update_visitor::visit_expr_statement(new expr_statement(*s
));
2825 deep_copy_visitor::visit_if_statement (if_statement
* s
)
2827 update_visitor::visit_if_statement(new if_statement(*s
));
2831 deep_copy_visitor::visit_for_loop (for_loop
* s
)
2833 update_visitor::visit_for_loop(new for_loop(*s
));
2837 deep_copy_visitor::visit_foreach_loop (foreach_loop
* s
)
2839 update_visitor::visit_foreach_loop(new foreach_loop(*s
));
2843 deep_copy_visitor::visit_return_statement (return_statement
* s
)
2845 update_visitor::visit_return_statement(new return_statement(*s
));
2849 deep_copy_visitor::visit_delete_statement (delete_statement
* s
)
2851 update_visitor::visit_delete_statement(new delete_statement(*s
));
2855 deep_copy_visitor::visit_next_statement (next_statement
* s
)
2857 update_visitor::visit_next_statement(new next_statement(*s
));
2861 deep_copy_visitor::visit_break_statement (break_statement
* s
)
2863 update_visitor::visit_break_statement(new break_statement(*s
));
2867 deep_copy_visitor::visit_continue_statement (continue_statement
* s
)
2869 update_visitor::visit_continue_statement(new continue_statement(*s
));
2873 deep_copy_visitor::visit_literal_string (literal_string
* e
)
2875 update_visitor::visit_literal_string(new literal_string(*e
));
2879 deep_copy_visitor::visit_literal_number (literal_number
* e
)
2881 update_visitor::visit_literal_number(new literal_number(*e
));
2885 deep_copy_visitor::visit_embedded_expr (embedded_expr
* e
)
2887 update_visitor::visit_embedded_expr(new embedded_expr(*e
));
2891 deep_copy_visitor::visit_binary_expression (binary_expression
* e
)
2893 update_visitor::visit_binary_expression(new binary_expression(*e
));
2897 deep_copy_visitor::visit_unary_expression (unary_expression
* e
)
2899 update_visitor::visit_unary_expression(new unary_expression(*e
));
2903 deep_copy_visitor::visit_pre_crement (pre_crement
* e
)
2905 update_visitor::visit_pre_crement(new pre_crement(*e
));
2909 deep_copy_visitor::visit_post_crement (post_crement
* e
)
2911 update_visitor::visit_post_crement(new post_crement(*e
));
2916 deep_copy_visitor::visit_logical_or_expr (logical_or_expr
* e
)
2918 update_visitor::visit_logical_or_expr(new logical_or_expr(*e
));
2922 deep_copy_visitor::visit_logical_and_expr (logical_and_expr
* e
)
2924 update_visitor::visit_logical_and_expr(new logical_and_expr(*e
));
2928 deep_copy_visitor::visit_array_in (array_in
* e
)
2930 update_visitor::visit_array_in(new array_in(*e
));
2934 deep_copy_visitor::visit_comparison (comparison
* e
)
2936 update_visitor::visit_comparison(new comparison(*e
));
2940 deep_copy_visitor::visit_concatenation (concatenation
* e
)
2942 update_visitor::visit_concatenation(new concatenation(*e
));
2946 deep_copy_visitor::visit_ternary_expression (ternary_expression
* e
)
2948 update_visitor::visit_ternary_expression(new ternary_expression(*e
));
2952 deep_copy_visitor::visit_assignment (assignment
* e
)
2954 update_visitor::visit_assignment(new assignment(*e
));
2958 deep_copy_visitor::visit_symbol (symbol
* e
)
2960 symbol
* n
= new symbol(*e
);
2961 n
->referent
= NULL
; // don't copy!
2962 update_visitor::visit_symbol(n
);
2966 deep_copy_visitor::visit_target_symbol (target_symbol
* e
)
2968 target_symbol
* n
= new target_symbol(*e
);
2969 n
->referent
= NULL
; // don't copy!
2970 update_visitor::visit_target_symbol(n
);
2974 deep_copy_visitor::visit_cast_op (cast_op
* e
)
2976 update_visitor::visit_cast_op(new cast_op(*e
));
2980 deep_copy_visitor::visit_defined_op (defined_op
* e
)
2982 update_visitor::visit_defined_op(new defined_op(*e
));
2986 deep_copy_visitor::visit_entry_op (entry_op
* e
)
2988 update_visitor::visit_entry_op(new entry_op(*e
));
2992 deep_copy_visitor::visit_arrayindex (arrayindex
* e
)
2994 update_visitor::visit_arrayindex(new arrayindex(*e
));
2998 deep_copy_visitor::visit_functioncall (functioncall
* e
)
3000 functioncall
* n
= new functioncall(*e
);
3001 n
->referent
= NULL
; // don't copy!
3002 update_visitor::visit_functioncall(n
);
3006 deep_copy_visitor::visit_print_format (print_format
* e
)
3008 update_visitor::visit_print_format(new print_format(*e
));
3012 deep_copy_visitor::visit_stat_op (stat_op
* e
)
3014 update_visitor::visit_stat_op(new stat_op(*e
));
3018 deep_copy_visitor::visit_hist_op (hist_op
* e
)
3020 update_visitor::visit_hist_op(new hist_op(*e
));
3023 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */