diff options
author | graydon <graydon> | 2005-10-20 22:11:33 +0000 |
---|---|---|
committer | graydon <graydon> | 2005-10-20 22:11:33 +0000 |
commit | 57b73400d06052b179335059c2f440350fd28c99 (patch) | |
tree | 1fe125be909fd23d7591f63f96dd66018400b1ac /elaborate.cxx | |
parent | f6f492468e2dfec286e3611e3e38ad070c91ae9d (diff) | |
download | systemtap-steved-57b73400d06052b179335059c2f440350fd28c99.tar.gz systemtap-steved-57b73400d06052b179335059c2f440350fd28c99.tar.xz systemtap-steved-57b73400d06052b179335059c2f440350fd28c99.zip |
2005-10-20 Graydon Hoare <graydon@redhat.com>
PR 917 (incomplete)
* staptree.h (struct statistic_decl): New struct.
(stapfile::stat_decls): New member.
* parse.h, parse.cxx
(parser::expect_known): Fix typo.
(parser::expect_number): New method.
(parser::parse_global): Parse global statistic_decls.
* elaborate.h (systemtap_session::stat_decls): New member.
* elaborate.cxx (semantic_pass_symbols): Copy per-file stat_decls
to session-wide.
(typeresolution_info::visit_assignment): Detect some semantic stats
errors in type resolution pass.
* translate.cxx (var::sd): New private member.
(var::var): Initialize it.
(var::sdecl): New accessor.
(var::init): Handle stats values.
(mapvar::mapvar): Pass through statistic_decl to var ctor.
(mapvar::get): Test for long explicitly.
(mapvar::set): Likewise.
(mapvar::init): Handle stats values.
(c_unparser::emit_common_header): Remove typedef of stats_t,
include stat.c when necessary.
(mapvar::key_typename): Typo.
(c_unparser::emit_map_type_instantiations): Thinko: value_typename not key_typename.
(c_unparser::c_typename): Implementation typename is "Stat", not "stats_t".
(c_unparser::c_assign): Fix bad error message.
(c_unparser_assignment::c_assignop): Handle operator <<<.
(c_unparser::getvar): Feed session statistic_decl into var.
(c_unparser::getmap): Likewise.
(c_unparser::visit_assignment): Handle operator <<<.
(c_tmpcounter_assignment::visit_symbol): Derive type from rvalue when present.
(c_unparser_assignment::visit_symbol)
(c_tmpcounter_assignment::visit_arrayindex)
(c_unparser_assignment::load_map_indices): Likewise.
(c_unparser::visit_arrayindex): Likewise, and Prohibit statistic rvalues.
(c_unparser_assignment::visit_arrayindex): Handle operator <<<.
* testsuite/semko/twentyfour.stp:
* testsuite/semko/twentyfive.stp:
* testsuite/semko/twentysix.stp:
* testsuite/semko/twentyseven.stp:
* testsuite/semko/twentyeight.stp:
* testsuite/semko/twentynine.stp:
* testsuite/semko/thirty.stp:
* testsuite/semko/thirtyone.stp: New tests for prohibited statistic contexts.
* testsuite/buildok/twentytwo.stp: New test for legal statistic contexts.
Diffstat (limited to 'elaborate.cxx')
-rw-r--r-- | elaborate.cxx | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/elaborate.cxx b/elaborate.cxx index 06f6d01c..890e9dc0 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -608,6 +608,23 @@ semantic_pass_symbols (systemtap_session& s) for (unsigned i=0; i<dome->embeds.size(); i++) s.embeds.push_back (dome->embeds[i]); + for (std::map<std::string, statistic_decl>::const_iterator i = + dome->stat_decls.begin(); i != dome->stat_decls.end(); ++i) + { + try + { + + if (s.stat_decls.find(i->first) != s.stat_decls.end()) + throw semantic_error("multiple statistic declarations for " + i->first); + s.stat_decls.insert(std::make_pair(i->first, + i->second)); + } + catch (const semantic_error& e) + { + s.print_error (e); + } + } + // Pass 2: process functions for (unsigned i=0; i<dome->functions.size(); i++) @@ -1130,12 +1147,20 @@ typeresolution_info::visit_assignment (assignment *e) e->left->visit (this); t = pe_long; e->right->visit (this); - if (e->type == pe_unknown) + if (e->type == pe_unknown || + e->type == pe_stats) { e->type = pe_long; resolved (e->tok, e->type); } } + + else if (e->left->type == pe_stats) + invalid (e->left->tok, e->left->type); + + else if (e->right->type == pe_stats) + invalid (e->right->tok, e->right->type); + else if (e->op == "+=" || // numeric only e->op == "-=" || e->op == "*=" || |