From d02548c0925a02dd0af64a9dc13cce9e84d87b4f Mon Sep 17 00:00:00 2001 From: graydon Date: Mon, 14 Nov 2005 04:39:47 +0000 Subject: 2005-11-13 Graydon Hoare * staptree.h (struct indexable): New struct. (classify_indexable): New function. (classify_const_indexable): New function. (struct symbol): Implement indexable. (struct arrayindex): Take indexable as base. (struct foreach_loop): Take indexable as base. (struct print_format): New struct. (enum stat_component_type): New enum. (struct stat_op): New struct. (enum historgram_type): New enum. (struct hist_op): New struct. (struct visitor) (struct traversing_visitor) (struct throwing_visitor) (struct deep_copy_visitor): Add new visitor methods. (require): Specialize for indexable*. * staptree.cxx (print_format::*) (stat_op::*) (hist_op::*) (indexable::*) (traversing_visitor::*) (throwing_visitor::*) (deep_copy_visitor::*) (classify_indexable) (classify_const_indexable): Implement (deep_copy_visitor::*): Update to use indexables. * parse.h (parser::parse_indexable): New method. (parser::parse_hist_op_or_bare_name): New method. * parse.cxx (lexer::scan): Accept @ in identifiers. (parser::parse_array_in) (parser::parse_foreach_loop): Call parse_indexable. (parser::parse_hist_op_or_bare_name): Implement. (parser::parse_indexable): Implement. (parser::parse_symbol): Accept printf, stat_ops, hist_ops. * elaborate.h (struct typeresolution_info): Add methods for visiting print_format, stat_op, hist_op. * elaborate.cxx (symbol_fetcher): New class. (get_symbol_within_expression): New function. (get_symbol_within_indexable): New function. (mutated_var_collector): Replace mutated_map_collector. (no_var_mutation_during_iteration_check): Replace no_map_mutation_during_iteration_check. (semantic_pass_vars): Replace semantic_pass_maps. (semantic_pass): Update call accordingly. (symresolution_info::*) Add new visitors, teach about indexables (typeresolution_info::*) Likewise. * translate.cxx (c_unparser::getiter): Take symbol, not foreach_loop. (c_unparser::*) Add new visitors, teach about indexables. (c_tmpcounter::*) (delete_statement_operand_visitor::visit_arrayindex) (c_tmpcounter_assignment::*) (c_unparser_assignment::*): Likewise. (hist_op_downcaster): New struct. (expression_is_hist_op): New function. * testsuite/buildok/printf.stp: New test for print_format. --- testsuite/buildok/printf.stp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 testsuite/buildok/printf.stp (limited to 'testsuite') diff --git a/testsuite/buildok/printf.stp b/testsuite/buildok/printf.stp new file mode 100755 index 00000000..4fd14ad6 --- /dev/null +++ b/testsuite/buildok/printf.stp @@ -0,0 +1,29 @@ +#! stap -p4 + +# test the translatability of the formatted printing operators + +function foo() { + return 10 +} + +probe begin +{ + x = sprintf("take %d steps forward, %d steps back\n", 3, 2) + printf("take %d steps forward, %d steps back\n", 3, 2) + printf("take %d steps forward, %d steps back\n", 3+1, 2*2) + + bob = "bob" + alice = "alice" + print(bob) + print(alice) + print("hello") + print(10) + printf("%s phoned %s %4.4x times\n", bob, alice, 3456) + printf("%s phoned %s %+4d times\n", bob . alice, alice, 3456) + printf("%s phoned %s %.4x times\n", bob, alice . bob, 3456) + printf("%s phoned %s %-i times\n", sprintf("%s%s", bob, bob), sprint(alice), 3456) + printf("%s except after %s\n", + sprintf("%s before %s", + sprint(1), sprint(3)), + sprint("C")) +} -- cgit