From bb2e3076ea20631d4606050550bc9664204f2c62 Mon Sep 17 00:00:00 2001 From: fche Date: Wed, 8 Jun 2005 22:02:09 +0000 Subject: 2005-06-08 Frank Ch. Eigler systemtap/916 Implement all basic scalar operators, including modify-assignment. * parse.cxx (lexer): Allow multi-character lookahead in order to scan 1/2/3-character operators. (parse_boolean_or/and/xor/shift): New routines. * translate.cxx (visit_assignment, visit_binary_expression, visit_*_crement): Generally rewrote. (visit_*): Added more parentheses in output. (emit_module_init): Initialize globals. * staptree.h, elaborate.cxx, elaborate.h: Remove exponentiation. * main.cxx (main): Add an end-of-line to output file. * testsuite/*: Several new tests. --- testsuite/parseok/eleven.stp | 54 ++++++++++++++++++++++++++++++++++++++++++ testsuite/parseok/ten.stp | 14 +++++------ testsuite/transok/five.stp | 2 +- testsuite/transok/one.stp | 56 ++++++++++++++++++++++++++++++++++++++++++++ testsuite/transok/three.stp | 7 +++--- testsuite/transok/two.stp | 2 +- 6 files changed, 122 insertions(+), 13 deletions(-) create mode 100755 testsuite/parseok/eleven.stp create mode 100755 testsuite/transok/one.stp (limited to 'testsuite') diff --git a/testsuite/parseok/eleven.stp b/testsuite/parseok/eleven.stp new file mode 100755 index 00000000..c05ca66f --- /dev/null +++ b/testsuite/parseok/eleven.stp @@ -0,0 +1,54 @@ +#! stap -p1 + +probe two +{ + # all assignment operators + a = b + a <<< b + a += b + a -= b + a *= b + a /= b + a %= b + a <<= b + a >>= b + a &= b + a ^= b + a |= b + + # all ternary operators + a ? b : c + + # all binary operators + a || b + a && b + a | b + a & b + a ^ b + a < b + a > b + a == b + a != b + a <= b + a >= b + a << b + a >> b + a . b + a + b + a - b + a * b + a / b + a % b + + # all unary operators + a ++ + a -- + -- a + ++ a + ~ a + ! a + ; # grammar glitch + + a + ; # grammar glitch + - a +} diff --git a/testsuite/parseok/ten.stp b/testsuite/parseok/ten.stp index 25d16e62..2da82f04 100755 --- a/testsuite/parseok/ten.stp +++ b/testsuite/parseok/ten.stp @@ -4,13 +4,13 @@ probe two { for (;;) ; for (a=0;;) { a + 4; break } - for (;a>0;) { a + 5; continue } - for (;;a++) { a + 5 } - for (a=0;a>0;) { a + 4 } - for (;a>0;a++) { a + 5 } - for (a=0;;a++) { a + 5 } - for (a=0; a<=4; a++) ; - for (a=0; a<=4; a++) { b = a } + for (;a>0;) { a ^ 5; continue } + for (;;a++) { a | 5 } + for (a=0;a>0;) { a << 4 } + for (;a>0;++a) { a >> 5 } + for (a=0;;a--) { a & 5 * b } + for (a=0; a<=4 && b>=5; --a) ; + for (a=0; a==4 || b!=5; a++) { b = a } next while (99) ; while (99) { break continue } diff --git a/testsuite/transok/five.stp b/testsuite/transok/five.stp index 266b3408..5cd50cb6 100755 --- a/testsuite/transok/five.stp +++ b/testsuite/transok/five.stp @@ -1,6 +1,6 @@ #! stap -probe two +probe begin { for (;;) ; for (a=0;;) { if (a > 4) break } diff --git a/testsuite/transok/one.stp b/testsuite/transok/one.stp new file mode 100755 index 00000000..6c624f14 --- /dev/null +++ b/testsuite/transok/one.stp @@ -0,0 +1,56 @@ +#! stap -p3 + +probe begin +{ + # all assignment operators + a = b + # a <<< b + a += b + a -= b + a *= b + a /= b + a %= b + a <<= b + a >>= b + a &= b + a ^= b + a |= b + + # all ternary operators + a ? b : c + + # all binary operators + a || b + a && b + a | b + a & b + a ^ b + a < b + a > b + a == b + a != b + a <= b + a >= b + a << b + a >> b + as . bs + as == bs # overload operators for strings + as != bs + a + b + a - b + a * b + a / b + a % b + + # all unary operators + a ++ + a -- + -- a + -- b + ~ a + ! a + ; # grammar glitch + + a + ; # grammar glitch + - a +} diff --git a/testsuite/transok/three.stp b/testsuite/transok/three.stp index c372b271..07703f90 100755 --- a/testsuite/transok/three.stp +++ b/testsuite/transok/three.stp @@ -5,7 +5,7 @@ function f1 (a, b) { d = "hello"; # poo[c] = bab[d] = "hi" bab = "hi"; - bab = poo[c]; + # bab = poo[c]; return 0 } @@ -14,14 +14,13 @@ function f2 () { } global koo -global poo, bab -probe z { +probe begin { f2 (); koo = 1 } -probe x,y { +probe begin, end { f2 (); f1 (f1 (3 * 2 + 1, "foo"), "canoe") } diff --git a/testsuite/transok/two.stp b/testsuite/transok/two.stp index d62e88a8..848934a7 100755 --- a/testsuite/transok/two.stp +++ b/testsuite/transok/two.stp @@ -1,5 +1,5 @@ #! stap -probe k,l { 2; } +probe begin, end { 2; } function poo (zoo) { n = poo2 (8); return "foo" . zoo } function poo2 (zoo) { return poo3 (2 + 4 * zoo) } function poo3 (zoo) { return zoo } -- cgit