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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 1124233002: Remove Scope::scope_uses_arguments_ flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Created 5 years, 7 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/scopes.cc ('k') | no next file » | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 { "function f() {", "}" }, 953 { "function f() {", "}" },
954 { "var f = () => {", "};" }, 954 { "var f = () => {", "};" },
955 { "class C { constructor() {", "} }" }, 955 { "class C { constructor() {", "} }" },
956 }; 956 };
957 957
958 enum Expected { 958 enum Expected {
959 NONE = 0, 959 NONE = 0,
960 ARGUMENTS = 1, 960 ARGUMENTS = 1,
961 SUPER_PROPERTY = 1 << 1, 961 SUPER_PROPERTY = 1 << 1,
962 THIS = 1 << 2, 962 THIS = 1 << 2,
963 INNER_ARGUMENTS = 1 << 3,
964 INNER_SUPER_PROPERTY = 1 << 4, 963 INNER_SUPER_PROPERTY = 1 << 4,
965 }; 964 };
966 965
967 static const struct { 966 static const struct {
968 const char* body; 967 const char* body;
969 int expected; 968 int expected;
970 } source_data[] = { 969 } source_data[] = {
971 {"", NONE}, 970 {"", NONE},
972 {"return this", THIS}, 971 {"return this", THIS},
973 {"return arguments", ARGUMENTS}, 972 {"return arguments", ARGUMENTS},
(...skipping 20 matching lines...) Expand all
994 {"return function (x) { return this + x }", NONE}, 993 {"return function (x) { return this + x }", NONE},
995 {"return { m(x) { return super.m() + x } }", NONE}, 994 {"return { m(x) { return super.m() + x } }", NONE},
996 {"var x = function () { this.foo = 42 };", NONE}, 995 {"var x = function () { this.foo = 42 };", NONE},
997 {"var x = { m() { super.foo = 42 } };", NONE}, 996 {"var x = { m() { super.foo = 42 } };", NONE},
998 {"if (1) { return function () { while (true) new this() } }", NONE}, 997 {"if (1) { return function () { while (true) new this() } }", NONE},
999 {"if (1) { return { m() { while (true) super.m() } } }", NONE}, 998 {"if (1) { return { m() { while (true) super.m() } } }", NONE},
1000 {"return function (x) { return () => this }", NONE}, 999 {"return function (x) { return () => this }", NONE},
1001 {"return { m(x) { return () => super.m() } }", NONE}, 1000 {"return { m(x) { return () => super.m() } }", NONE},
1002 // Flags must be correctly set when using block scoping. 1001 // Flags must be correctly set when using block scoping.
1003 {"\"use strict\"; while (true) { let x; this, arguments; }", 1002 {"\"use strict\"; while (true) { let x; this, arguments; }",
1004 INNER_ARGUMENTS | THIS}, 1003 ARGUMENTS | THIS},
1005 {"\"use strict\"; while (true) { let x; this, super.f(), arguments; }", 1004 {"\"use strict\"; while (true) { let x; this, super.f(), arguments; }",
1006 INNER_ARGUMENTS | INNER_SUPER_PROPERTY | THIS}, 1005 ARGUMENTS | INNER_SUPER_PROPERTY | THIS},
1007 {"\"use strict\"; if (foo()) { let x; this.f() }", THIS}, 1006 {"\"use strict\"; if (foo()) { let x; this.f() }", THIS},
1008 {"\"use strict\"; if (foo()) { let x; super.f() }", 1007 {"\"use strict\"; if (foo()) { let x; super.f() }",
1009 INNER_SUPER_PROPERTY}, 1008 INNER_SUPER_PROPERTY},
1010 {"\"use strict\"; if (1) {" 1009 {"\"use strict\"; if (1) {"
1011 " let x; return { m() { return this + super.m() + arguments } }" 1010 " let x; return { m() { return this + super.m() + arguments } }"
1012 "}", 1011 "}",
1013 NONE}, 1012 NONE},
1014 }; 1013 };
1015 1014
1016 i::Isolate* isolate = CcTest::i_isolate(); 1015 i::Isolate* isolate = CcTest::i_isolate();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 i::Scope* script_scope = info.function()->scope(); 1056 i::Scope* script_scope = info.function()->scope();
1058 CHECK(script_scope->is_script_scope()); 1057 CHECK(script_scope->is_script_scope());
1059 CHECK_EQ(1, script_scope->inner_scopes()->length()); 1058 CHECK_EQ(1, script_scope->inner_scopes()->length());
1060 1059
1061 i::Scope* scope = script_scope->inner_scopes()->at(0); 1060 i::Scope* scope = script_scope->inner_scopes()->at(0);
1062 // Adjust for constructor scope. 1061 // Adjust for constructor scope.
1063 if (j == 2) { 1062 if (j == 2) {
1064 CHECK_EQ(1, scope->inner_scopes()->length()); 1063 CHECK_EQ(1, scope->inner_scopes()->length());
1065 scope = scope->inner_scopes()->at(0); 1064 scope = scope->inner_scopes()->at(0);
1066 } 1065 }
1067 CHECK_EQ((source_data[i].expected & ARGUMENTS) != 0, 1066 // Arguments usage in an arrow function doesn't cause local allocation of
1068 scope->uses_arguments()); 1067 // an arguments object.
1068 CHECK_EQ((source_data[i].expected & ARGUMENTS) != 0 && j != 1,
1069 scope->arguments() != nullptr);
1069 CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0, 1070 CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0,
1070 scope->uses_super_property()); 1071 scope->uses_super_property());
1071 if ((source_data[i].expected & THIS) != 0) { 1072 if ((source_data[i].expected & THIS) != 0) {
1072 // Currently the is_used() flag is conservative; all variables in a 1073 // Currently the is_used() flag is conservative; all variables in a
1073 // script scope are marked as used. 1074 // script scope are marked as used.
1074 CHECK(scope->LookupThis()->is_used()); 1075 CHECK(scope->LookupThis()->is_used());
1075 } 1076 }
1076 CHECK_EQ((source_data[i].expected & INNER_ARGUMENTS) != 0,
1077 scope->inner_uses_arguments());
1078 CHECK_EQ((source_data[i].expected & INNER_SUPER_PROPERTY) != 0, 1077 CHECK_EQ((source_data[i].expected & INNER_SUPER_PROPERTY) != 0,
1079 scope->inner_uses_super_property()); 1078 scope->inner_uses_super_property());
1080 } 1079 }
1081 } 1080 }
1082 } 1081 }
1083 1082
1084 1083
1085 TEST(ScopePositions) { 1084 TEST(ScopePositions) {
1086 // Test the parser for correctly setting the start and end positions 1085 // Test the parser for correctly setting the start and end positions
1087 // of a scope. We check the scope positions of exactly one scope 1086 // of a scope. We check the scope positions of exactly one scope
(...skipping 5379 matching lines...) Expand 10 before | Expand all | Expand 10 after
6467 const char* data[] = { 6466 const char* data[] = {
6468 "yield", 6467 "yield",
6469 "[yield]", 6468 "[yield]",
6470 "{ x : yield }", 6469 "{ x : yield }",
6471 NULL}; 6470 NULL};
6472 // clang-format on 6471 // clang-format on
6473 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6472 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6474 arraysize(always_flags)); 6473 arraysize(always_flags));
6475 } 6474 }
6476 } 6475 }
OLDNEW
« no previous file with comments | « src/scopes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698