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. --- testsuite/parseko/seven.stp | 8 ++++++++ testsuite/parseok/eight.stp | 6 ++++++ testsuite/semko/ten.stp | 5 +++++ testsuite/semok/seven.stp | 4 ++-- testsuite/semok/ten.stp | 10 ++++++++++ testsuite/transok/three.stp | 27 +++++++++++++++++++++++++++ 6 files changed, 58 insertions(+), 2 deletions(-) create mode 100755 testsuite/parseko/seven.stp create mode 100755 testsuite/parseok/eight.stp create mode 100755 testsuite/semko/ten.stp create mode 100755 testsuite/semok/ten.stp create mode 100755 testsuite/transok/three.stp (limited to 'testsuite') diff --git a/testsuite/parseko/seven.stp b/testsuite/parseko/seven.stp new file mode 100755 index 00000000..06f8a3ba --- /dev/null +++ b/testsuite/parseko/seven.stp @@ -0,0 +1,8 @@ +#! stap -p1 + +probe foo { + (a,) in b; + (,c) in d; + () in e; + a in e[2]; +} diff --git a/testsuite/parseok/eight.stp b/testsuite/parseok/eight.stp new file mode 100755 index 00000000..0da5c8d2 --- /dev/null +++ b/testsuite/parseok/eight.stp @@ -0,0 +1,6 @@ +#! stap -p1 + +probe all +{ + "1" in a1; ("1", 2) in a2; (a) in a3; +} diff --git a/testsuite/semko/ten.stp b/testsuite/semko/ten.stp new file mode 100755 index 00000000..3e233228 --- /dev/null +++ b/testsuite/semko/ten.stp @@ -0,0 +1,5 @@ +#! stap -p2 + +global foo +probe p1 { foo = 1 } +probe p2 { if (4 in foo) { } } diff --git a/testsuite/semok/seven.stp b/testsuite/semok/seven.stp index 8351c1e2..b9ce8cb9 100755 --- a/testsuite/semok/seven.stp +++ b/testsuite/semok/seven.stp @@ -7,7 +7,7 @@ function printk (s) { str=s.""; return 0 } # to become a built-in function search (key) { - if (1) # (key in ar1) + if (key in ar1) { ar1[key] ++; return ar2[ar1[key]] } else return "no can do" # implies ar2[]: string @@ -22,6 +22,6 @@ probe syscall("zamboni") probe end { # for (key in ar2) - if (1) # (key in ar2) + if (key in ar2) printk ("this: " . string (key) . " was " . ar2[key]) } diff --git a/testsuite/semok/ten.stp b/testsuite/semok/ten.stp new file mode 100755 index 00000000..d56c2a4a --- /dev/null +++ b/testsuite/semok/ten.stp @@ -0,0 +1,10 @@ +#! stap -p1 + +global a1, a2, a3 + +probe all +{ + a = "1" in a1; + a = ("1", a) in a2; + a = (a, a+a, a1[a], a2[0+a]) in a3; +} diff --git a/testsuite/transok/three.stp b/testsuite/transok/three.stp new file mode 100755 index 00000000..ce94531c --- /dev/null +++ b/testsuite/transok/three.stp @@ -0,0 +1,27 @@ +#! stap + +function f1 (a, b) { + c = 1; + d = "hello"; + # poo[c] = bab[d] = "hi" + bab = "hi"; + bab = poo[c]; + return 0 +} + +function f2 () { + return f1 (4, "zoo"); +} + +global koo +global poo, bab + +probe z { + f2 (); + koo = 1 +} + +probe x,y { + f2 (); + f1 (f1 (3, "foo"), "canoe") +} -- cgit