Index: runtime/vm/ast.cc |
diff --git a/runtime/vm/ast.cc b/runtime/vm/ast.cc |
index 69fb0d39ef3728d3d7b59c504ca485cf0ce54993..f97964be06933cfcfa8ec8fe35af15a98397a5f2 100644 |
--- a/runtime/vm/ast.cc |
+++ b/runtime/vm/ast.cc |
@@ -10,7 +10,6 @@ |
#include "vm/object_store.h" |
#include "vm/resolver.h" |
- |
namespace dart { |
#define DEFINE_VISIT_FUNCTION(BaseName) \ |
@@ -21,14 +20,12 @@ namespace dart { |
FOR_EACH_NODE(DEFINE_VISIT_FUNCTION) |
#undef DEFINE_VISIT_FUNCTION |
- |
#define DEFINE_NAME_FUNCTION(BaseName) \ |
const char* BaseName##Node::Name() const { return #BaseName; } |
FOR_EACH_NODE(DEFINE_NAME_FUNCTION) |
#undef DEFINE_NAME_FUNCTION |
- |
const Field* AstNode::MayCloneField(const Field& value) { |
if (Compiler::IsBackgroundCompilation() || |
FLAG_force_clone_compiler_objects) { |
@@ -39,7 +36,6 @@ const Field* AstNode::MayCloneField(const Field& value) { |
} |
} |
- |
// A visitor class to collect all the nodes (including children) into an |
// array. |
class AstNodeCollector : public AstNodeVisitor { |
@@ -60,20 +56,17 @@ class AstNodeCollector : public AstNodeVisitor { |
DISALLOW_COPY_AND_ASSIGN(AstNodeCollector); |
}; |
- |
void SequenceNode::CollectAllNodes(GrowableArray<AstNode*>* nodes) { |
AstNodeCollector node_collector(nodes); |
this->Visit(&node_collector); |
} |
- |
void SequenceNode::VisitChildren(AstNodeVisitor* visitor) const { |
for (intptr_t i = 0; i < this->length(); i++) { |
NodeAt(i)->Visit(visitor); |
} |
} |
- |
void SequenceNode::Add(AstNode* node) { |
if (node->IsReturnNode()) { |
node->AsReturnNode()->set_scope(scope()); |
@@ -81,21 +74,17 @@ void SequenceNode::Add(AstNode* node) { |
nodes_.Add(node); |
} |
- |
void PrimaryNode::VisitChildren(AstNodeVisitor* visitor) const {} |
- |
void ArgumentListNode::VisitChildren(AstNodeVisitor* visitor) const { |
for (intptr_t i = 0; i < this->length(); i++) { |
NodeAt(i)->Visit(visitor); |
} |
} |
- |
LetNode::LetNode(TokenPosition token_pos) |
: AstNode(token_pos), vars_(1), initializers_(1), nodes_(1) {} |
- |
LocalVariable* LetNode::AddInitializer(AstNode* node) { |
Thread* thread = Thread::Current(); |
Zone* zone = thread->zone(); |
@@ -111,7 +100,6 @@ LocalVariable* LetNode::AddInitializer(AstNode* node) { |
return temp_var; |
} |
- |
void LetNode::VisitChildren(AstNodeVisitor* visitor) const { |
for (intptr_t i = 0; i < num_temps(); ++i) { |
initializers_[i]->Visit(visitor); |
@@ -151,14 +139,12 @@ const Instance* LetNode::EvalConstExpr() const { |
return last; |
} |
- |
void ArrayNode::VisitChildren(AstNodeVisitor* visitor) const { |
for (intptr_t i = 0; i < this->length(); i++) { |
ElementAt(i)->Visit(visitor); |
} |
} |
- |
bool StringInterpolateNode::IsPotentiallyConst() const { |
for (int i = 0; i < value_->length(); i++) { |
if (!value_->ElementAt(i)->IsPotentiallyConst()) { |
@@ -168,12 +154,10 @@ bool StringInterpolateNode::IsPotentiallyConst() const { |
return true; |
} |
- |
bool LiteralNode::IsPotentiallyConst() const { |
return true; |
} |
- |
AstNode* LiteralNode::ApplyUnaryOp(Token::Kind unary_op_kind) { |
if (unary_op_kind == Token::kNEGATE) { |
if (literal().IsSmi()) { |
@@ -218,24 +202,20 @@ AstNode* LiteralNode::ApplyUnaryOp(Token::Kind unary_op_kind) { |
return NULL; |
} |
- |
const char* TypeNode::TypeName() const { |
return String::Handle(type().UserVisibleName()).ToCString(); |
} |
- |
bool ComparisonNode::IsKindValid() const { |
return Token::IsRelationalOperator(kind_) || |
Token::IsEqualityOperator(kind_) || Token::IsTypeTestOperator(kind_) || |
Token::IsTypeCastOperator(kind_); |
} |
- |
const char* ComparisonNode::TokenName() const { |
return (kind_ == Token::kAS) ? "as" : Token::Str(kind_); |
} |
- |
bool ComparisonNode::IsPotentiallyConst() const { |
switch (kind_) { |
case Token::kLT: |
@@ -253,7 +233,6 @@ bool ComparisonNode::IsPotentiallyConst() const { |
} |
} |
- |
const Instance* ComparisonNode::EvalConstExpr() const { |
const Instance* left_val = this->left()->EvalConstExpr(); |
if (left_val == NULL) { |
@@ -295,7 +274,6 @@ const Instance* ComparisonNode::EvalConstExpr() const { |
return NULL; |
} |
- |
bool BinaryOpNode::IsKindValid() const { |
switch (kind_) { |
case Token::kADD: |
@@ -318,12 +296,10 @@ bool BinaryOpNode::IsKindValid() const { |
} |
} |
- |
const char* BinaryOpNode::TokenName() const { |
return Token::Str(kind_); |
} |
- |
bool BinaryOpNode::IsPotentiallyConst() const { |
switch (kind_) { |
case Token::kOR: |
@@ -357,7 +333,6 @@ bool BinaryOpNode::IsPotentiallyConst() const { |
} |
} |
- |
const Instance* BinaryOpNode::EvalConstExpr() const { |
const Instance* left_val = this->left()->EvalConstExpr(); |
if (left_val == NULL) { |
@@ -419,7 +394,6 @@ const Instance* BinaryOpNode::EvalConstExpr() const { |
return NULL; |
} |
- |
AstNode* UnaryOpNode::UnaryOpOrLiteral(TokenPosition token_pos, |
Token::Kind kind, |
AstNode* operand) { |
@@ -430,7 +404,6 @@ AstNode* UnaryOpNode::UnaryOpOrLiteral(TokenPosition token_pos, |
return new UnaryOpNode(token_pos, kind, operand); |
} |
- |
bool UnaryOpNode::IsKindValid() const { |
switch (kind_) { |
case Token::kNEGATE: |
@@ -442,7 +415,6 @@ bool UnaryOpNode::IsKindValid() const { |
} |
} |
- |
bool UnaryOpNode::IsPotentiallyConst() const { |
if (this->operand()->IsLiteralNode() && |
this->operand()->AsLiteralNode()->literal().IsNull()) { |
@@ -451,7 +423,6 @@ bool UnaryOpNode::IsPotentiallyConst() const { |
return this->operand()->IsPotentiallyConst(); |
} |
- |
const Instance* UnaryOpNode::EvalConstExpr() const { |
const Instance* val = this->operand()->EvalConstExpr(); |
if (val == NULL) { |
@@ -469,14 +440,12 @@ const Instance* UnaryOpNode::EvalConstExpr() const { |
} |
} |
- |
bool ConditionalExprNode::IsPotentiallyConst() const { |
return this->condition()->IsPotentiallyConst() && |
this->true_expr()->IsPotentiallyConst() && |
this->false_expr()->IsPotentiallyConst(); |
} |
- |
const Instance* ConditionalExprNode::EvalConstExpr() const { |
const Instance* cond = this->condition()->EvalConstExpr(); |
if ((cond != NULL) && cond->IsBool() && |
@@ -487,7 +456,6 @@ const Instance* ConditionalExprNode::EvalConstExpr() const { |
return NULL; |
} |
- |
bool ClosureNode::IsPotentiallyConst() const { |
if (function().IsImplicitStaticClosureFunction()) { |
return true; |
@@ -495,7 +463,6 @@ bool ClosureNode::IsPotentiallyConst() const { |
return false; |
} |
- |
const Instance* ClosureNode::EvalConstExpr() const { |
if (!is_deferred_reference_ && function().IsImplicitStaticClosureFunction()) { |
// Return a value that represents an instance. Only the type is relevant. |
@@ -504,7 +471,6 @@ const Instance* ClosureNode::EvalConstExpr() const { |
return NULL; |
} |
- |
AstNode* ClosureNode::MakeAssignmentNode(AstNode* rhs) { |
if (scope() == NULL) { |
// This is an implicit closure node created because a static getter was not |
@@ -517,17 +483,14 @@ AstNode* ClosureNode::MakeAssignmentNode(AstNode* rhs) { |
return NULL; |
} |
- |
const char* UnaryOpNode::TokenName() const { |
return Token::Str(kind_); |
} |
- |
const char* JumpNode::TokenName() const { |
return Token::Str(kind_); |
} |
- |
bool LoadLocalNode::IsPotentiallyConst() const { |
// Parameters of const constructors are implicitly final and can be |
// used in initializer expressions. |
@@ -537,7 +500,6 @@ bool LoadLocalNode::IsPotentiallyConst() const { |
return local().is_final(); |
} |
- |
const Instance* LoadLocalNode::EvalConstExpr() const { |
if (local().IsConst()) { |
return local().ConstValue(); |
@@ -545,7 +507,6 @@ const Instance* LoadLocalNode::EvalConstExpr() const { |
return NULL; |
} |
- |
AstNode* LoadLocalNode::MakeAssignmentNode(AstNode* rhs) { |
if (local().is_final()) { |
return NULL; |
@@ -553,7 +514,6 @@ AstNode* LoadLocalNode::MakeAssignmentNode(AstNode* rhs) { |
return new StoreLocalNode(token_pos(), &local(), rhs); |
} |
- |
AstNode* LoadStaticFieldNode::MakeAssignmentNode(AstNode* rhs) { |
if (field().is_final()) { |
return NULL; |
@@ -567,19 +527,16 @@ AstNode* LoadStaticFieldNode::MakeAssignmentNode(AstNode* rhs) { |
Field::ZoneHandle(field().Original()), rhs); |
} |
- |
AstNode* InstanceGetterNode::MakeAssignmentNode(AstNode* rhs) { |
return new InstanceSetterNode(token_pos(), receiver(), field_name(), rhs, |
is_conditional()); |
} |
- |
bool InstanceGetterNode::IsPotentiallyConst() const { |
return field_name().Equals(Symbols::Length()) && !is_conditional() && |
receiver()->IsPotentiallyConst(); |
} |
- |
const Instance* InstanceGetterNode::EvalConstExpr() const { |
if (field_name().Equals(Symbols::Length()) && !is_conditional()) { |
const Instance* receiver_val = receiver()->EvalConstExpr(); |
@@ -590,13 +547,11 @@ const Instance* InstanceGetterNode::EvalConstExpr() const { |
return NULL; |
} |
- |
AstNode* LoadIndexedNode::MakeAssignmentNode(AstNode* rhs) { |
return new StoreIndexedNode(token_pos(), array(), index_expr(), rhs, |
super_class()); |
} |
- |
AstNode* StaticGetterNode::MakeAssignmentNode(AstNode* rhs) { |
Thread* thread = Thread::Current(); |
Zone* zone = thread->zone(); |
@@ -736,7 +691,6 @@ AstNode* StaticGetterNode::MakeAssignmentNode(AstNode* rhs) { |
return new StaticSetterNode(token_pos(), NULL, cls(), field_name_, rhs); |
} |
- |
AstNode* StaticCallNode::MakeAssignmentNode(AstNode* rhs) { |
// Return this node if it represents a 'throw NoSuchMethodError' indicating |
// that a getter was not found, otherwise return null. |
@@ -750,7 +704,6 @@ AstNode* StaticCallNode::MakeAssignmentNode(AstNode* rhs) { |
return NULL; |
} |
- |
bool StaticGetterNode::IsPotentiallyConst() const { |
if (is_deferred_reference_) { |
return false; |
@@ -765,7 +718,6 @@ bool StaticGetterNode::IsPotentiallyConst() const { |
return true; |
} |
- |
const Instance* StaticGetterNode::EvalConstExpr() const { |
if (is_deferred_reference_) { |
return NULL; |