From d5e178c1d6eb0e7c1a317b925687050aa1cb6c1b Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 13 Oct 2009 16:57:38 -0700 Subject: Consolidate print_format creation We almost had a factory in print_format::parse_print, so let's take that the rest of the way. This way we don't have so much duplication in initializing the print flags. * staptree.cxx (print_format::parse_print): Replaced with... (print_format::create): New factory to parse and create print_formats. * elaborate.cxx (add_global_var_display): Use this factory. * parse.cxx (parser::parse_symbol): Ditto. * tapset-mark.cxx (mark_var_expanding_visitor::visit_target_symbol_context): Ditto. * tapset-utrace.cxx (utrace_var_expanding_visitor::visit_target_symbol_arg): Ditto. * tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol_context): Ditto. (tracepoint_var_expanding_visitor::visit_target_symbol_context) Ditto. --- staptree.cxx | 66 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 31 deletions(-) (limited to 'staptree.cxx') diff --git a/staptree.cxx b/staptree.cxx index 090f0bd3..bc552454 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -405,52 +405,56 @@ void functioncall::print (ostream& o) const } -bool -print_format::parse_print(const std::string &name, - bool &stream, bool &format, bool &delim, bool &newline, bool &_char) +print_format* +print_format::create(const token *t) { - const char *n = name.c_str(); + bool stream, format, delim, newline, _char; + const char *n = t->content.c_str(); stream = true; format = delim = newline = _char = false; if (strcmp(n, "print_char") == 0) + _char = true; + else { - _char = true; - return true; - } - - if (*n == 's') - { - stream = false; - ++n; - } + if (*n == 's') + { + stream = false; + ++n; + } - if (0 != strncmp(n, "print", 5)) - return false; - n += 5; + if (0 != strncmp(n, "print", 5)) + return NULL; + n += 5; - if (*n == 'f') - { - format = true; - ++n; - } - else - { - if (*n == 'd') - { - delim = true; + if (*n == 'f') + { + format = true; ++n; } + else + { + if (*n == 'd') + { + delim = true; + ++n; + } - if (*n == 'l' && *(n+1) == 'n') - { - newline = true; - n += 2; + if (*n == 'l' && *(n+1) == 'n') + { + newline = true; + n += 2; + } } + + if (*n != '\0') + return NULL; } - return (*n == '\0'); + print_format *pf = new print_format(stream, format, delim, newline, _char); + pf->tok = t; + return pf; } -- cgit