summaryrefslogtreecommitdiffstats
path: root/elaborate.cxx
diff options
context:
space:
mode:
authorfche <fche>2005-05-30 21:28:44 +0000
committerfche <fche>2005-05-30 21:28:44 +0000
commitce10591c2048cc3c5e4979b15e14fecc2a384968 (patch)
tree09b4a09692e1810809091ad474e35e0b3f752a81 /elaborate.cxx
parent4383d78cedb616af407f35c996c4eff808704ea6 (diff)
downloadsystemtap-steved-ce10591c2048cc3c5e4979b15e14fecc2a384968.tar.gz
systemtap-steved-ce10591c2048cc3c5e4979b15e14fecc2a384968.tar.xz
systemtap-steved-ce10591c2048cc3c5e4979b15e14fecc2a384968.zip
2005-05-30 Frank Ch. Eigler <fche@redhat.com>
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.
Diffstat (limited to 'elaborate.cxx')
-rw-r--r--elaborate.cxx29
1 files changed, 22 insertions, 7 deletions
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; i<session.globals.size(); i++)
if (session.globals[i]->name == 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; j<f->globals.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);
+ }
}