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

Side by Side Diff: src/ast/ast.h

Issue 1751613004: Get rid of the different kinds of yield in the AST & full-codegen. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Do an inline call. Created 4 years, 9 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
« no previous file with comments | « no previous file | src/ast/prettyprinter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 2488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 DCHECK(!expression->IsRewritableExpression()); 2499 DCHECK(!expression->IsRewritableExpression());
2500 } 2500 }
2501 2501
2502 private: 2502 private:
2503 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2503 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2504 2504
2505 bool is_rewritten_; 2505 bool is_rewritten_;
2506 Expression* expr_; 2506 Expression* expr_;
2507 }; 2507 };
2508 2508
2509 2509 // Our Yield is different from the JS yield in that it "returns" its argument as
2510 // is, without wrapping it in an iterator result object. Such wrapping, if
2511 // desired, must be done beforehand (see the parser).
2510 class Yield final : public Expression { 2512 class Yield final : public Expression {
2511 public: 2513 public:
2512 DECLARE_NODE_TYPE(Yield) 2514 DECLARE_NODE_TYPE(Yield)
2513 2515
2514 enum Kind {
2515 kInitial, // The initial yield that returns the unboxed generator object.
2516 kSuspend, // A normal yield: { value: EXPRESSION, done: false }
2517 kDelegating, // A yield*.
2518 kFinal // A return: { value: EXPRESSION, done: true }
2519 };
2520
2521 Expression* generator_object() const { return generator_object_; } 2516 Expression* generator_object() const { return generator_object_; }
2522 Expression* expression() const { return expression_; } 2517 Expression* expression() const { return expression_; }
2523 Kind yield_kind() const { return yield_kind_; }
2524 2518
2525 void set_generator_object(Expression* e) { generator_object_ = e; } 2519 void set_generator_object(Expression* e) { generator_object_ = e; }
2526 void set_expression(Expression* e) { expression_ = e; } 2520 void set_expression(Expression* e) { expression_ = e; }
2527 2521
2528 protected: 2522 protected:
2529 Yield(Zone* zone, Expression* generator_object, Expression* expression, 2523 Yield(Zone* zone, Expression* generator_object, Expression* expression,
2530 Kind yield_kind, int pos) 2524 int pos)
2531 : Expression(zone, pos), 2525 : Expression(zone, pos),
2532 generator_object_(generator_object), 2526 generator_object_(generator_object),
2533 expression_(expression), 2527 expression_(expression) {}
2534 yield_kind_(yield_kind) {}
2535 2528
2536 private: 2529 private:
2537 Expression* generator_object_; 2530 Expression* generator_object_;
2538 Expression* expression_; 2531 Expression* expression_;
2539 Kind yield_kind_;
2540 }; 2532 };
2541 2533
2542 2534
2543 class Throw final : public Expression { 2535 class Throw final : public Expression {
2544 public: 2536 public:
2545 DECLARE_NODE_TYPE(Throw) 2537 DECLARE_NODE_TYPE(Throw)
2546 2538
2547 Expression* exception() const { return exception_; } 2539 Expression* exception() const { return exception_; }
2548 void set_exception(Expression* e) { exception_ = e; } 2540 void set_exception(Expression* e) { exception_ = e; }
2549 2541
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
3367 if (assign->is_compound()) { 3359 if (assign->is_compound()) {
3368 DCHECK(Token::IsAssignmentOp(op)); 3360 DCHECK(Token::IsAssignmentOp(op));
3369 assign->binary_operation_ = 3361 assign->binary_operation_ =
3370 NewBinaryOperation(assign->binary_op(), target, value, pos + 1); 3362 NewBinaryOperation(assign->binary_op(), target, value, pos + 1);
3371 } 3363 }
3372 return assign; 3364 return assign;
3373 } 3365 }
3374 3366
3375 Yield* NewYield(Expression *generator_object, 3367 Yield* NewYield(Expression *generator_object,
3376 Expression* expression, 3368 Expression* expression,
3377 Yield::Kind yield_kind,
3378 int pos) { 3369 int pos) {
3379 if (!expression) expression = NewUndefinedLiteral(pos); 3370 if (!expression) expression = NewUndefinedLiteral(pos);
3380 return new (local_zone_) 3371 return new (local_zone_)
3381 Yield(local_zone_, generator_object, expression, yield_kind, pos); 3372 Yield(local_zone_, generator_object, expression, pos);
3382 } 3373 }
3383 3374
3384 Throw* NewThrow(Expression* exception, int pos) { 3375 Throw* NewThrow(Expression* exception, int pos) {
3385 return new (local_zone_) Throw(local_zone_, exception, pos); 3376 return new (local_zone_) Throw(local_zone_, exception, pos);
3386 } 3377 }
3387 3378
3388 FunctionLiteral* NewFunctionLiteral( 3379 FunctionLiteral* NewFunctionLiteral(
3389 const AstRawString* name, Scope* scope, ZoneList<Statement*>* body, 3380 const AstRawString* name, Scope* scope, ZoneList<Statement*>* body,
3390 int materialized_literal_count, int expected_property_count, 3381 int materialized_literal_count, int expected_property_count,
3391 int parameter_count, 3382 int parameter_count,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3529 : NULL; \ 3520 : NULL; \
3530 } 3521 }
3531 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3522 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3532 #undef DECLARE_NODE_FUNCTIONS 3523 #undef DECLARE_NODE_FUNCTIONS
3533 3524
3534 3525
3535 } // namespace internal 3526 } // namespace internal
3536 } // namespace v8 3527 } // namespace v8
3537 3528
3538 #endif // V8_AST_AST_H_ 3529 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698