diff options
author | graydon <graydon> | 2005-08-13 01:36:41 +0000 |
---|---|---|
committer | graydon <graydon> | 2005-08-13 01:36:41 +0000 |
commit | 51bf37c337fbd49b59d9b6039b1722818dde8491 (patch) | |
tree | 382ecd87c484a9173ff7725d15af2c02c4d24d86 /translate.cxx | |
parent | 3a20432bc0a0aa6d8651561d508cc730e6dabc97 (diff) | |
download | systemtap-steved-51bf37c337fbd49b59d9b6039b1722818dde8491.tar.gz systemtap-steved-51bf37c337fbd49b59d9b6039b1722818dde8491.tar.xz systemtap-steved-51bf37c337fbd49b59d9b6039b1722818dde8491.zip |
[ChangeLog]
2005-08-12 Graydon Hoare <graydon@redhat.com>
* translate.cxx (c_tmpcounter::visit_array_in): Implement.
(c_unparser::visit_array_in): Likewise.
(mapvar::exists): New method.
[runtime/ChangeLog]
2005-08-12 Graydon Hoare <graydon@redhat.com>
* map-values.c (_stp_map_entry_exists): New function.
* map.h (_stp_map_entry_exists): Declare it.
Diffstat (limited to 'translate.cxx')
-rw-r--r-- | translate.cxx | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/translate.cxx b/translate.cxx index 6b3ee308..c2425b84 100644 --- a/translate.cxx +++ b/translate.cxx @@ -150,7 +150,7 @@ struct c_tmpcounter: void visit_post_crement (post_crement* e); // void visit_logical_or_expr (logical_or_expr* e); // void visit_logical_and_expr (logical_and_expr* e); - // void visit_array_in (array_in* e); + void visit_array_in (array_in* e); // void visit_comparison (comparison* e); void visit_concatenation (concatenation* e); // void visit_ternary_expression (ternary_expression* e); @@ -322,6 +322,11 @@ struct mapvar return "_stp_map_key_del (" + qname() + ")"; } + string exists () const + { + return "_stp_map_entry_exists (" + qname() + ")"; + } + string seek (vector<tmpvar> const & indices) const { string result = "_stp_map_key" + mangled_indices() + " ("; @@ -1600,10 +1605,45 @@ c_unparser::visit_logical_and_expr (logical_and_expr* e) } +void +c_tmpcounter::visit_array_in (array_in* e) +{ + vardecl* r = e->operand->referent; + + // One temporary per index dimension. + for (unsigned i=0; i<r->index_types.size(); i++) + { + tmpvar ix = parent->gensym (r->index_types[i]); + ix.declare (*parent); + e->operand->indexes[i]->visit(this); + } + + // A boolean result. + tmpvar res = parent->gensym (e->type); + res.declare (*parent); +} + + void c_unparser::visit_array_in (array_in* e) { - throw semantic_error ("array-in expression not yet implemented", e->tok); + stmt_expr block(*this); + + vector<tmpvar> idx; + load_map_indices (e->operand, idx); + + tmpvar res = gensym (pe_long); + + o->newline() << "if (unlikely (c->errorcount)) goto out;"; + + { + mapvar mvar = getmap (e->operand->referent, e->tok); + varlock guard (*this, mvar); + o->newline() << mvar.seek (idx) << ";"; + c_assign (res, mvar.exists(), e->tok); + } + + o->newline() << res << ";"; } |