From ce10591c2048cc3c5e4979b15e14fecc2a384968 Mon Sep 17 00:00:00 2001 From: fche Date: Mon, 30 May 2005 21:28:44 +0000 Subject: 2005-05-30 Frank Ch. Eigler More fully parse & elaborate "expr in array" construct. * staptree.h (array_in): Make this unary. Update .cxx to match. * parse.cxx (parse_array_in): Rewrite. (parse_symbol_plain): Removed. Update .h to match. * elaborate.cxx (typeresolution_info::visit_array_in): New function. (find_array): Tentatively, accept arity=0. * translate.cxx (c_unparser::c_assign): New functions to eliminate much ugly duplication. Use throughout. (visit_symbol): Correct function formal argument search. (c_tmpcounter*::visit): Add missing recursion in several functions. * testsuite/*: Add new tests for array-in construct. Add the first "transok" test. * Makefile.am: Add transok tests. * Makefile.in: Regenerated. --- elaborate.cxx | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'elaborate.cxx') diff --git a/elaborate.cxx b/elaborate.cxx index cac773bf..02c81a2d 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -220,7 +220,8 @@ symresolution_info::visit_symbol (symbol* e) else if (current_probe) current_probe->locals.push_back (v); else - throw semantic_error ("no current probe/function for unresolved scalar", e->tok); + // must not happen + throw semantic_error ("no current probe/function", e->tok); e->referent = v; } } @@ -340,10 +341,11 @@ symresolution_info::find_array (const string& name, unsigned arity) // search processed globals for (unsigned i=0; iname == name) - if ((session.globals[i]->arity == (int) arity) || + if ((arity > 0 && (session.globals[i]->arity == (int) arity)) || session.globals[i]->arity < 0) { - session.globals[i]->set_arity (arity); + if (arity > 0) + session.globals[i]->set_arity (arity); return session.globals[i]; } @@ -353,10 +355,11 @@ symresolution_info::find_array (const string& name, unsigned arity) stapfile* f = session.library_files[i]; for (unsigned j=0; jglobals.size(); j++) if (f->globals[j]->name == name) - if ((f->globals[j]->arity == (int) arity) || + if ((arity > 0 && (f->globals[j]->arity == (int) arity)) || f->globals[j]->arity < 0) { - f->globals[j]->set_arity (arity); + if (arity > 0) + f->globals[j]->set_arity (arity); // put library into the queue if not already there if (0) // (session.verbose_resolution) @@ -925,8 +928,20 @@ typeresolution_info::visit_delete_statement (delete_statement* e) void typeresolution_info::visit_array_in (array_in* e) { - // XXX: not yet supported - unresolved (e->tok); + // all unary operators only work on numerics + exp_type t1 = t; + t = pe_unknown; // array value can be anything + e->operand->visit (this); + + if (t1 == pe_unknown && e->type != pe_unknown) + ; // already resolved + else if (t1 == pe_string || t1 == pe_stats) + mismatch (e->tok, t1, pe_long); + else if (e->type == pe_unknown) + { + e->type = pe_long; + resolved (e->tok, e->type); + } } -- cgit