Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: src/ast.h

Issue 477263002: ES6: Add support for method shorthand in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add strict formal param checking Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 enum IsFunctionFlag { 2360 enum IsFunctionFlag {
2361 kGlobalOrEval, 2361 kGlobalOrEval,
2362 kIsFunction 2362 kIsFunction
2363 }; 2363 };
2364 2364
2365 enum IsParenthesizedFlag { 2365 enum IsParenthesizedFlag {
2366 kIsParenthesized, 2366 kIsParenthesized,
2367 kNotParenthesized 2367 kNotParenthesized
2368 }; 2368 };
2369 2369
2370 enum KindFlag { 2370 enum IsGeneratorFlag { kNotGenerator = 0, kIsGenerator = 1 };
2371 kNormalFunction, 2371
2372 kArrowFunction, 2372 enum IsArrowFlag { kNotArrow = 0, kIsArrow = 1 };
2373 kGeneratorFunction 2373
2374 }; 2374 enum IsConciseMethodFlag { kNotConciseMethod = 0, kIsConciseMethod = 1 };
2375 2375
2376 enum ArityRestriction { 2376 enum ArityRestriction {
2377 NORMAL_ARITY, 2377 NORMAL_ARITY,
2378 GETTER_ARITY, 2378 GETTER_ARITY,
2379 SETTER_ARITY 2379 SETTER_ARITY
2380 }; 2380 };
2381 2381
2382 DECLARE_NODE_TYPE(FunctionLiteral) 2382 DECLARE_NODE_TYPE(FunctionLiteral)
2383 2383
2384 Handle<String> name() const { return raw_name_->string(); } 2384 Handle<String> name() const { return raw_name_->string(); }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 // - var x = function() { ... }(); 2457 // - var x = function() { ... }();
2458 bool is_parenthesized() { 2458 bool is_parenthesized() {
2459 return IsParenthesized::decode(bitfield_) == kIsParenthesized; 2459 return IsParenthesized::decode(bitfield_) == kIsParenthesized;
2460 } 2460 }
2461 void set_parenthesized() { 2461 void set_parenthesized() {
2462 bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized); 2462 bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized);
2463 } 2463 }
2464 2464
2465 bool is_generator() { return IsGenerator::decode(bitfield_); } 2465 bool is_generator() { return IsGenerator::decode(bitfield_); }
2466 bool is_arrow() { return IsArrow::decode(bitfield_); } 2466 bool is_arrow() { return IsArrow::decode(bitfield_); }
2467 bool is_concise_method() { return IsConciseMethod::decode(bitfield_); }
2467 2468
2468 int ast_node_count() { return ast_properties_.node_count(); } 2469 int ast_node_count() { return ast_properties_.node_count(); }
2469 AstProperties::Flags* flags() { return ast_properties_.flags(); } 2470 AstProperties::Flags* flags() { return ast_properties_.flags(); }
2470 void set_ast_properties(AstProperties* ast_properties) { 2471 void set_ast_properties(AstProperties* ast_properties) {
2471 ast_properties_ = *ast_properties; 2472 ast_properties_ = *ast_properties;
2472 } 2473 }
2473 int slot_count() { 2474 int slot_count() {
2474 return ast_properties_.feedback_slots(); 2475 return ast_properties_.feedback_slots();
2475 } 2476 }
2476 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2477 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2477 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2478 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2478 void set_dont_optimize_reason(BailoutReason reason) { 2479 void set_dont_optimize_reason(BailoutReason reason) {
2479 dont_optimize_reason_ = reason; 2480 dont_optimize_reason_ = reason;
2480 } 2481 }
2481 2482
2482 protected: 2483 protected:
2483 FunctionLiteral(Zone* zone, const AstRawString* name, 2484 FunctionLiteral(Zone* zone, const AstRawString* name,
2484 AstValueFactory* ast_value_factory, Scope* scope, 2485 AstValueFactory* ast_value_factory, Scope* scope,
2485 ZoneList<Statement*>* body, int materialized_literal_count, 2486 ZoneList<Statement*>* body, int materialized_literal_count,
2486 int expected_property_count, int handler_count, 2487 int expected_property_count, int handler_count,
2487 int parameter_count, FunctionType function_type, 2488 int parameter_count, FunctionType function_type,
2488 ParameterFlag has_duplicate_parameters, 2489 ParameterFlag has_duplicate_parameters,
2489 IsFunctionFlag is_function, 2490 IsFunctionFlag is_function,
2490 IsParenthesizedFlag is_parenthesized, KindFlag kind, 2491 IsParenthesizedFlag is_parenthesized,
2491 int position) 2492 IsGeneratorFlag is_generator, IsArrowFlag is_arrow,
2493 IsConciseMethodFlag is_concise_method, int position)
2492 : Expression(zone, position), 2494 : Expression(zone, position),
2493 raw_name_(name), 2495 raw_name_(name),
2494 scope_(scope), 2496 scope_(scope),
2495 body_(body), 2497 body_(body),
2496 raw_inferred_name_(ast_value_factory->empty_string()), 2498 raw_inferred_name_(ast_value_factory->empty_string()),
2497 dont_optimize_reason_(kNoReason), 2499 dont_optimize_reason_(kNoReason),
2498 materialized_literal_count_(materialized_literal_count), 2500 materialized_literal_count_(materialized_literal_count),
2499 expected_property_count_(expected_property_count), 2501 expected_property_count_(expected_property_count),
2500 handler_count_(handler_count), 2502 handler_count_(handler_count),
2501 parameter_count_(parameter_count), 2503 parameter_count_(parameter_count),
2502 function_token_position_(RelocInfo::kNoPosition) { 2504 function_token_position_(RelocInfo::kNoPosition) {
2503 bitfield_ = IsExpression::encode(function_type != DECLARATION) | 2505 bitfield_ = IsExpression::encode(function_type != DECLARATION) |
2504 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2506 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2505 Pretenure::encode(false) | 2507 Pretenure::encode(false) |
2506 HasDuplicateParameters::encode(has_duplicate_parameters) | 2508 HasDuplicateParameters::encode(has_duplicate_parameters) |
2507 IsFunction::encode(is_function) | 2509 IsFunction::encode(is_function) |
2508 IsParenthesized::encode(is_parenthesized) | 2510 IsParenthesized::encode(is_parenthesized) |
2509 IsGenerator::encode(kind == kGeneratorFunction) | 2511 IsGenerator::encode(is_generator) | IsArrow::encode(is_arrow) |
2510 IsArrow::encode(kind == kArrowFunction); 2512 IsConciseMethod::encode(is_concise_method);
2511 } 2513 }
2512 2514
2513 private: 2515 private:
2514 const AstRawString* raw_name_; 2516 const AstRawString* raw_name_;
2515 Handle<String> name_; 2517 Handle<String> name_;
2516 Handle<SharedFunctionInfo> shared_info_; 2518 Handle<SharedFunctionInfo> shared_info_;
2517 Scope* scope_; 2519 Scope* scope_;
2518 ZoneList<Statement*>* body_; 2520 ZoneList<Statement*>* body_;
2519 const AstString* raw_inferred_name_; 2521 const AstString* raw_inferred_name_;
2520 Handle<String> inferred_name_; 2522 Handle<String> inferred_name_;
2521 AstProperties ast_properties_; 2523 AstProperties ast_properties_;
2522 BailoutReason dont_optimize_reason_; 2524 BailoutReason dont_optimize_reason_;
2523 2525
2524 int materialized_literal_count_; 2526 int materialized_literal_count_;
2525 int expected_property_count_; 2527 int expected_property_count_;
2526 int handler_count_; 2528 int handler_count_;
2527 int parameter_count_; 2529 int parameter_count_;
2528 int function_token_position_; 2530 int function_token_position_;
2529 2531
2530 unsigned bitfield_; 2532 unsigned bitfield_;
2531 class IsExpression: public BitField<bool, 0, 1> {}; 2533 class IsExpression: public BitField<bool, 0, 1> {};
2532 class IsAnonymous: public BitField<bool, 1, 1> {}; 2534 class IsAnonymous: public BitField<bool, 1, 1> {};
2533 class Pretenure: public BitField<bool, 2, 1> {}; 2535 class Pretenure: public BitField<bool, 2, 1> {};
2534 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {}; 2536 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {};
2535 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {}; 2537 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {};
2536 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {}; 2538 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {};
2537 class IsGenerator : public BitField<bool, 6, 1> {}; 2539 class IsGenerator : public BitField<bool, 6, 1> {};
2538 class IsArrow : public BitField<bool, 7, 1> {}; 2540 class IsArrow : public BitField<bool, 7, 1> {};
2541 class IsConciseMethod : public BitField<bool, 8, 1> {};
2539 }; 2542 };
2540 2543
2541 2544
2542 class NativeFunctionLiteral V8_FINAL : public Expression { 2545 class NativeFunctionLiteral V8_FINAL : public Expression {
2543 public: 2546 public:
2544 DECLARE_NODE_TYPE(NativeFunctionLiteral) 2547 DECLARE_NODE_TYPE(NativeFunctionLiteral)
2545 2548
2546 Handle<String> name() const { return name_->string(); } 2549 Handle<String> name() const { return name_->string(); }
2547 v8::Extension* extension() const { return extension_; } 2550 v8::Extension* extension() const { return extension_; }
2548 2551
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
3469 } 3472 }
3470 3473
3471 FunctionLiteral* NewFunctionLiteral( 3474 FunctionLiteral* NewFunctionLiteral(
3472 const AstRawString* name, AstValueFactory* ast_value_factory, 3475 const AstRawString* name, AstValueFactory* ast_value_factory,
3473 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, 3476 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
3474 int expected_property_count, int handler_count, int parameter_count, 3477 int expected_property_count, int handler_count, int parameter_count,
3475 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3478 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3476 FunctionLiteral::FunctionType function_type, 3479 FunctionLiteral::FunctionType function_type,
3477 FunctionLiteral::IsFunctionFlag is_function, 3480 FunctionLiteral::IsFunctionFlag is_function,
3478 FunctionLiteral::IsParenthesizedFlag is_parenthesized, 3481 FunctionLiteral::IsParenthesizedFlag is_parenthesized,
3479 FunctionLiteral::KindFlag kind, int position) { 3482 FunctionLiteral::IsGeneratorFlag is_generator,
3483 FunctionLiteral::IsArrowFlag is_arrow,
3484 FunctionLiteral::IsConciseMethodFlag is_concise_method, int position) {
3480 FunctionLiteral* lit = new (zone_) FunctionLiteral( 3485 FunctionLiteral* lit = new (zone_) FunctionLiteral(
3481 zone_, name, ast_value_factory, scope, body, materialized_literal_count, 3486 zone_, name, ast_value_factory, scope, body, materialized_literal_count,
3482 expected_property_count, handler_count, parameter_count, function_type, 3487 expected_property_count, handler_count, parameter_count, function_type,
3483 has_duplicate_parameters, is_function, is_parenthesized, kind, 3488 has_duplicate_parameters, is_function, is_parenthesized, is_generator,
3484 position); 3489 is_arrow, is_concise_method, position);
3485 // Top-level literal doesn't count for the AST's properties. 3490 // Top-level literal doesn't count for the AST's properties.
3486 if (is_function == FunctionLiteral::kIsFunction) { 3491 if (is_function == FunctionLiteral::kIsFunction) {
3487 visitor_.VisitFunctionLiteral(lit); 3492 visitor_.VisitFunctionLiteral(lit);
3488 } 3493 }
3489 return lit; 3494 return lit;
3490 } 3495 }
3491 3496
3492 NativeFunctionLiteral* NewNativeFunctionLiteral( 3497 NativeFunctionLiteral* NewNativeFunctionLiteral(
3493 const AstRawString* name, v8::Extension* extension, 3498 const AstRawString* name, v8::Extension* extension,
3494 int pos) { 3499 int pos) {
(...skipping 17 matching lines...) Expand all
3512 private: 3517 private:
3513 Zone* zone_; 3518 Zone* zone_;
3514 Visitor visitor_; 3519 Visitor visitor_;
3515 AstValueFactory* ast_value_factory_; 3520 AstValueFactory* ast_value_factory_;
3516 }; 3521 };
3517 3522
3518 3523
3519 } } // namespace v8::internal 3524 } } // namespace v8::internal
3520 3525
3521 #endif // V8_AST_H_ 3526 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arm64/lithium-codegen-arm64.cc ('k') | src/code-stubs.h » ('j') | src/parser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698