diff options
author | Ben Smith <binjimin@gmail.com> | 2017-08-15 14:36:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 14:36:20 -0700 |
commit | 3d3920f6d9388c46af6725dabb34d98752958d8d (patch) | |
tree | cf77acb6d4140b2fb791f91d4af38d59ad8f66a3 /src/circular-array.h | |
parent | 68e8642fea319253466bb3bddece75306f808a69 (diff) | |
download | wabt-3d3920f6d9388c46af6725dabb34d98752958d8d.tar.gz wabt-3d3920f6d9388c46af6725dabb34d98752958d8d.tar.bz2 wabt-3d3920f6d9388c46af6725dabb34d98752958d8d.zip |
Rewrite parser as recursive descent (#591)
* Remove Bison dependency
* Remove pre-generated parser files
* Rename build config from no-re2c-bison to no-re2c
* Add a simple make_unique implementation
* Move handling of module bindings into ir.cc
* Simplify lexer
- Remove lookahead, the parser handles this now
- Unify Token/LexerToken, it only contains terminal values now
- Refactor setting token type and value into one function (e.g.
LITERAL, RETURN => RETURN_LITERAL)
* New Parser
- Uses two tokens of lookahead (use Peek(0) or Peek(1))
- Consume() consumes one token of any kind
- Match(t) consumes the current token if it matches
- PeekMatch(t) returns true iff the token matches, but doesn't consume
- Basic error synchronization; plenty of room for improvement here
Diffstat (limited to 'src/circular-array.h')
-rw-r--r-- | src/circular-array.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/circular-array.h b/src/circular-array.h index 3787cbdd..265410e8 100644 --- a/src/circular-array.h +++ b/src/circular-array.h @@ -18,6 +18,9 @@ #define WABT_CIRCULAR_ARRAY_H_ #include <array> +#include <cassert> +#include <cstddef> +#include <type_traits> namespace wabt { @@ -33,8 +36,10 @@ class CircularArray { typedef const value_type& const_reference; typedef size_t size_type; typedef ptrdiff_t difference_type; + CircularArray() : size_(0), front_(0), mask_(kCapacity - 1) { - assert(kCapacity && ((kCapacity & (kCapacity - 1)) == 0)); + static_assert(kCapacity && ((kCapacity & (kCapacity - 1)) == 0), + "Capacity must be a power of 2."); } reference at(size_type index) { @@ -86,7 +91,7 @@ class CircularArray { --size_; } - void push_back(value_type& value) { + void push_back(const value_type& value) { assert(size_ < kCapacity); contents_[position(size_++)] = value; } |