| Index: src/interpreter/bytecode-pipeline.h
|
| diff --git a/src/interpreter/bytecode-pipeline.h b/src/interpreter/bytecode-pipeline.h
|
| index 3ac1a9e979fbcfec36f384d72546fdf81faaa7b0..e2beff2c8e3ca94e19172c033248e8e0e6743ee4 100644
|
| --- a/src/interpreter/bytecode-pipeline.h
|
| +++ b/src/interpreter/bytecode-pipeline.h
|
| @@ -54,36 +54,86 @@ class BytecodeSourceInfo final {
|
| public:
|
| static const int kUninitializedPosition = -1;
|
|
|
| - BytecodeSourceInfo(int position = kUninitializedPosition,
|
| - bool is_statement = false)
|
| - : source_position_(position), is_statement_(is_statement) {}
|
| + BytecodeSourceInfo()
|
| + : position_type_(PositionType::kNone),
|
| + source_position_(kUninitializedPosition) {}
|
| +
|
| + BytecodeSourceInfo(int source_position, bool is_statement)
|
| + : position_type_(is_statement ? PositionType::kStatement
|
| + : PositionType::kExpression),
|
| + source_position_(source_position) {
|
| + DCHECK_GE(source_position, 0);
|
| + }
|
| +
|
| + // Makes instance into a statement position.
|
| + void MakeStatementPosition(int source_position) {
|
| + // Statement positions can be replaced by other statement
|
| + // positions. For example , "for (x = 0; x < 3; ++x) 7;" has a
|
| + // statement position associated with 7 but no bytecode associated
|
| + // with it. Then Next is emitted after the body and has
|
| + // statement position and overrides the existing one.
|
| + position_type_ = PositionType::kStatement;
|
| + source_position_ = source_position;
|
| + }
|
| +
|
| + // Makes instance into an expression position. Instance should not
|
| + // be a statement position otherwise it could be lost and impair the
|
| + // debugging experience.
|
| + void MakeExpressionPosition(int source_position) {
|
| + DCHECK(!is_statement());
|
| + position_type_ = PositionType::kExpression;
|
| + source_position_ = source_position;
|
| + }
|
| +
|
| + // Forces an instance into an expression position.
|
| + void ForceExpressionPosition(int source_position) {
|
| + position_type_ = PositionType::kExpression;
|
| + source_position_ = source_position;
|
| + }
|
|
|
| - // Combine later source info with current.
|
| - void Update(const BytecodeSourceInfo& entry);
|
| + // Clones a source position. The current instance is expected to be
|
| + // invalid.
|
| + void Clone(const BytecodeSourceInfo& other) {
|
| + DCHECK(!is_valid());
|
| + position_type_ = other.position_type_;
|
| + source_position_ = other.source_position_;
|
| + }
|
|
|
| int source_position() const {
|
| DCHECK(is_valid());
|
| return source_position_;
|
| }
|
|
|
| - bool is_statement() const { return is_valid() && is_statement_; }
|
| - bool is_expression() const { return is_valid() && !is_statement_; }
|
| + bool is_statement() const {
|
| + return position_type_ == PositionType::kStatement;
|
| + }
|
| + bool is_expression() const {
|
| + return position_type_ == PositionType::kExpression;
|
| + }
|
|
|
| - bool is_valid() const { return source_position_ != kUninitializedPosition; }
|
| - void set_invalid() { source_position_ = kUninitializedPosition; }
|
| + bool is_valid() const { return position_type_ != PositionType::kNone; }
|
| + void set_invalid() {
|
| + position_type_ = PositionType::kNone;
|
| + source_position_ = kUninitializedPosition;
|
| + }
|
|
|
| bool operator==(const BytecodeSourceInfo& other) const {
|
| - return source_position_ == other.source_position_ &&
|
| - is_statement_ == other.is_statement_;
|
| + return position_type_ == other.position_type_ &&
|
| + source_position_ == other.source_position_;
|
| }
|
| +
|
| bool operator!=(const BytecodeSourceInfo& other) const {
|
| - return source_position_ != other.source_position_ ||
|
| - is_statement_ != other.is_statement_;
|
| + return position_type_ != other.position_type_ ||
|
| + source_position_ != other.source_position_;
|
| }
|
|
|
| private:
|
| + enum class PositionType : uint8_t { kNone, kExpression, kStatement };
|
| +
|
| + PositionType position_type_;
|
| int source_position_;
|
| - bool is_statement_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BytecodeSourceInfo);
|
| };
|
|
|
| // A container for a generated bytecode, it's operands, and source information.
|
|
|