diff options
author | fche <fche> | 2005-08-12 19:43:55 +0000 |
---|---|---|
committer | fche <fche> | 2005-08-12 19:43:55 +0000 |
commit | 3a20432bc0a0aa6d8651561d508cc730e6dabc97 (patch) | |
tree | 2d957fcf675df9a8f3a909ab51f1177ae4854137 /parse.cxx | |
parent | ba3f9e9ebb1b8cae641159305031ec5fee637fd4 (diff) | |
download | systemtap-steved-3a20432bc0a0aa6d8651561d508cc730e6dabc97.tar.gz systemtap-steved-3a20432bc0a0aa6d8651561d508cc730e6dabc97.tar.xz systemtap-steved-3a20432bc0a0aa6d8651561d508cc730e6dabc97.zip |
2005-08-12 Frank Ch. Eigler <fche@elastic.org>
PR systemtap/1122 et alii
* parse.cxx (parse_literal): Parse and range-limit 64-bit numbers.
(parse_unary): Correct precedence glitch.
* staptree.h (literal_number): Store an int64_t.
* staptree.cxx: Corresponding changes.
* translate.cxx (check_dbz): Remove - insufficient.
(emit_function): Define CONTEXT macro sibling for THIS.
(c_typename): pe_long -> int64_t.
(visit_literal_number): Format literal rigorously and uglily.
(c_assignop, visit_binary_expression): Handle div/mod via new
helper functions in runtime.
* tapset/builtin_logging.stp: Add error, exit builtins.
* testsuite/buildok/ten,eleven.stp: New tests.
* testsuite/parse{ko,ok}/six.stp: Modify for larger numbers.
* testsuite/transok/one.stp: Add more ";"s, maybe unnecessarily.
2005-08-12 Frank Ch. Eigler <fche@elastic.org>
* arith.c: New file to contain arithmetic helper functions.
* builtin_functions.h: Remove, unused.
* runtime.h: Include it.
Diffstat (limited to 'parse.cxx')
-rw-r--r-- | parse.cxx | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -291,7 +291,7 @@ lexer::scan () return n; } - else if (isdigit (c)) + else if (isdigit (c)) // positive literal { n->type = tok_number; n->content = (char) c; @@ -349,6 +349,11 @@ lexer::scan () string s2 = (c2 > 0 ? s1 + (char) c2 : s1); string s3 = (c3 > 0 ? s2 + (char) c3 : s2); + // NB: if we were to recognize negative numeric literals here, + // we'd introduce another grammar ambiguity: + // 1-1 would be parsed as tok_number(1) and tok_number(-1) + // instead of tok_number(1) tok_operator('-') tok_number(1) + if (s1 == "#") // shell comment { unsigned this_line = cursor_line; @@ -847,15 +852,17 @@ parser::parse_literal () const char* startp = t->content.c_str (); char* endp = (char*) startp; - // NB: we allow controlled overflow from LONG_MIN .. ULONG_MAX + // NB: we allow controlled overflow from LLONG_MIN .. ULLONG_MAX + // Actually, this allows all the way from -ULLONG_MAX to ULLONG_MAX, + // since the lexer only gives us positive digit strings. errno = 0; - long long value = strtoll (startp, & endp, 0); + long long value = (long long) strtoull (startp, & endp, 0); if (errno == ERANGE || errno == EINVAL || *endp != '\0' - || value > 4294967295LL || value < (-2147483647LL-1)) + || (unsigned long long) value > 18446744073709551615ULL + || value < -9223372036854775807LL-1) throw parse_error ("number invalid or out of range"); - long value2 = (long) value; - l = new literal_number (value2); + l = new literal_number (value); } else throw parse_error ("expected literal string or number"); @@ -1537,7 +1544,7 @@ parser::parse_unary () e->op = t->content; e->tok = t; next (); - e->operand = parse_expression (); + e->operand = parse_crement (); return e; } else |