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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 // of a scope. We check the scope positions of exactly one scope | 1063 // of a scope. We check the scope positions of exactly one scope |
1064 // nested in the global scope of a program. 'inner source' is the | 1064 // nested in the global scope of a program. 'inner source' is the |
1065 // source code that determines the part of the source belonging | 1065 // source code that determines the part of the source belonging |
1066 // to the nested scope. 'outer_prefix' and 'outer_suffix' are | 1066 // to the nested scope. 'outer_prefix' and 'outer_suffix' are |
1067 // parts of the source that belong to the global scope. | 1067 // parts of the source that belong to the global scope. |
1068 struct SourceData { | 1068 struct SourceData { |
1069 const char* outer_prefix; | 1069 const char* outer_prefix; |
1070 const char* inner_source; | 1070 const char* inner_source; |
1071 const char* outer_suffix; | 1071 const char* outer_suffix; |
1072 i::ScopeType scope_type; | 1072 i::ScopeType scope_type; |
1073 i::StrictMode strict_mode; | 1073 i::LanguageMode language_mode; |
1074 }; | 1074 }; |
1075 | 1075 |
1076 const SourceData source_data[] = { | 1076 const SourceData source_data[] = { |
1077 { " with ({}) ", "{ block; }", " more;", i::WITH_SCOPE, i::SLOPPY }, | 1077 { " with ({}) ", "{ block; }", " more;", i::WITH_SCOPE, i::SLOPPY }, |
1078 { " with ({}) ", "{ block; }", "; more;", i::WITH_SCOPE, i::SLOPPY }, | 1078 { " with ({}) ", "{ block; }", "; more;", i::WITH_SCOPE, i::SLOPPY }, |
1079 { " with ({}) ", "{\n" | 1079 { " with ({}) ", "{\n" |
1080 " block;\n" | 1080 " block;\n" |
1081 " }", "\n" | 1081 " }", "\n" |
1082 " more;", i::WITH_SCOPE, i::SLOPPY }, | 1082 " more;", i::WITH_SCOPE, i::SLOPPY }, |
1083 { " with ({}) ", "statement;", " more;", i::WITH_SCOPE, i::SLOPPY }, | 1083 { " with ({}) ", "statement;", " more;", i::WITH_SCOPE, i::SLOPPY }, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 i::Handle<i::Script> script = factory->NewScript(source); | 1270 i::Handle<i::Script> script = factory->NewScript(source); |
1271 i::CompilationInfoWithZone info(script); | 1271 i::CompilationInfoWithZone info(script); |
1272 i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(), | 1272 i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(), |
1273 isolate->heap()->HashSeed(), | 1273 isolate->heap()->HashSeed(), |
1274 isolate->unicode_cache()}; | 1274 isolate->unicode_cache()}; |
1275 i::Parser parser(&info, &parse_info); | 1275 i::Parser parser(&info, &parse_info); |
1276 parser.set_allow_lazy(true); | 1276 parser.set_allow_lazy(true); |
1277 parser.set_allow_harmony_scoping(true); | 1277 parser.set_allow_harmony_scoping(true); |
1278 parser.set_allow_harmony_arrow_functions(true); | 1278 parser.set_allow_harmony_arrow_functions(true); |
1279 info.MarkAsGlobal(); | 1279 info.MarkAsGlobal(); |
1280 info.SetStrictMode(source_data[i].strict_mode); | 1280 info.SetLanguageMode(source_data[i].language_mode); |
1281 parser.Parse(); | 1281 parser.Parse(); |
1282 CHECK(info.function() != NULL); | 1282 CHECK(info.function() != NULL); |
1283 | 1283 |
1284 // Check scope types and positions. | 1284 // Check scope types and positions. |
1285 i::Scope* scope = info.function()->scope(); | 1285 i::Scope* scope = info.function()->scope(); |
1286 CHECK(scope->is_script_scope()); | 1286 CHECK(scope->is_script_scope()); |
1287 CHECK_EQ(scope->start_position(), 0); | 1287 CHECK_EQ(scope->start_position(), 0); |
1288 CHECK_EQ(scope->end_position(), kProgramSize); | 1288 CHECK_EQ(scope->end_position(), kProgramSize); |
1289 CHECK_EQ(scope->inner_scopes()->length(), 1); | 1289 CHECK_EQ(scope->inner_scopes()->length(), 1); |
1290 | 1290 |
(...skipping 3686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4977 "const x = 1;", | 4977 "const x = 1;", |
4978 "class C {}", | 4978 "class C {}", |
4979 NULL}; | 4979 NULL}; |
4980 | 4980 |
4981 static const ParserFlag always_flags[] = { | 4981 static const ParserFlag always_flags[] = { |
4982 kAllowHarmonyClasses, kAllowHarmonyScoping | 4982 kAllowHarmonyClasses, kAllowHarmonyScoping |
4983 }; | 4983 }; |
4984 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, | 4984 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, |
4985 always_flags, arraysize(always_flags)); | 4985 always_flags, arraysize(always_flags)); |
4986 } | 4986 } |
OLD | NEW |