5 #ifndef V8_INTERPRETER_BYTECODE_SOURCE_INFO_H_ 6 #define V8_INTERPRETER_BYTECODE_SOURCE_INFO_H_ 8 #include "src/globals.h" 12 namespace interpreter {
17 static const int kUninitializedPosition = -1;
20 : position_type_(PositionType::kNone),
21 source_position_(kUninitializedPosition) {}
24 : position_type_(is_statement ? PositionType::kStatement
25 : PositionType::kExpression),
26 source_position_(source_position) {
27 DCHECK_GE(source_position, 0);
31 void MakeStatementPosition(
int source_position) {
37 position_type_ = PositionType::kStatement;
38 source_position_ = source_position;
44 void MakeExpressionPosition(
int source_position) {
45 DCHECK(!is_statement());
46 position_type_ = PositionType::kExpression;
47 source_position_ = source_position;
51 void ForceExpressionPosition(
int source_position) {
52 position_type_ = PositionType::kExpression;
53 source_position_ = source_position;
56 int source_position()
const {
58 return source_position_;
61 bool is_statement()
const {
62 return position_type_ == PositionType::kStatement;
64 bool is_expression()
const {
65 return position_type_ == PositionType::kExpression;
68 bool is_valid()
const {
return position_type_ != PositionType::kNone; }
70 position_type_ = PositionType::kNone;
71 source_position_ = kUninitializedPosition;
75 return position_type_ == other.position_type_ &&
76 source_position_ == other.source_position_;
80 return position_type_ != other.position_type_ ||
81 source_position_ != other.source_position_;
85 enum class PositionType : uint8_t {
kNone, kExpression, kStatement };
87 PositionType position_type_;
91 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
98 #endif // V8_INTERPRETER_BYTECODE_SOURCE_INFO_H_