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

Unified Diff: src/ast.h

Issue 919703003: WIP: Implement ES6 Spread-calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: AssignmentExpressions are not spreadable, add cctests for parsing Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/preparser.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index e457e66a215f1aed49d48e5c54ffed107b29cca9..19c51fdf552fc6ab1a045172089d9c09fd477655 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -93,6 +93,7 @@ namespace internal {
V(CountOperation) \
V(BinaryOperation) \
V(CompareOperation) \
+ V(SpreadOperation) \
V(ThisFunction) \
V(SuperReference) \
V(CaseClause)
@@ -128,6 +129,9 @@ class RegExpLookahead;
class RegExpQuantifier;
class RegExpText;
+// Other forward declarations
+class Scope;
+
#define DEF_FORWARD_DECLARATION(type) class type;
AST_NODE_LIST(DEF_FORWARD_DECLARATION)
#undef DEF_FORWARD_DECLARATION
@@ -1891,6 +1895,20 @@ class Call FINAL : public Expression {
bool return_is_recorded_;
#endif
+ static bool HasSpreadArguments(ZoneList<Expression*>* arguments) {
+ ZoneList<Expression*>::iterator it;
+ for (it = arguments->begin(); it != arguments->end(); ++it) {
+ if ((*it)->IsSpreadOperation()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ inline bool HasSpreadArguments() const {
+ return HasSpreadArgumentsField::decode(bit_field_);
+ }
+
protected:
Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
int pos)
@@ -1898,7 +1916,9 @@ class Call FINAL : public Expression {
ic_slot_or_slot_(FeedbackVectorICSlot::Invalid().ToInt()),
expression_(expression),
arguments_(arguments),
- bit_field_(IsUninitializedField::encode(false)) {
+ bit_field_(
+ IsUninitializedField::encode(false) |
+ HasSpreadArgumentsField::encode(HasSpreadArguments(arguments))) {
arv (Not doing code reviews) 2015/02/12 21:41:34 Maybe have the parser keep track of this and set t
if (expression->IsProperty()) {
expression->AsProperty()->mark_for_call();
}
@@ -1917,6 +1937,7 @@ class Call FINAL : public Expression {
Handle<Cell> cell_;
Handle<AllocationSite> allocation_site_;
class IsUninitializedField : public BitField8<bool, 0, 1> {};
+ class HasSpreadArgumentsField : public BitField8<bool, 1, 1> {};
uint8_t bit_field_;
};
@@ -2243,6 +2264,35 @@ class CompareOperation FINAL : public Expression {
};
+class SpreadOperation FINAL : public Expression {
+ public:
+ DECLARE_NODE_TYPE(SpreadOperation)
+
+ Expression* expression() const { return expression_; }
+ Expression* assign_iterator() const { return assign_iterator_; }
+ Expression* next_result() const { return next_result_; }
+ Expression* result_done() const { return result_done_; }
+ Expression* result_value() const { return result_value_; }
+
+ static int num_ids() { return parent_num_ids(); }
+
+ protected:
+ SpreadOperation(Zone* zone, AstNodeFactory* factory,
+ AstValueFactory* value_factory, Scope* scope,
+ Expression* expression, int pos);
+ static int parent_num_ids() { return Expression::num_ids(); }
+
+ private:
+ int local_id(int n) const { return base_id() + parent_num_ids() + n; }
+
+ Expression* expression_;
+ Expression* assign_iterator_;
+ Expression* next_result_;
+ Expression* result_done_;
+ Expression* result_value_;
+};
+
+
class Conditional FINAL : public Expression {
public:
DECLARE_NODE_TYPE(Conditional)
@@ -3463,6 +3513,12 @@ class AstNodeFactory FINAL BASE_EMBEDDED {
return new (zone_) CompareOperation(zone_, op, left, right, pos);
}
+ SpreadOperation* NewSpreadOperation(Scope* scope, Expression* expression,
+ int pos) {
+ return new (zone_) SpreadOperation(zone_, this, ast_value_factory_, scope,
+ expression, pos);
+ }
+
Conditional* NewConditional(Expression* condition,
Expression* then_expression,
Expression* else_expression,
@@ -3538,6 +3594,16 @@ class AstNodeFactory FINAL BASE_EMBEDDED {
return new (zone_) SuperReference(zone_, this_var, pos);
}
+ // Utilities
+ Expression* GetIterator(Expression* iterable) {
+ Expression* iterator_symbol_literal =
+ NewSymbolLiteral("iterator_symbol", RelocInfo::kNoPosition);
+ int pos = iterable->position();
+ Expression* prop = NewProperty(iterable, iterator_symbol_literal, pos);
+ ZoneList<Expression*>* args = new (zone_) ZoneList<Expression*>(0, zone_);
+ return NewCall(prop, args, pos);
+ }
+
private:
Zone* zone_;
AstValueFactory* ast_value_factory_;
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/preparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698