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

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

Issue 2004363002: Refactor duplicate logic in Ast{Traversal,Expression}Visitor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Undefine utility macros Created 4 years, 6 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/ast-expression-visitor.h » ('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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 // undefined expression or literal? Revisit this code if this 809 // undefined expression or literal? Revisit this code if this
810 // changes 810 // changes
811 Expression* expression = expressions->at(i); 811 Expression* expression = expressions->at(i);
812 if (expression != NULL) Visit(expression); 812 if (expression != NULL) Visit(expression);
813 } 813 }
814 } 814 }
815 815
816 // ---------------------------------------------------------------------------- 816 // ----------------------------------------------------------------------------
817 // Implementation of AstTraversalVisitor 817 // Implementation of AstTraversalVisitor
818 818
819 AstTraversalVisitor::AstTraversalVisitor(Isolate* isolate) { 819 #define RECURSE(call) \
820 do { \
821 DCHECK(!HasStackOverflow()); \
822 call; \
823 if (HasStackOverflow()) return; \
824 } while (false)
825
826 #define RECURSE_EXPRESSION(call) \
827 do { \
828 DCHECK(!HasStackOverflow()); \
829 ++depth_; \
830 call; \
831 --depth_; \
832 if (HasStackOverflow()) return; \
833 } while (false)
834
835 AstTraversalVisitor::AstTraversalVisitor(Isolate* isolate) : depth_(0) {
820 InitializeAstVisitor(isolate); 836 InitializeAstVisitor(isolate);
821 } 837 }
822 838
839 AstTraversalVisitor::AstTraversalVisitor(uintptr_t stack_limit) : depth_(0) {
840 InitializeAstVisitor(stack_limit);
841 }
842
843 void AstTraversalVisitor::VisitDeclarations(ZoneList<Declaration*>* decls) {
844 for (int i = 0; i < decls->length(); ++i) {
845 Declaration* decl = decls->at(i);
846 RECURSE(Visit(decl));
847 }
848 }
849
850 void AstTraversalVisitor::VisitStatements(ZoneList<Statement*>* stmts) {
851 for (int i = 0; i < stmts->length(); ++i) {
852 Statement* stmt = stmts->at(i);
853 RECURSE(Visit(stmt));
854 if (stmt->IsJump()) break;
855 }
856 }
857
823 void AstTraversalVisitor::VisitVariableDeclaration(VariableDeclaration* decl) {} 858 void AstTraversalVisitor::VisitVariableDeclaration(VariableDeclaration* decl) {}
824 859
825 void AstTraversalVisitor::VisitFunctionDeclaration(FunctionDeclaration* decl) { 860 void AstTraversalVisitor::VisitFunctionDeclaration(FunctionDeclaration* decl) {
826 Visit(decl->fun()); 861 RECURSE(Visit(decl->fun()));
827 } 862 }
828 863
829 void AstTraversalVisitor::VisitImportDeclaration(ImportDeclaration* decl) {} 864 void AstTraversalVisitor::VisitImportDeclaration(ImportDeclaration* decl) {}
830 865
831 void AstTraversalVisitor::VisitExportDeclaration(ExportDeclaration* decl) {} 866 void AstTraversalVisitor::VisitExportDeclaration(ExportDeclaration* decl) {}
832 867
833 void AstTraversalVisitor::VisitStatements(ZoneList<Statement*>* stmts) {
834 for (int i = 0; i < stmts->length(); ++i) {
835 Statement* stmt = stmts->at(i);
836 Visit(stmt);
837 if (stmt->IsJump()) break;
838 }
839 }
840
841 void AstTraversalVisitor::VisitExpressions(ZoneList<Expression*>* expressions) {
842 for (int i = 0; i < expressions->length(); i++) {
843 Expression* expression = expressions->at(i);
844 if (expression != NULL) Visit(expression);
845 }
846 }
847
848 void AstTraversalVisitor::VisitBlock(Block* stmt) { 868 void AstTraversalVisitor::VisitBlock(Block* stmt) {
849 VisitStatements(stmt->statements()); 869 RECURSE(VisitStatements(stmt->statements()));
850 } 870 }
851 871
852 void AstTraversalVisitor::VisitExpressionStatement(ExpressionStatement* stmt) { 872 void AstTraversalVisitor::VisitExpressionStatement(ExpressionStatement* stmt) {
853 Visit(stmt->expression()); 873 RECURSE(Visit(stmt->expression()));
854 } 874 }
855 875
856 void AstTraversalVisitor::VisitEmptyStatement(EmptyStatement* stmt) {} 876 void AstTraversalVisitor::VisitEmptyStatement(EmptyStatement* stmt) {}
857 877
858 void AstTraversalVisitor::VisitSloppyBlockFunctionStatement( 878 void AstTraversalVisitor::VisitSloppyBlockFunctionStatement(
859 SloppyBlockFunctionStatement* stmt) { 879 SloppyBlockFunctionStatement* stmt) {
860 Visit(stmt->statement()); 880 RECURSE(Visit(stmt->statement()));
861 } 881 }
862 882
863 void AstTraversalVisitor::VisitIfStatement(IfStatement* stmt) { 883 void AstTraversalVisitor::VisitIfStatement(IfStatement* stmt) {
864 Visit(stmt->condition()); 884 RECURSE(Visit(stmt->condition()));
865 Visit(stmt->then_statement()); 885 RECURSE(Visit(stmt->then_statement()));
866 Visit(stmt->else_statement()); 886 RECURSE(Visit(stmt->else_statement()));
867 } 887 }
868 888
869 void AstTraversalVisitor::VisitContinueStatement(ContinueStatement* stmt) {} 889 void AstTraversalVisitor::VisitContinueStatement(ContinueStatement* stmt) {}
870 890
871 void AstTraversalVisitor::VisitBreakStatement(BreakStatement* stmt) {} 891 void AstTraversalVisitor::VisitBreakStatement(BreakStatement* stmt) {}
872 892
873 void AstTraversalVisitor::VisitReturnStatement(ReturnStatement* stmt) { 893 void AstTraversalVisitor::VisitReturnStatement(ReturnStatement* stmt) {
874 Visit(stmt->expression()); 894 RECURSE(Visit(stmt->expression()));
875 } 895 }
876 896
877 void AstTraversalVisitor::VisitWithStatement(WithStatement* stmt) { 897 void AstTraversalVisitor::VisitWithStatement(WithStatement* stmt) {
878 stmt->expression(); 898 RECURSE(stmt->expression());
879 stmt->statement(); 899 RECURSE(stmt->statement());
880 } 900 }
881 901
882 void AstTraversalVisitor::VisitSwitchStatement(SwitchStatement* stmt) { 902 void AstTraversalVisitor::VisitSwitchStatement(SwitchStatement* stmt) {
883 Visit(stmt->tag()); 903 RECURSE(Visit(stmt->tag()));
884 904
885 ZoneList<CaseClause*>* clauses = stmt->cases(); 905 ZoneList<CaseClause*>* clauses = stmt->cases();
886 906
887 for (int i = 0; i < clauses->length(); ++i) { 907 for (int i = 0; i < clauses->length(); ++i) {
888 CaseClause* clause = clauses->at(i); 908 CaseClause* clause = clauses->at(i);
889 if (!clause->is_default()) { 909 if (!clause->is_default()) {
890 Expression* label = clause->label(); 910 Expression* label = clause->label();
891 Visit(label); 911 RECURSE(Visit(label));
892 } 912 }
893 ZoneList<Statement*>* stmts = clause->statements(); 913 ZoneList<Statement*>* stmts = clause->statements();
894 VisitStatements(stmts); 914 RECURSE(VisitStatements(stmts));
895 } 915 }
896 } 916 }
897 917
898 void AstTraversalVisitor::VisitCaseClause(CaseClause* clause) { UNREACHABLE(); } 918 void AstTraversalVisitor::VisitCaseClause(CaseClause* clause) { UNREACHABLE(); }
899 919
900 void AstTraversalVisitor::VisitDoWhileStatement(DoWhileStatement* stmt) { 920 void AstTraversalVisitor::VisitDoWhileStatement(DoWhileStatement* stmt) {
901 Visit(stmt->body()); 921 RECURSE(Visit(stmt->body()));
902 Visit(stmt->cond()); 922 RECURSE(Visit(stmt->cond()));
903 } 923 }
904 924
905 void AstTraversalVisitor::VisitWhileStatement(WhileStatement* stmt) { 925 void AstTraversalVisitor::VisitWhileStatement(WhileStatement* stmt) {
906 Visit(stmt->cond()); 926 RECURSE(Visit(stmt->cond()));
907 Visit(stmt->body()); 927 RECURSE(Visit(stmt->body()));
908 } 928 }
909 929
910 void AstTraversalVisitor::VisitForStatement(ForStatement* stmt) { 930 void AstTraversalVisitor::VisitForStatement(ForStatement* stmt) {
911 if (stmt->init() != NULL) { 931 if (stmt->init() != NULL) {
912 Visit(stmt->init()); 932 RECURSE(Visit(stmt->init()));
913 } 933 }
914 if (stmt->cond() != NULL) { 934 if (stmt->cond() != NULL) {
915 Visit(stmt->cond()); 935 RECURSE(Visit(stmt->cond()));
916 } 936 }
917 if (stmt->next() != NULL) { 937 if (stmt->next() != NULL) {
918 Visit(stmt->next()); 938 RECURSE(Visit(stmt->next()));
919 } 939 }
920 Visit(stmt->body()); 940 RECURSE(Visit(stmt->body()));
921 } 941 }
922 942
923 void AstTraversalVisitor::VisitForInStatement(ForInStatement* stmt) { 943 void AstTraversalVisitor::VisitForInStatement(ForInStatement* stmt) {
924 Visit(stmt->enumerable()); 944 RECURSE(Visit(stmt->enumerable()));
925 Visit(stmt->body()); 945 RECURSE(Visit(stmt->body()));
926 } 946 }
927 947
928 void AstTraversalVisitor::VisitForOfStatement(ForOfStatement* stmt) { 948 void AstTraversalVisitor::VisitForOfStatement(ForOfStatement* stmt) {
929 Visit(stmt->assign_iterator()); 949 RECURSE(Visit(stmt->assign_iterator()));
930 Visit(stmt->next_result()); 950 RECURSE(Visit(stmt->next_result()));
931 Visit(stmt->result_done()); 951 RECURSE(Visit(stmt->result_done()));
932 Visit(stmt->assign_each()); 952 RECURSE(Visit(stmt->assign_each()));
933 Visit(stmt->body()); 953 RECURSE(Visit(stmt->body()));
934 } 954 }
935 955
936 void AstTraversalVisitor::VisitTryCatchStatement(TryCatchStatement* stmt) { 956 void AstTraversalVisitor::VisitTryCatchStatement(TryCatchStatement* stmt) {
937 Visit(stmt->try_block()); 957 RECURSE(Visit(stmt->try_block()));
938 Visit(stmt->catch_block()); 958 RECURSE(Visit(stmt->catch_block()));
939 } 959 }
940 960
941 void AstTraversalVisitor::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 961 void AstTraversalVisitor::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
942 Visit(stmt->try_block()); 962 RECURSE(Visit(stmt->try_block()));
943 Visit(stmt->finally_block()); 963 RECURSE(Visit(stmt->finally_block()));
944 } 964 }
945 965
946 void AstTraversalVisitor::VisitDebuggerStatement(DebuggerStatement* stmt) {} 966 void AstTraversalVisitor::VisitDebuggerStatement(DebuggerStatement* stmt) {}
947 967
948 void AstTraversalVisitor::VisitFunctionLiteral(FunctionLiteral* expr) { 968 void AstTraversalVisitor::VisitFunctionLiteral(FunctionLiteral* expr) {
949 Scope* scope = expr->scope(); 969 Scope* scope = expr->scope();
950 VisitDeclarations(scope->declarations()); 970 RECURSE_EXPRESSION(VisitDeclarations(scope->declarations()));
951 VisitStatements(expr->body()); 971 RECURSE_EXPRESSION(VisitStatements(expr->body()));
952 } 972 }
953 973
954 void AstTraversalVisitor::VisitNativeFunctionLiteral( 974 void AstTraversalVisitor::VisitNativeFunctionLiteral(
955 NativeFunctionLiteral* expr) {} 975 NativeFunctionLiteral* expr) {}
956 976
957 void AstTraversalVisitor::VisitDoExpression(DoExpression* expr) { 977 void AstTraversalVisitor::VisitDoExpression(DoExpression* expr) {
958 VisitBlock(expr->block()); 978 RECURSE(VisitBlock(expr->block()));
959 VisitVariableProxy(expr->result()); 979 RECURSE(VisitVariableProxy(expr->result()));
960 } 980 }
961 981
962 void AstTraversalVisitor::VisitConditional(Conditional* expr) { 982 void AstTraversalVisitor::VisitConditional(Conditional* expr) {
963 Visit(expr->condition()); 983 RECURSE_EXPRESSION(Visit(expr->condition()));
964 Visit(expr->then_expression()); 984 RECURSE_EXPRESSION(Visit(expr->then_expression()));
965 Visit(expr->else_expression()); 985 RECURSE_EXPRESSION(Visit(expr->else_expression()));
966 } 986 }
967 987
968 void AstTraversalVisitor::VisitVariableProxy(VariableProxy* expr) {} 988 void AstTraversalVisitor::VisitVariableProxy(VariableProxy* expr) {}
969 989
970 void AstTraversalVisitor::VisitLiteral(Literal* expr) {} 990 void AstTraversalVisitor::VisitLiteral(Literal* expr) {}
971 991
972 void AstTraversalVisitor::VisitRegExpLiteral(RegExpLiteral* expr) {} 992 void AstTraversalVisitor::VisitRegExpLiteral(RegExpLiteral* expr) {}
973 993
974 void AstTraversalVisitor::VisitObjectLiteral(ObjectLiteral* expr) { 994 void AstTraversalVisitor::VisitObjectLiteral(ObjectLiteral* expr) {
975 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); 995 ZoneList<ObjectLiteralProperty*>* props = expr->properties();
976 for (int i = 0; i < props->length(); ++i) { 996 for (int i = 0; i < props->length(); ++i) {
977 ObjectLiteralProperty* prop = props->at(i); 997 ObjectLiteralProperty* prop = props->at(i);
978 if (!prop->key()->IsLiteral()) { 998 if (!prop->key()->IsLiteral()) {
979 Visit(prop->key()); 999 RECURSE_EXPRESSION(Visit(prop->key()));
980 } 1000 }
981 Visit(prop->value()); 1001 RECURSE_EXPRESSION(Visit(prop->value()));
982 } 1002 }
983 } 1003 }
984 1004
985 void AstTraversalVisitor::VisitArrayLiteral(ArrayLiteral* expr) { 1005 void AstTraversalVisitor::VisitArrayLiteral(ArrayLiteral* expr) {
986 ZoneList<Expression*>* values = expr->values(); 1006 ZoneList<Expression*>* values = expr->values();
987 for (int i = 0; i < values->length(); ++i) { 1007 for (int i = 0; i < values->length(); ++i) {
988 Expression* value = values->at(i); 1008 Expression* value = values->at(i);
989 Visit(value); 1009 RECURSE_EXPRESSION(Visit(value));
990 } 1010 }
991 } 1011 }
992 1012
993 void AstTraversalVisitor::VisitAssignment(Assignment* expr) { 1013 void AstTraversalVisitor::VisitAssignment(Assignment* expr) {
994 Visit(expr->target()); 1014 RECURSE_EXPRESSION(Visit(expr->target()));
995 Visit(expr->value()); 1015 RECURSE_EXPRESSION(Visit(expr->value()));
996 } 1016 }
997 1017
998 void AstTraversalVisitor::VisitYield(Yield* expr) { 1018 void AstTraversalVisitor::VisitYield(Yield* expr) {
999 Visit(expr->generator_object()); 1019 RECURSE_EXPRESSION(Visit(expr->generator_object()));
1000 Visit(expr->expression()); 1020 RECURSE_EXPRESSION(Visit(expr->expression()));
1001 } 1021 }
1002 1022
1003 void AstTraversalVisitor::VisitThrow(Throw* expr) { Visit(expr->exception()); } 1023 void AstTraversalVisitor::VisitThrow(Throw* expr) {
1024 RECURSE_EXPRESSION(Visit(expr->exception()));
1025 }
1004 1026
1005 void AstTraversalVisitor::VisitProperty(Property* expr) { 1027 void AstTraversalVisitor::VisitProperty(Property* expr) {
1006 Visit(expr->obj()); 1028 RECURSE_EXPRESSION(Visit(expr->obj()));
1007 Visit(expr->key()); 1029 RECURSE_EXPRESSION(Visit(expr->key()));
1008 } 1030 }
1009 1031
1010 void AstTraversalVisitor::VisitCall(Call* expr) { 1032 void AstTraversalVisitor::VisitCall(Call* expr) {
1011 Visit(expr->expression()); 1033 RECURSE_EXPRESSION(Visit(expr->expression()));
1012 ZoneList<Expression*>* args = expr->arguments(); 1034 ZoneList<Expression*>* args = expr->arguments();
1013 for (int i = 0; i < args->length(); ++i) { 1035 for (int i = 0; i < args->length(); ++i) {
1014 Expression* arg = args->at(i); 1036 Expression* arg = args->at(i);
1015 Visit(arg); 1037 RECURSE_EXPRESSION(Visit(arg));
1016 } 1038 }
1017 } 1039 }
1018 1040
1019 void AstTraversalVisitor::VisitCallNew(CallNew* expr) { 1041 void AstTraversalVisitor::VisitCallNew(CallNew* expr) {
1020 Visit(expr->expression()); 1042 RECURSE_EXPRESSION(Visit(expr->expression()));
1021 ZoneList<Expression*>* args = expr->arguments(); 1043 ZoneList<Expression*>* args = expr->arguments();
1022 for (int i = 0; i < args->length(); ++i) { 1044 for (int i = 0; i < args->length(); ++i) {
1023 Expression* arg = args->at(i); 1045 Expression* arg = args->at(i);
1024 Visit(arg); 1046 RECURSE_EXPRESSION(Visit(arg));
1025 } 1047 }
1026 } 1048 }
1027 1049
1028 void AstTraversalVisitor::VisitCallRuntime(CallRuntime* expr) { 1050 void AstTraversalVisitor::VisitCallRuntime(CallRuntime* expr) {
1029 ZoneList<Expression*>* args = expr->arguments(); 1051 ZoneList<Expression*>* args = expr->arguments();
1030 for (int i = 0; i < args->length(); ++i) { 1052 for (int i = 0; i < args->length(); ++i) {
1031 Expression* arg = args->at(i); 1053 Expression* arg = args->at(i);
1032 Visit(arg); 1054 RECURSE_EXPRESSION(Visit(arg));
1033 } 1055 }
1034 } 1056 }
1035 1057
1036 void AstTraversalVisitor::VisitUnaryOperation(UnaryOperation* expr) { 1058 void AstTraversalVisitor::VisitUnaryOperation(UnaryOperation* expr) {
1037 Visit(expr->expression()); 1059 RECURSE_EXPRESSION(Visit(expr->expression()));
1038 } 1060 }
1039 1061
1040 void AstTraversalVisitor::VisitCountOperation(CountOperation* expr) { 1062 void AstTraversalVisitor::VisitCountOperation(CountOperation* expr) {
1041 Visit(expr->expression()); 1063 RECURSE_EXPRESSION(Visit(expr->expression()));
1042 } 1064 }
1043 1065
1044 void AstTraversalVisitor::VisitBinaryOperation(BinaryOperation* expr) { 1066 void AstTraversalVisitor::VisitBinaryOperation(BinaryOperation* expr) {
1045 Visit(expr->left()); 1067 RECURSE_EXPRESSION(Visit(expr->left()));
1046 Visit(expr->right()); 1068 RECURSE_EXPRESSION(Visit(expr->right()));
1047 } 1069 }
1048 1070
1049 void AstTraversalVisitor::VisitCompareOperation(CompareOperation* expr) { 1071 void AstTraversalVisitor::VisitCompareOperation(CompareOperation* expr) {
1050 Visit(expr->left()); 1072 RECURSE_EXPRESSION(Visit(expr->left()));
1051 Visit(expr->right()); 1073 RECURSE_EXPRESSION(Visit(expr->right()));
1052 } 1074 }
1053 1075
1054 void AstTraversalVisitor::VisitThisFunction(ThisFunction* expr) {} 1076 void AstTraversalVisitor::VisitThisFunction(ThisFunction* expr) {}
1055 1077
1056 void AstTraversalVisitor::VisitDeclarations(ZoneList<Declaration*>* decls) {
1057 for (int i = 0; i < decls->length(); ++i) {
1058 Declaration* decl = decls->at(i);
1059 Visit(decl);
1060 }
1061 }
1062
1063 void AstTraversalVisitor::VisitClassLiteral(ClassLiteral* expr) { 1078 void AstTraversalVisitor::VisitClassLiteral(ClassLiteral* expr) {
1064 if (expr->extends() != nullptr) { 1079 if (expr->extends() != nullptr) {
1065 Visit(expr->extends()); 1080 RECURSE_EXPRESSION(Visit(expr->extends()));
1066 } 1081 }
1067 Visit(expr->constructor()); 1082 RECURSE_EXPRESSION(Visit(expr->constructor()));
1068 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); 1083 ZoneList<ObjectLiteralProperty*>* props = expr->properties();
1069 for (int i = 0; i < props->length(); ++i) { 1084 for (int i = 0; i < props->length(); ++i) {
1070 ObjectLiteralProperty* prop = props->at(i); 1085 ObjectLiteralProperty* prop = props->at(i);
1071 if (!prop->key()->IsLiteral()) { 1086 if (!prop->key()->IsLiteral()) {
1072 Visit(prop->key()); 1087 RECURSE_EXPRESSION(Visit(prop->key()));
1073 } 1088 }
1074 Visit(prop->value()); 1089 RECURSE_EXPRESSION(Visit(prop->value()));
1075 } 1090 }
1076 } 1091 }
1077 1092
1078 void AstTraversalVisitor::VisitSpread(Spread* expr) { 1093 void AstTraversalVisitor::VisitSpread(Spread* expr) {
1079 Visit(expr->expression()); 1094 RECURSE_EXPRESSION(Visit(expr->expression()));
1080 } 1095 }
1081 1096
1082 void AstTraversalVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} 1097 void AstTraversalVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {}
1083 1098
1084 void AstTraversalVisitor::VisitSuperPropertyReference( 1099 void AstTraversalVisitor::VisitSuperPropertyReference(
1085 SuperPropertyReference* expr) { 1100 SuperPropertyReference* expr) {
1086 VisitVariableProxy(expr->this_var()); 1101 RECURSE_EXPRESSION(VisitVariableProxy(expr->this_var()));
1087 Visit(expr->home_object()); 1102 RECURSE_EXPRESSION(Visit(expr->home_object()));
1088 } 1103 }
1089 1104
1090 void AstTraversalVisitor::VisitSuperCallReference(SuperCallReference* expr) { 1105 void AstTraversalVisitor::VisitSuperCallReference(SuperCallReference* expr) {
1091 VisitVariableProxy(expr->this_var()); 1106 RECURSE_EXPRESSION(VisitVariableProxy(expr->this_var()));
1092 VisitVariableProxy(expr->new_target_var()); 1107 RECURSE_EXPRESSION(VisitVariableProxy(expr->new_target_var()));
1093 VisitVariableProxy(expr->this_function_var()); 1108 RECURSE_EXPRESSION(VisitVariableProxy(expr->this_function_var()));
1094 } 1109 }
1095 1110
1096 void AstTraversalVisitor::VisitRewritableExpression( 1111 void AstTraversalVisitor::VisitRewritableExpression(
1097 RewritableExpression* expr) { 1112 RewritableExpression* expr) {
1098 Visit(expr->expression()); 1113 RECURSE(Visit(expr->expression()));
1099 } 1114 }
1100 1115
1116 #undef RECURSE_EXPRESSION
1117 #undef RECURSE
1118
1101 CaseClause::CaseClause(Zone* zone, Expression* label, 1119 CaseClause::CaseClause(Zone* zone, Expression* label,
1102 ZoneList<Statement*>* statements, int pos) 1120 ZoneList<Statement*>* statements, int pos)
1103 : Expression(zone, pos), 1121 : Expression(zone, pos),
1104 label_(label), 1122 label_(label),
1105 statements_(statements), 1123 statements_(statements),
1106 compare_type_(Type::None()) {} 1124 compare_type_(Type::None()) {}
1107 1125
1108 uint32_t Literal::Hash() { 1126 uint32_t Literal::Hash() {
1109 return raw_value()->IsString() 1127 return raw_value()->IsString()
1110 ? raw_value()->AsString()->hash() 1128 ? raw_value()->AsString()->hash()
1111 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber())); 1129 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber()));
1112 } 1130 }
1113 1131
1114 1132
1115 // static 1133 // static
1116 bool Literal::Match(void* literal1, void* literal2) { 1134 bool Literal::Match(void* literal1, void* literal2) {
1117 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 1135 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
1118 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 1136 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
1119 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 1137 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
1120 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 1138 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
1121 } 1139 }
1122 1140
1123 1141
1124 } // namespace internal 1142 } // namespace internal
1125 } // namespace v8 1143 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/ast-expression-visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698