diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | elaborate.cxx | 30 | ||||
-rw-r--r-- | tapsets.cxx | 49 | ||||
-rw-r--r-- | tapsets.h | 17 | ||||
-rw-r--r-- | translate.cxx | 69 |
5 files changed, 27 insertions, 144 deletions
@@ -1,3 +1,9 @@ +2005-07-26 Graydon Hoare <graydon@redhat.com> + + * elaborate.cxx: Revert builtin-function code. + * translate.cxx: Likewise. + * tapsets.{h,cxx}: Likewise. + 2005-07-26 Martin Hunt <hunt@redhat.com> * buildrun.cxx (compile_pass): Add -Wno-unused to CFLAGS because diff --git a/elaborate.cxx b/elaborate.cxx index e7d9f967..f1f0cede 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -591,12 +591,9 @@ semantic_pass_symbols (systemtap_session& s) try { - if (fd->body) - { - sym.current_function = fd; - sym.current_probe = 0; - fd->body->visit (& sym); - } + sym.current_function = fd; + sym.current_probe = 0; + fd->body->visit (& sym); } catch (const semantic_error& e) { @@ -945,18 +942,15 @@ semantic_pass_types (systemtap_session& s) for (unsigned j=0; j<s.functions.size(); j++) { functiondecl* fn = s.functions[j]; - if (fn->body) - { - ti.current_function = fn; - ti.t = pe_unknown; - fn->body->visit (& ti); - // NB: we don't have to assert a known type for - // functions here, to permit a "void" function. - // The translator phase will omit the "retvalue". - // - // if (fn->type == pe_unknown) - // ti.unresolved (fn->tok); - } + ti.current_function = fn; + ti.t = pe_unknown; + fn->body->visit (& ti); + // NB: we don't have to assert a known type for + // functions here, to permit a "void" function. + // The translator phase will omit the "retvalue". + // + // if (fn->type == pe_unknown) + // ti.unresolved (fn->tok); } for (unsigned j=0; j<s.probes.size(); j++) diff --git a/tapsets.cxx b/tapsets.cxx index 6eff619f..43d50fb5 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -1210,50 +1210,6 @@ dwarf_builder::build(systemtap_session & sess, #endif /* HAVE_ELFUTILS_LIBDWFL_H */ -// ------------------------------------------------------------------------ -// Built-in function support class -// ------------------------------------------------------------------------ - -token * -builtin_function::id(string const & name) -{ - token *t = new token; - t->type = tok_identifier; - t->content = name; - t->location.file = "<builtin>"; - return t; -} - -builtin_function::builtin_function(exp_type ty, string const & name) -{ - f = new functiondecl; - f->tok = id(name); - f->name = name; - f->type = ty; - f->body = NULL; -} - -builtin_function & -builtin_function::arg(exp_type e, string const & name) -{ - vardecl *arg = new vardecl; - arg->name = name; - arg->tok = id(name); - arg->type = e; - f->formal_args.push_back(arg); - return *this; -} - -void -builtin_function::bind(systemtap_session & s) -{ - for (unsigned i = 0; i < s.functions.size(); ++i) - { - if (s.functions[i]->name == f->name) - throw semantic_error("builtin function " + f->name + " registered twice"); - } - s.functions.push_back(f); -} // ------------------------------------------------------------------------ // Standard tapset registry. @@ -1269,9 +1225,4 @@ register_standard_tapsets(systemtap_session & s) #ifdef HAVE_ELFUTILS_LIBDWFL_H dwarf_derived_probe::register_patterns(s.pattern_root); #endif /* HAVE_ELFUTILS_LIBDWFL_H */ - - // Some standard builtins - builtin_function(pe_long, "printk").arg(pe_string, "message").bind(s); - builtin_function(pe_long, "log").arg(pe_string, "message").bind(s); - builtin_function(pe_long, "warn").arg(pe_string, "message").bind(s); } @@ -14,23 +14,6 @@ #include "elaborate.h" -// Helper class for describing builtin functions. Calls to builtins -// are typechecked and emitted, but the builtin definitions are *not* -// emitted by the translator (in fact, they have no definitions in -// systemtap language); they are assumed to exist outside the -// translator, in the runtime library. - -class -builtin_function -{ - functiondecl *f; - token *id(std::string const & name); - public: - builtin_function(exp_type e, std::string const & name); - builtin_function & arg(exp_type e, std::string const & name); - void bind(systemtap_session & sess); -}; - void register_standard_tapsets(systemtap_session & sess); diff --git a/translate.cxx b/translate.cxx index e4bf28b9..3623799c 100644 --- a/translate.cxx +++ b/translate.cxx @@ -52,7 +52,6 @@ struct c_unparser: public unparser, public visitor ~c_unparser () {} void emit_map_type_instantiations (); - void emit_builtin_function_symbols (); void emit_common_header (); void emit_global (vardecl* v); void emit_functionsig (functiondecl* v); @@ -204,12 +203,6 @@ struct c_tmpcounter_assignment: }; -struct builtin_collector: public traversing_visitor -{ - set<string> called_builtins; - void visit_functioncall (functioncall* e); -}; - ostream & operator<<(ostream & o, var const & v); class var @@ -491,14 +484,6 @@ translator_output::line () return o; } -// ------------------------------------------------------------------------ - -void -builtin_collector::visit_functioncall(functioncall* e) -{ - if (e->referent && !e->referent->body) - called_builtins.insert(e->referent->name); -} // ------------------------------------------------------------------------ @@ -567,8 +552,7 @@ c_unparser::emit_common_header () << c_varname (v->name) << ";"; } c_tmpcounter ct (this); - if (fd->body) - fd->body->visit (& ct); + fd->body->visit (& ct); if (fd->type == pe_unknown) o->newline() << "/* no return value */"; else @@ -580,8 +564,6 @@ c_unparser::emit_common_header () o->newline(-1) << "} locals [MAXNESTING];"; o->newline(-1) << "} contexts [MAXCONCURRENCY];" << endl; - emit_builtin_function_symbols (); - emit_map_type_instantiations (); } @@ -817,37 +799,6 @@ c_unparser::emit_probe (derived_probe* v, unsigned i) } -void -c_unparser::emit_builtin_function_symbols () -{ - builtin_collector bc; - for (unsigned i=0; i<session->functions.size(); i++) - { - functiondecl* fd = session->functions[i]; - if (fd->body) - fd->body->visit(&bc); - } - for (unsigned i=0; i<session->probes.size(); i++) - { - derived_probe* dp = session->probes[i]; - dp->body->visit(&bc); - } - - for (set<string>::const_iterator i = bc.called_builtins.begin(); - i != bc.called_builtins.end(); ++i) - { - o->newline() << "#define _BUILTIN_FUNCTION_" << *i << "_"; - } - - o->newline() << "#include \"builtin_functions.h\""; - - for (set<string>::const_iterator i = bc.called_builtins.begin(); - i != bc.called_builtins.end(); ++i) - { - o->newline() << "#undef _BUILTIN_FUNCTION_" << *i << "_"; - } -} - void c_unparser::collect_map_index_types(vector<vardecl *> const & vars, set< exp_type > & value_types, @@ -2103,18 +2054,16 @@ translate_pass (systemtap_session& s) } for (unsigned i=0; i<s.functions.size(); i++) - if (s.functions[i]->body) - { - s.op->newline(); - s.up->emit_functionsig (s.functions[i]); - } + { + s.op->newline(); + s.up->emit_functionsig (s.functions[i]); + } for (unsigned i=0; i<s.functions.size(); i++) - if (s.functions[i]->body) - { - s.op->newline(); - s.up->emit_function (s.functions[i]); - } + { + s.op->newline(); + s.up->emit_function (s.functions[i]); + } for (unsigned i=0; i<s.probes.size(); i++) { |