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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 return i::Handle<i::String>::cast(result); | 1065 return i::Handle<i::String>::cast(result); |
1066 } | 1066 } |
1067 | 1067 |
1068 | 1068 |
1069 enum ParserFlag { | 1069 enum ParserFlag { |
1070 kAllowLazy, | 1070 kAllowLazy, |
1071 kAllowNativesSyntax, | 1071 kAllowNativesSyntax, |
1072 kAllowHarmonyScoping, | 1072 kAllowHarmonyScoping, |
1073 kAllowModules, | 1073 kAllowModules, |
1074 kAllowGenerators, | 1074 kAllowGenerators, |
| 1075 kAllowForOf, |
1075 kParserFlagCount | 1076 kParserFlagCount |
1076 }; | 1077 }; |
1077 | 1078 |
1078 | 1079 |
1079 static bool checkParserFlag(unsigned flags, ParserFlag flag) { | 1080 static bool checkParserFlag(unsigned flags, ParserFlag flag) { |
1080 return flags & (1 << flag); | 1081 return flags & (1 << flag); |
1081 } | 1082 } |
1082 | 1083 |
1083 | 1084 |
1084 #define SET_PARSER_FLAGS(parser, flags) \ | 1085 #define SET_PARSER_FLAGS(parser, flags) \ |
1085 parser.set_allow_lazy(checkParserFlag(flags, kAllowLazy)); \ | 1086 parser.set_allow_lazy(checkParserFlag(flags, kAllowLazy)); \ |
1086 parser.set_allow_natives_syntax(checkParserFlag(flags, \ | 1087 parser.set_allow_natives_syntax(checkParserFlag(flags, \ |
1087 kAllowNativesSyntax)); \ | 1088 kAllowNativesSyntax)); \ |
1088 parser.set_allow_harmony_scoping(checkParserFlag(flags, \ | 1089 parser.set_allow_harmony_scoping(checkParserFlag(flags, \ |
1089 kAllowHarmonyScoping)); \ | 1090 kAllowHarmonyScoping)); \ |
1090 parser.set_allow_modules(checkParserFlag(flags, kAllowModules)); \ | 1091 parser.set_allow_modules(checkParserFlag(flags, kAllowModules)); \ |
1091 parser.set_allow_generators(checkParserFlag(flags, kAllowGenerators)); | 1092 parser.set_allow_generators(checkParserFlag(flags, kAllowGenerators)); \ |
| 1093 parser.set_allow_for_of(checkParserFlag(flags, kAllowForOf)); |
1092 | 1094 |
1093 void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) { | 1095 void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) { |
1094 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); | 1096 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); |
1095 | 1097 |
1096 // Preparse the data. | 1098 // Preparse the data. |
1097 i::CompleteParserRecorder log; | 1099 i::CompleteParserRecorder log; |
1098 { | 1100 { |
1099 i::Scanner scanner(i::Isolate::Current()->unicode_cache()); | 1101 i::Scanner scanner(i::Isolate::Current()->unicode_cache()); |
1100 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); | 1102 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); |
1101 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); | 1103 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 " b = function() { \n" | 1299 " b = function() { \n" |
1298 " 01; \n" | 1300 " 01; \n" |
1299 " }; \n" | 1301 " }; \n" |
1300 "}; \n"; | 1302 "}; \n"; |
1301 v8::Script::Compile(v8::String::New(script)); | 1303 v8::Script::Compile(v8::String::New(script)); |
1302 CHECK(try_catch.HasCaught()); | 1304 CHECK(try_catch.HasCaught()); |
1303 v8::String::Utf8Value exception(try_catch.Exception()); | 1305 v8::String::Utf8Value exception(try_catch.Exception()); |
1304 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", | 1306 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", |
1305 *exception); | 1307 *exception); |
1306 } | 1308 } |
OLD | NEW |