| 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::DeclarationScope* script_scope = info.literal()->scope(); | 1123 i::Scope* 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->AsDeclarationScope()->is_arrow_scope()) { | 1137 !scope->is_arrow_scope()) { |
| 1138 CHECK_NOT_NULL(scope->AsDeclarationScope()->arguments()); | 1138 CHECK_NOT_NULL(scope->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 4786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5935 "import 'q.js'"; | 5935 "import 'q.js'"; |
| 5936 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); | 5936 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); |
| 5937 i::Handle<i::Script> script = factory->NewScript(source); | 5937 i::Handle<i::Script> script = factory->NewScript(source); |
| 5938 i::Zone zone(CcTest::i_isolate()->allocator()); | 5938 i::Zone zone(CcTest::i_isolate()->allocator()); |
| 5939 i::ParseInfo info(&zone, script); | 5939 i::ParseInfo info(&zone, script); |
| 5940 i::Parser parser(&info); | 5940 i::Parser parser(&info); |
| 5941 info.set_module(); | 5941 info.set_module(); |
| 5942 CHECK(parser.Parse(&info)); | 5942 CHECK(parser.Parse(&info)); |
| 5943 CHECK(i::Compiler::Analyze(&info)); | 5943 CHECK(i::Compiler::Analyze(&info)); |
| 5944 i::FunctionLiteral* func = info.literal(); | 5944 i::FunctionLiteral* func = info.literal(); |
| 5945 i::DeclarationScope* module_scope = func->scope(); | 5945 i::Scope* module_scope = func->scope(); |
| 5946 i::Scope* outer_scope = module_scope->outer_scope(); | 5946 i::Scope* outer_scope = module_scope->outer_scope(); |
| 5947 CHECK(outer_scope->is_script_scope()); | 5947 CHECK(outer_scope->is_script_scope()); |
| 5948 CHECK_NULL(outer_scope->outer_scope()); | 5948 CHECK_NULL(outer_scope->outer_scope()); |
| 5949 CHECK(module_scope->is_module_scope()); | 5949 CHECK(module_scope->is_module_scope()); |
| 5950 i::ModuleDescriptor* descriptor = module_scope->module(); | 5950 i::ModuleDescriptor* descriptor = module_scope->module(); |
| 5951 CHECK_NOT_NULL(descriptor); | 5951 CHECK_NOT_NULL(descriptor); |
| 5952 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations(); | 5952 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations(); |
| 5953 CHECK_EQ(8, declarations->length()); | 5953 CHECK_EQ(8, declarations->length()); |
| 5954 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); | 5954 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); |
| 5955 CHECK(declarations->at(1)->proxy()->raw_name()->IsOneByteEqualTo("z")); | 5955 CHECK(declarations->at(1)->proxy()->raw_name()->IsOneByteEqualTo("z")); |
| (...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7984 "(a,);", | 7984 "(a,);", |
| 7985 "(a,b,c,);", | 7985 "(a,b,c,);", |
| 7986 NULL | 7986 NULL |
| 7987 }; | 7987 }; |
| 7988 // clang-format on | 7988 // clang-format on |
| 7989 | 7989 |
| 7990 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 7990 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
| 7991 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7991 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 7992 arraysize(always_flags)); | 7992 arraysize(always_flags)); |
| 7993 } | 7993 } |
| OLD | NEW |