| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_AST_H_ | 5 #ifndef V8_AST_H_ |
| 6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
| (...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 | 1269 |
| 1270 const AstRawString* AsRawPropertyName() { | 1270 const AstRawString* AsRawPropertyName() { |
| 1271 DCHECK(IsPropertyName()); | 1271 DCHECK(IsPropertyName()); |
| 1272 return value_->AsString(); | 1272 return value_->AsString(); |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 bool ToBooleanIsTrue() const override { return value()->BooleanValue(); } | 1275 bool ToBooleanIsTrue() const override { return value()->BooleanValue(); } |
| 1276 bool ToBooleanIsFalse() const override { return !value()->BooleanValue(); } | 1276 bool ToBooleanIsFalse() const override { return !value()->BooleanValue(); } |
| 1277 | 1277 |
| 1278 Handle<Object> value() const { return value_->value(); } | 1278 Handle<Object> value() const { return value_->value(); } |
| 1279 bool is_float() const { return is_float_; } |
| 1279 const AstValue* raw_value() const { return value_; } | 1280 const AstValue* raw_value() const { return value_; } |
| 1280 | 1281 |
| 1281 // Support for using Literal as a HashMap key. NOTE: Currently, this works | 1282 // Support for using Literal as a HashMap key. NOTE: Currently, this works |
| 1282 // only for string and number literals! | 1283 // only for string and number literals! |
| 1283 uint32_t Hash(); | 1284 uint32_t Hash(); |
| 1284 static bool Match(void* literal1, void* literal2); | 1285 static bool Match(void* literal1, void* literal2); |
| 1285 | 1286 |
| 1286 static int num_ids() { return parent_num_ids() + 1; } | 1287 static int num_ids() { return parent_num_ids() + 1; } |
| 1287 TypeFeedbackId LiteralFeedbackId() const { | 1288 TypeFeedbackId LiteralFeedbackId() const { |
| 1288 return TypeFeedbackId(local_id(0)); | 1289 return TypeFeedbackId(local_id(0)); |
| 1289 } | 1290 } |
| 1290 | 1291 |
| 1291 protected: | 1292 protected: |
| 1292 Literal(Zone* zone, const AstValue* value, int position) | 1293 Literal(Zone* zone, const AstValue* value, int position, |
| 1293 : Expression(zone, position), value_(value) {} | 1294 bool is_float = false) |
| 1295 : Expression(zone, position), value_(value), is_float_(is_float) {} |
| 1294 static int parent_num_ids() { return Expression::num_ids(); } | 1296 static int parent_num_ids() { return Expression::num_ids(); } |
| 1295 | 1297 |
| 1296 private: | 1298 private: |
| 1297 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1299 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1298 | 1300 |
| 1299 const AstValue* value_; | 1301 const AstValue* value_; |
| 1302 bool is_float_; // Literal contained a '.' |
| 1300 }; | 1303 }; |
| 1301 | 1304 |
| 1302 | 1305 |
| 1303 // Base class for literals that needs space in the corresponding JSFunction. | 1306 // Base class for literals that needs space in the corresponding JSFunction. |
| 1304 class MaterializedLiteral : public Expression { | 1307 class MaterializedLiteral : public Expression { |
| 1305 public: | 1308 public: |
| 1306 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 1309 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
| 1307 | 1310 |
| 1308 int literal_index() { return literal_index_; } | 1311 int literal_index() { return literal_index_; } |
| 1309 | 1312 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 }; | 1620 }; |
| 1618 | 1621 |
| 1619 | 1622 |
| 1620 class VariableProxy final : public Expression { | 1623 class VariableProxy final : public Expression { |
| 1621 public: | 1624 public: |
| 1622 DECLARE_NODE_TYPE(VariableProxy) | 1625 DECLARE_NODE_TYPE(VariableProxy) |
| 1623 | 1626 |
| 1624 bool IsValidReferenceExpression() const override { return !is_this(); } | 1627 bool IsValidReferenceExpression() const override { return !is_this(); } |
| 1625 | 1628 |
| 1626 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } | 1629 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } |
| 1630 bool IsParameter() const { return is_resolved() && var()->IsParameter(); } |
| 1627 | 1631 |
| 1628 Handle<String> name() const { return raw_name()->string(); } | 1632 Handle<String> name() const { return raw_name()->string(); } |
| 1629 const AstRawString* raw_name() const { | 1633 const AstRawString* raw_name() const { |
| 1630 return is_resolved() ? var_->raw_name() : raw_name_; | 1634 return is_resolved() ? var_->raw_name() : raw_name_; |
| 1631 } | 1635 } |
| 1632 | 1636 |
| 1633 Variable* var() const { | 1637 Variable* var() const { |
| 1634 DCHECK(is_resolved()); | 1638 DCHECK(is_resolved()); |
| 1635 return var_; | 1639 return var_; |
| 1636 } | 1640 } |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2511 Scope* scope() const { return scope_; } | 2515 Scope* scope() const { return scope_; } |
| 2512 ZoneList<Statement*>* body() const { return body_; } | 2516 ZoneList<Statement*>* body() const { return body_; } |
| 2513 void set_function_token_position(int pos) { function_token_position_ = pos; } | 2517 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 2514 int function_token_position() const { return function_token_position_; } | 2518 int function_token_position() const { return function_token_position_; } |
| 2515 int start_position() const; | 2519 int start_position() const; |
| 2516 int end_position() const; | 2520 int end_position() const; |
| 2517 int SourceSize() const { return end_position() - start_position(); } | 2521 int SourceSize() const { return end_position() - start_position(); } |
| 2518 bool is_expression() const { return IsExpression::decode(bitfield_); } | 2522 bool is_expression() const { return IsExpression::decode(bitfield_); } |
| 2519 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); } | 2523 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); } |
| 2520 LanguageMode language_mode() const; | 2524 LanguageMode language_mode() const; |
| 2525 AsmMode asm_mode() const; |
| 2521 | 2526 |
| 2522 static bool NeedsHomeObject(Expression* expr); | 2527 static bool NeedsHomeObject(Expression* expr); |
| 2523 | 2528 |
| 2524 int materialized_literal_count() { return materialized_literal_count_; } | 2529 int materialized_literal_count() { return materialized_literal_count_; } |
| 2525 int expected_property_count() { return expected_property_count_; } | 2530 int expected_property_count() { return expected_property_count_; } |
| 2526 int handler_count() { return handler_count_; } | 2531 int handler_count() { return handler_count_; } |
| 2527 int parameter_count() { return parameter_count_; } | 2532 int parameter_count() { return parameter_count_; } |
| 2528 | 2533 |
| 2529 bool AllowsLazyCompilation(); | 2534 bool AllowsLazyCompilation(); |
| 2530 bool AllowsLazyCompilationWithoutContext(); | 2535 bool AllowsLazyCompilationWithoutContext(); |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3360 Literal* NewStringLiteral(const AstRawString* string, int pos) { | 3365 Literal* NewStringLiteral(const AstRawString* string, int pos) { |
| 3361 return new (zone_) | 3366 return new (zone_) |
| 3362 Literal(zone_, ast_value_factory_->NewString(string), pos); | 3367 Literal(zone_, ast_value_factory_->NewString(string), pos); |
| 3363 } | 3368 } |
| 3364 | 3369 |
| 3365 // A JavaScript symbol (ECMA-262 edition 6). | 3370 // A JavaScript symbol (ECMA-262 edition 6). |
| 3366 Literal* NewSymbolLiteral(const char* name, int pos) { | 3371 Literal* NewSymbolLiteral(const char* name, int pos) { |
| 3367 return new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); | 3372 return new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); |
| 3368 } | 3373 } |
| 3369 | 3374 |
| 3370 Literal* NewNumberLiteral(double number, int pos) { | 3375 Literal* NewNumberLiteral(double number, int pos, bool is_float = false) { |
| 3371 return new (zone_) | 3376 return new (zone_) |
| 3372 Literal(zone_, ast_value_factory_->NewNumber(number), pos); | 3377 Literal(zone_, ast_value_factory_->NewNumber(number), pos, is_float); |
| 3373 } | 3378 } |
| 3374 | 3379 |
| 3375 Literal* NewSmiLiteral(int number, int pos) { | 3380 Literal* NewSmiLiteral(int number, int pos) { |
| 3376 return new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); | 3381 return new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); |
| 3377 } | 3382 } |
| 3378 | 3383 |
| 3379 Literal* NewBooleanLiteral(bool b, int pos) { | 3384 Literal* NewBooleanLiteral(bool b, int pos) { |
| 3380 return new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); | 3385 return new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); |
| 3381 } | 3386 } |
| 3382 | 3387 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3593 | 3598 |
| 3594 private: | 3599 private: |
| 3595 Zone* zone_; | 3600 Zone* zone_; |
| 3596 AstValueFactory* ast_value_factory_; | 3601 AstValueFactory* ast_value_factory_; |
| 3597 }; | 3602 }; |
| 3598 | 3603 |
| 3599 | 3604 |
| 3600 } } // namespace v8::internal | 3605 } } // namespace v8::internal |
| 3601 | 3606 |
| 3602 #endif // V8_AST_H_ | 3607 #endif // V8_AST_H_ |
| OLD | NEW |