OLD | NEW |
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 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 i::Handle<i::Script> script = factory->NewScript(source); | 1113 i::Handle<i::Script> script = factory->NewScript(source); |
1114 i::Zone zone(CcTest::i_isolate()->allocator()); | 1114 i::Zone zone(CcTest::i_isolate()->allocator()); |
1115 i::ParseInfo info(&zone, script); | 1115 i::ParseInfo info(&zone, script); |
1116 i::Parser parser(&info); | 1116 i::Parser parser(&info); |
1117 info.set_global(); | 1117 info.set_global(); |
1118 CHECK(parser.Parse(&info)); | 1118 CHECK(parser.Parse(&info)); |
1119 CHECK(i::Rewriter::Rewrite(&info)); | 1119 CHECK(i::Rewriter::Rewrite(&info)); |
1120 CHECK(i::Scope::Analyze(&info)); | 1120 CHECK(i::Scope::Analyze(&info)); |
1121 CHECK(info.literal() != NULL); | 1121 CHECK(info.literal() != NULL); |
1122 | 1122 |
1123 i::Scope* script_scope = info.literal()->scope(); | 1123 i::DeclarationScope* script_scope = info.literal()->scope(); |
1124 CHECK(script_scope->is_script_scope()); | 1124 CHECK(script_scope->is_script_scope()); |
1125 | 1125 |
1126 i::Scope* scope = script_scope->inner_scope(); | 1126 i::Scope* scope = script_scope->inner_scope(); |
1127 DCHECK_NOT_NULL(scope); | 1127 DCHECK_NOT_NULL(scope); |
1128 DCHECK_NULL(scope->sibling()); | 1128 DCHECK_NULL(scope->sibling()); |
1129 // Adjust for constructor scope. | 1129 // Adjust for constructor scope. |
1130 if (j == 2) { | 1130 if (j == 2) { |
1131 scope = scope->inner_scope(); | 1131 scope = scope->inner_scope(); |
1132 DCHECK_NOT_NULL(scope); | 1132 DCHECK_NOT_NULL(scope); |
1133 DCHECK_NULL(scope->sibling()); | 1133 DCHECK_NULL(scope->sibling()); |
1134 } | 1134 } |
1135 // Arrows themselves never get an arguments object. | 1135 // Arrows themselves never get an arguments object. |
1136 if ((source_data[i].expected & ARGUMENTS) != 0 && | 1136 if ((source_data[i].expected & ARGUMENTS) != 0 && |
1137 !scope->is_arrow_scope()) { | 1137 !scope->AsDeclarationScope()->is_arrow_scope()) { |
1138 CHECK_NOT_NULL(scope->arguments()); | 1138 CHECK_NOT_NULL(scope->AsDeclarationScope()->arguments()); |
1139 } | 1139 } |
1140 CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0, | 1140 CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0, |
1141 scope->uses_super_property()); | 1141 scope->uses_super_property()); |
1142 if ((source_data[i].expected & THIS) != 0) { | 1142 if ((source_data[i].expected & THIS) != 0) { |
1143 // Currently the is_used() flag is conservative; all variables in a | 1143 // Currently the is_used() flag is conservative; all variables in a |
1144 // script scope are marked as used. | 1144 // script scope are marked as used. |
1145 CHECK( | 1145 CHECK( |
1146 scope->Lookup(info.ast_value_factory()->this_string())->is_used()); | 1146 scope->Lookup(info.ast_value_factory()->this_string())->is_used()); |
1147 } | 1147 } |
1148 CHECK_EQ((source_data[i].expected & EVAL) != 0, scope->calls_eval()); | 1148 CHECK_EQ((source_data[i].expected & EVAL) != 0, scope->calls_eval()); |
(...skipping 4782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5931 "import 'q.js'"; | 5931 "import 'q.js'"; |
5932 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); | 5932 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); |
5933 i::Handle<i::Script> script = factory->NewScript(source); | 5933 i::Handle<i::Script> script = factory->NewScript(source); |
5934 i::Zone zone(CcTest::i_isolate()->allocator()); | 5934 i::Zone zone(CcTest::i_isolate()->allocator()); |
5935 i::ParseInfo info(&zone, script); | 5935 i::ParseInfo info(&zone, script); |
5936 i::Parser parser(&info); | 5936 i::Parser parser(&info); |
5937 info.set_module(); | 5937 info.set_module(); |
5938 CHECK(parser.Parse(&info)); | 5938 CHECK(parser.Parse(&info)); |
5939 CHECK(i::Compiler::Analyze(&info)); | 5939 CHECK(i::Compiler::Analyze(&info)); |
5940 i::FunctionLiteral* func = info.literal(); | 5940 i::FunctionLiteral* func = info.literal(); |
5941 i::Scope* module_scope = func->scope(); | 5941 i::DeclarationScope* module_scope = func->scope(); |
5942 i::Scope* outer_scope = module_scope->outer_scope(); | 5942 i::Scope* outer_scope = module_scope->outer_scope(); |
5943 CHECK(outer_scope->is_script_scope()); | 5943 CHECK(outer_scope->is_script_scope()); |
5944 CHECK_NULL(outer_scope->outer_scope()); | 5944 CHECK_NULL(outer_scope->outer_scope()); |
5945 CHECK(module_scope->is_module_scope()); | 5945 CHECK(module_scope->is_module_scope()); |
5946 i::ModuleDescriptor* descriptor = module_scope->module(); | 5946 i::ModuleDescriptor* descriptor = module_scope->module(); |
5947 CHECK_NOT_NULL(descriptor); | 5947 CHECK_NOT_NULL(descriptor); |
5948 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations(); | 5948 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations(); |
5949 CHECK_EQ(8, declarations->length()); | 5949 CHECK_EQ(8, declarations->length()); |
5950 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); | 5950 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); |
5951 CHECK(declarations->at(1)->proxy()->raw_name()->IsOneByteEqualTo("z")); | 5951 CHECK(declarations->at(1)->proxy()->raw_name()->IsOneByteEqualTo("z")); |
(...skipping 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7986 "(a,);", | 7986 "(a,);", |
7987 "(a,b,c,);", | 7987 "(a,b,c,);", |
7988 NULL | 7988 NULL |
7989 }; | 7989 }; |
7990 // clang-format on | 7990 // clang-format on |
7991 | 7991 |
7992 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 7992 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
7993 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7993 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
7994 arraysize(always_flags)); | 7994 arraysize(always_flags)); |
7995 } | 7995 } |
OLD | NEW |