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

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

Issue 2287173002: Replace CollectVariables with locals(), update callsites to walk locals instead (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: restore undefined handling Created 4 years, 3 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 | « src/ast/ast.h ('k') | src/ast/scopeinfo.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 #include "src/ast/ast.h" 5 #include "src/ast/ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 8
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 bool Expression::IsPropertyName() const { 76 bool Expression::IsPropertyName() const {
77 return IsLiteral() && AsLiteral()->IsPropertyName(); 77 return IsLiteral() && AsLiteral()->IsPropertyName();
78 } 78 }
79 79
80 bool Expression::IsNullLiteral() const { 80 bool Expression::IsNullLiteral() const {
81 if (!IsLiteral()) return false; 81 if (!IsLiteral()) return false;
82 return AsLiteral()->raw_value()->IsNull(); 82 return AsLiteral()->raw_value()->IsNull();
83 } 83 }
84 84
85 bool Expression::IsUndefinedLiteral() const { 85 bool Expression::IsUndefinedLiteral() const {
86 if (IsLiteral()) { 86 if (IsLiteral() && AsLiteral()->raw_value()->IsUndefined()) return true;
87 if (AsLiteral()->raw_value()->IsUndefined()) {
88 return true;
89 }
90 }
91 87
92 const VariableProxy* var_proxy = AsVariableProxy(); 88 const VariableProxy* var_proxy = AsVariableProxy();
93 if (var_proxy == NULL) return false; 89 if (var_proxy == nullptr) return false;
94 Variable* var = var_proxy->var(); 90 Variable* var = var_proxy->var();
95 // The global identifier "undefined" is immutable. Everything 91 // The global identifier "undefined" is immutable. Everything
96 // else could be reassigned. 92 // else could be reassigned.
97 return var != NULL && var->IsUnallocatedOrGlobalSlot() && 93 return var != NULL && var->IsUnallocated() &&
98 var_proxy->raw_name()->IsOneByteEqualTo("undefined"); 94 var_proxy->raw_name()->IsOneByteEqualTo("undefined");
99 } 95 }
100 96
101 bool Expression::ToBooleanIsTrue() const { 97 bool Expression::ToBooleanIsTrue() const {
102 return IsLiteral() && AsLiteral()->ToBooleanIsTrue(); 98 return IsLiteral() && AsLiteral()->ToBooleanIsTrue();
103 } 99 }
104 100
105 bool Expression::ToBooleanIsFalse() const { 101 bool Expression::ToBooleanIsFalse() const {
106 return IsLiteral() && AsLiteral()->ToBooleanIsFalse(); 102 return IsLiteral() && AsLiteral()->ToBooleanIsFalse();
107 } 103 }
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 if (IsUsingCallFeedbackSlot()) { 902 if (IsUsingCallFeedbackSlot()) {
907 stub_slot_ = spec->AddGeneralSlot(); 903 stub_slot_ = spec->AddGeneralSlot();
908 } 904 }
909 } 905 }
910 906
911 Call::CallType Call::GetCallType() const { 907 Call::CallType Call::GetCallType() const {
912 VariableProxy* proxy = expression()->AsVariableProxy(); 908 VariableProxy* proxy = expression()->AsVariableProxy();
913 if (proxy != NULL) { 909 if (proxy != NULL) {
914 if (is_possibly_eval()) { 910 if (is_possibly_eval()) {
915 return POSSIBLY_EVAL_CALL; 911 return POSSIBLY_EVAL_CALL;
916 } else if (proxy->var()->IsUnallocatedOrGlobalSlot()) { 912 } else if (proxy->var()->IsUnallocated()) {
917 return GLOBAL_CALL; 913 return GLOBAL_CALL;
918 } else if (proxy->var()->IsLookupSlot()) { 914 } else if (proxy->var()->IsLookupSlot()) {
919 return LOOKUP_SLOT_CALL; 915 return LOOKUP_SLOT_CALL;
920 } 916 }
921 } 917 }
922 918
923 if (expression()->IsSuperCallReference()) return SUPER_CALL; 919 if (expression()->IsSuperCallReference()) return SUPER_CALL;
924 920
925 Property* property = expression()->AsProperty(); 921 Property* property = expression()->AsProperty();
926 if (property != nullptr) { 922 if (property != nullptr) {
(...skipping 25 matching lines...) Expand all
952 // static 948 // static
953 bool Literal::Match(void* literal1, void* literal2) { 949 bool Literal::Match(void* literal1, void* literal2) {
954 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 950 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
955 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 951 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
956 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 952 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
957 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 953 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
958 } 954 }
959 955
960 } // namespace internal 956 } // namespace internal
961 } // namespace v8 957 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698