summaryrefslogtreecommitdiffstats
path: root/staptree.cxx
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-10-13 16:57:38 -0700
committerJosh Stone <jistone@redhat.com>2009-10-13 16:57:38 -0700
commitd5e178c1d6eb0e7c1a317b925687050aa1cb6c1b (patch)
tree0d46cafccc4518b81b6462b59333dca0fe5eca63 /staptree.cxx
parent42b2e52658603d3e1384a909ad816d05529fc1d3 (diff)
downloadsystemtap-steved-d5e178c1d6eb0e7c1a317b925687050aa1cb6c1b.tar.gz
systemtap-steved-d5e178c1d6eb0e7c1a317b925687050aa1cb6c1b.tar.xz
systemtap-steved-d5e178c1d6eb0e7c1a317b925687050aa1cb6c1b.zip
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.
Diffstat (limited to 'staptree.cxx')
-rw-r--r--staptree.cxx66
1 files changed, 35 insertions, 31 deletions
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;
}