Index: src/ast/ast.cc |
diff --git a/src/ast/ast.cc b/src/ast/ast.cc |
index b8ed4a287fab5121951e7adfc49f1ad2f85190d1..3408ddec00c4ddc3b810c5fed035c3835b26fcb1 100644 |
--- a/src/ast/ast.cc |
+++ b/src/ast/ast.cc |
@@ -23,7 +23,7 @@ namespace internal { |
// ---------------------------------------------------------------------------- |
// All the Accept member functions for each syntax tree node type. |
-#define DECL_ACCEPT(type) \ |
+#define DECL_ACCEPT(type) \ |
void type::Accept(AstVisitor* v) { v->Visit##type(this); } |
AST_NODE_LIST(DECL_ACCEPT) |
#undef DECL_ACCEPT |
@@ -168,18 +168,30 @@ void CountOperation::AssignFeedbackVectorSlots(Isolate* isolate, |
Token::Value Assignment::binary_op() const { |
switch (op()) { |
- case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
- case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
- case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
- case Token::ASSIGN_SHL: return Token::SHL; |
- case Token::ASSIGN_SAR: return Token::SAR; |
- case Token::ASSIGN_SHR: return Token::SHR; |
- case Token::ASSIGN_ADD: return Token::ADD; |
- case Token::ASSIGN_SUB: return Token::SUB; |
- case Token::ASSIGN_MUL: return Token::MUL; |
- case Token::ASSIGN_DIV: return Token::DIV; |
- case Token::ASSIGN_MOD: return Token::MOD; |
- default: UNREACHABLE(); |
+ case Token::ASSIGN_BIT_OR: |
+ return Token::BIT_OR; |
+ case Token::ASSIGN_BIT_XOR: |
+ return Token::BIT_XOR; |
+ case Token::ASSIGN_BIT_AND: |
+ return Token::BIT_AND; |
+ case Token::ASSIGN_SHL: |
+ return Token::SHL; |
+ case Token::ASSIGN_SAR: |
+ return Token::SAR; |
+ case Token::ASSIGN_SHR: |
+ return Token::SHR; |
+ case Token::ASSIGN_ADD: |
+ return Token::ADD; |
+ case Token::ASSIGN_SUB: |
+ return Token::SUB; |
+ case Token::ASSIGN_MUL: |
+ return Token::MUL; |
+ case Token::ASSIGN_DIV: |
+ return Token::DIV; |
+ case Token::ASSIGN_MOD: |
+ return Token::MOD; |
+ default: |
+ UNREACHABLE(); |
} |
return Token::ILLEGAL; |
} |
@@ -200,9 +212,7 @@ int FunctionLiteral::start_position() const { |
} |
-int FunctionLiteral::end_position() const { |
- return scope()->end_position(); |
-} |
+int FunctionLiteral::end_position() const { return scope()->end_position(); } |
LanguageMode FunctionLiteral::language_mode() const { |
@@ -271,9 +281,8 @@ void ClassLiteral::AssignFeedbackVectorSlots(Isolate* isolate, |
bool ObjectLiteral::Property::IsCompileTimeValue() { |
- return kind_ == CONSTANT || |
- (kind_ == MATERIALIZED_LITERAL && |
- CompileTimeValue::IsCompileTimeValue(value_)); |
+ return kind_ == CONSTANT || (kind_ == MATERIALIZED_LITERAL && |
+ CompileTimeValue::IsCompileTimeValue(value_)); |
} |
@@ -282,9 +291,7 @@ void ObjectLiteral::Property::set_emit_store(bool emit_store) { |
} |
-bool ObjectLiteral::Property::emit_store() { |
- return emit_store_; |
-} |
+bool ObjectLiteral::Property::emit_store() { return emit_store_; } |
void ObjectLiteral::AssignFeedbackVectorSlots(Isolate* isolate, |
@@ -391,8 +398,8 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) { |
if (!constant_properties_.is_null()) return; |
// Allocate a fixed array to hold all the constant properties. |
- Handle<FixedArray> constant_properties = isolate->factory()->NewFixedArray( |
- boilerplate_properties_ * 2, TENURED); |
+ Handle<FixedArray> constant_properties = |
+ isolate->factory()->NewFixedArray(boilerplate_properties_ * 2, TENURED); |
int position = 0; |
// Accumulate the value in local variables and store it at the end. |
@@ -443,15 +450,15 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) { |
// much larger than the number of elements, creating an object |
// literal with fast elements will be a waste of space. |
uint32_t element_index = 0; |
- if (key->IsString() |
- && Handle<String>::cast(key)->AsArrayIndex(&element_index) |
- && element_index > max_element_index) { |
+ if (key->IsString() && |
+ Handle<String>::cast(key)->AsArrayIndex(&element_index) && |
+ element_index > max_element_index) { |
max_element_index = element_index; |
elements++; |
} else if (key->IsSmi()) { |
int key_value = Smi::cast(*key)->value(); |
- if (key_value > 0 |
- && static_cast<uint32_t>(key_value) > max_element_index) { |
+ if (key_value > 0 && |
+ static_cast<uint32_t>(key_value) > max_element_index) { |
max_element_index = key_value; |
} |
elements++; |
@@ -611,10 +618,8 @@ static bool IsTypeof(Expression* expr) { |
// Check for the pattern: typeof <expression> equals <string literal>. |
-static bool MatchLiteralCompareTypeof(Expression* left, |
- Token::Value op, |
- Expression* right, |
- Expression** expr, |
+static bool MatchLiteralCompareTypeof(Expression* left, Token::Value op, |
+ Expression* right, Expression** expr, |
Handle<String>* check) { |
if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { |
*expr = left->AsUnaryOperation()->expression(); |
@@ -628,24 +633,21 @@ static bool MatchLiteralCompareTypeof(Expression* left, |
bool CompareOperation::IsLiteralCompareTypeof(Expression** expr, |
Handle<String>* check) { |
return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) || |
- MatchLiteralCompareTypeof(right_, op_, left_, expr, check); |
+ MatchLiteralCompareTypeof(right_, op_, left_, expr, check); |
} |
static bool IsVoidOfLiteral(Expression* expr) { |
UnaryOperation* maybe_unary = expr->AsUnaryOperation(); |
- return maybe_unary != NULL && |
- maybe_unary->op() == Token::VOID && |
- maybe_unary->expression()->IsLiteral(); |
+ return maybe_unary != NULL && maybe_unary->op() == Token::VOID && |
+ maybe_unary->expression()->IsLiteral(); |
} |
// Check for the pattern: void <literal> equals <expression> or |
// undefined equals <expression> |
-static bool MatchLiteralCompareUndefined(Expression* left, |
- Token::Value op, |
- Expression* right, |
- Expression** expr, |
+static bool MatchLiteralCompareUndefined(Expression* left, Token::Value op, |
+ Expression* right, Expression** expr, |
Isolate* isolate) { |
if (IsVoidOfLiteral(left) && Token::IsEqualityOp(op)) { |
*expr = right; |
@@ -659,18 +661,16 @@ static bool MatchLiteralCompareUndefined(Expression* left, |
} |
-bool CompareOperation::IsLiteralCompareUndefined( |
- Expression** expr, Isolate* isolate) { |
+bool CompareOperation::IsLiteralCompareUndefined(Expression** expr, |
+ Isolate* isolate) { |
return MatchLiteralCompareUndefined(left_, op_, right_, expr, isolate) || |
- MatchLiteralCompareUndefined(right_, op_, left_, expr, isolate); |
+ MatchLiteralCompareUndefined(right_, op_, left_, expr, isolate); |
} |
// Check for the pattern: null equals <expression> |
-static bool MatchLiteralCompareNull(Expression* left, |
- Token::Value op, |
- Expression* right, |
- Expression** expr) { |
+static bool MatchLiteralCompareNull(Expression* left, Token::Value op, |
+ Expression* right, Expression** expr) { |
if (left->IsNullLiteral() && Token::IsEqualityOp(op)) { |
*expr = right; |
return true; |
@@ -681,7 +681,7 @@ static bool MatchLiteralCompareNull(Expression* left, |
bool CompareOperation::IsLiteralCompareNull(Expression** expr) { |
return MatchLiteralCompareNull(left_, op_, right_, expr) || |
- MatchLiteralCompareNull(right_, op_, left_, expr); |
+ MatchLiteralCompareNull(right_, op_, left_, expr); |
} |
@@ -692,9 +692,7 @@ bool Declaration::IsInlineable() const { |
return proxy()->var()->IsStackAllocated(); |
} |
-bool FunctionDeclaration::IsInlineable() const { |
- return false; |
-} |
+bool FunctionDeclaration::IsInlineable() const { return false; } |
// ---------------------------------------------------------------------------- |
@@ -797,25 +795,21 @@ void AstVisitor::VisitExpressions(ZoneList<Expression*>* expressions) { |
// ---------------------------------------------------------------------------- |
// Regular expressions |
-#define MAKE_ACCEPT(Name) \ |
- void* RegExp##Name::Accept(RegExpVisitor* visitor, void* data) { \ |
- return visitor->Visit##Name(this, data); \ |
+#define MAKE_ACCEPT(Name) \ |
+ void* RegExp##Name::Accept(RegExpVisitor* visitor, void* data) { \ |
+ return visitor->Visit##Name(this, data); \ |
} |
FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ACCEPT) |
#undef MAKE_ACCEPT |
-#define MAKE_TYPE_CASE(Name) \ |
- RegExp##Name* RegExpTree::As##Name() { \ |
- return NULL; \ |
- } \ |
+#define MAKE_TYPE_CASE(Name) \ |
+ RegExp##Name* RegExpTree::As##Name() { return NULL; } \ |
bool RegExpTree::Is##Name() { return false; } |
FOR_EACH_REG_EXP_TREE_TYPE(MAKE_TYPE_CASE) |
#undef MAKE_TYPE_CASE |
-#define MAKE_TYPE_CASE(Name) \ |
- RegExp##Name* RegExp##Name::As##Name() { \ |
- return this; \ |
- } \ |
+#define MAKE_TYPE_CASE(Name) \ |
+ RegExp##Name* RegExp##Name::As##Name() { return this; } \ |
bool RegExp##Name::Is##Name() { return true; } |
FOR_EACH_REG_EXP_TREE_TYPE(MAKE_TYPE_CASE) |
#undef MAKE_TYPE_CASE |
@@ -869,8 +863,12 @@ bool RegExpAlternative::IsAnchoredAtStart() { |
ZoneList<RegExpTree*>* nodes = this->nodes(); |
for (int i = 0; i < nodes->length(); i++) { |
RegExpTree* node = nodes->at(i); |
- if (node->IsAnchoredAtStart()) { return true; } |
- if (node->max_match() > 0) { return false; } |
+ if (node->IsAnchoredAtStart()) { |
+ return true; |
+ } |
+ if (node->max_match() > 0) { |
+ return false; |
+ } |
} |
return false; |
} |
@@ -880,8 +878,12 @@ bool RegExpAlternative::IsAnchoredAtEnd() { |
ZoneList<RegExpTree*>* nodes = this->nodes(); |
for (int i = nodes->length() - 1; i >= 0; i--) { |
RegExpTree* node = nodes->at(i); |
- if (node->IsAnchoredAtEnd()) { return true; } |
- if (node->max_match() > 0) { return false; } |
+ if (node->IsAnchoredAtEnd()) { |
+ return true; |
+ } |
+ if (node->max_match() > 0) { |
+ return false; |
+ } |
} |
return false; |
} |
@@ -890,8 +892,7 @@ bool RegExpAlternative::IsAnchoredAtEnd() { |
bool RegExpDisjunction::IsAnchoredAtStart() { |
ZoneList<RegExpTree*>* alternatives = this->alternatives(); |
for (int i = 0; i < alternatives->length(); i++) { |
- if (!alternatives->at(i)->IsAnchoredAtStart()) |
- return false; |
+ if (!alternatives->at(i)->IsAnchoredAtStart()) return false; |
} |
return true; |
} |
@@ -900,8 +901,7 @@ bool RegExpDisjunction::IsAnchoredAtStart() { |
bool RegExpDisjunction::IsAnchoredAtEnd() { |
ZoneList<RegExpTree*>* alternatives = this->alternatives(); |
for (int i = 0; i < alternatives->length(); i++) { |
- if (!alternatives->at(i)->IsAnchoredAtEnd()) |
- return false; |
+ if (!alternatives->at(i)->IsAnchoredAtEnd()) return false; |
} |
return true; |
} |
@@ -912,14 +912,10 @@ bool RegExpLookaround::IsAnchoredAtStart() { |
} |
-bool RegExpCapture::IsAnchoredAtStart() { |
- return body()->IsAnchoredAtStart(); |
-} |
+bool RegExpCapture::IsAnchoredAtStart() { return body()->IsAnchoredAtStart(); } |
-bool RegExpCapture::IsAnchoredAtEnd() { |
- return body()->IsAnchoredAtEnd(); |
-} |
+bool RegExpCapture::IsAnchoredAtEnd() { return body()->IsAnchoredAtEnd(); } |
// Convert regular expression trees to a simple sexp representation. |
@@ -942,7 +938,7 @@ class RegExpUnparser final : public RegExpVisitor { |
void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { |
os_ << "(|"; |
- for (int i = 0; i < that->alternatives()->length(); i++) { |
+ for (int i = 0; i < that->alternatives()->length(); i++) { |
os_ << " "; |
that->alternatives()->at(i)->Accept(this, data); |
} |
@@ -953,7 +949,7 @@ void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { |
void* RegExpUnparser::VisitAlternative(RegExpAlternative* that, void* data) { |
os_ << "(:"; |
- for (int i = 0; i < that->nodes()->length(); i++) { |
+ for (int i = 0; i < that->nodes()->length(); i++) { |
os_ << " "; |
that->nodes()->at(i)->Accept(this, data); |
} |
@@ -970,7 +966,6 @@ void RegExpUnparser::VisitCharacterRange(CharacterRange that) { |
} |
- |
void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that, |
void* data) { |
if (that->is_negated()) os_ << "^"; |
@@ -997,7 +992,7 @@ void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) { |
break; |
case RegExpAssertion::END_OF_LINE: |
os_ << "@$l"; |
- break; |
+ break; |
case RegExpAssertion::BOUNDARY: |
os_ << "@b"; |
break; |