| 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 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 return i::Handle<i::String>::cast(result); | 1071 return i::Handle<i::String>::cast(result); |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 | 1074 |
| 1075 enum ParserFlag { | 1075 enum ParserFlag { |
| 1076 kAllowLazy, | 1076 kAllowLazy, |
| 1077 kAllowNativesSyntax, | 1077 kAllowNativesSyntax, |
| 1078 kAllowHarmonyScoping, | 1078 kAllowHarmonyScoping, |
| 1079 kAllowModules, | 1079 kAllowModules, |
| 1080 kAllowGenerators, | 1080 kAllowGenerators, |
| 1081 kAllowForOf, |
| 1081 kParserFlagCount | 1082 kParserFlagCount |
| 1082 }; | 1083 }; |
| 1083 | 1084 |
| 1084 | 1085 |
| 1085 static bool checkParserFlag(unsigned flags, ParserFlag flag) { | 1086 static bool checkParserFlag(unsigned flags, ParserFlag flag) { |
| 1086 return flags & (1 << flag); | 1087 return flags & (1 << flag); |
| 1087 } | 1088 } |
| 1088 | 1089 |
| 1089 | 1090 |
| 1090 #define SET_PARSER_FLAGS(parser, flags) \ | 1091 #define SET_PARSER_FLAGS(parser, flags) \ |
| 1091 parser.set_allow_lazy(checkParserFlag(flags, kAllowLazy)); \ | 1092 parser.set_allow_lazy(checkParserFlag(flags, kAllowLazy)); \ |
| 1092 parser.set_allow_natives_syntax(checkParserFlag(flags, \ | 1093 parser.set_allow_natives_syntax(checkParserFlag(flags, \ |
| 1093 kAllowNativesSyntax)); \ | 1094 kAllowNativesSyntax)); \ |
| 1094 parser.set_allow_harmony_scoping(checkParserFlag(flags, \ | 1095 parser.set_allow_harmony_scoping(checkParserFlag(flags, \ |
| 1095 kAllowHarmonyScoping)); \ | 1096 kAllowHarmonyScoping)); \ |
| 1096 parser.set_allow_modules(checkParserFlag(flags, kAllowModules)); \ | 1097 parser.set_allow_modules(checkParserFlag(flags, kAllowModules)); \ |
| 1097 parser.set_allow_generators(checkParserFlag(flags, kAllowGenerators)); | 1098 parser.set_allow_generators(checkParserFlag(flags, kAllowGenerators)); \ |
| 1099 parser.set_allow_for_of(checkParserFlag(flags, kAllowForOf)); |
| 1098 | 1100 |
| 1099 void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) { | 1101 void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) { |
| 1100 i::Isolate* isolate = i::Isolate::Current(); | 1102 i::Isolate* isolate = i::Isolate::Current(); |
| 1101 i::Factory* factory = isolate->factory(); | 1103 i::Factory* factory = isolate->factory(); |
| 1102 | 1104 |
| 1103 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); | 1105 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); |
| 1104 | 1106 |
| 1105 // Preparse the data. | 1107 // Preparse the data. |
| 1106 i::CompleteParserRecorder log; | 1108 i::CompleteParserRecorder log; |
| 1107 { | 1109 { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 " b = function() { \n" | 1311 " b = function() { \n" |
| 1310 " 01; \n" | 1312 " 01; \n" |
| 1311 " }; \n" | 1313 " }; \n" |
| 1312 "}; \n"; | 1314 "}; \n"; |
| 1313 v8::Script::Compile(v8::String::New(script)); | 1315 v8::Script::Compile(v8::String::New(script)); |
| 1314 CHECK(try_catch.HasCaught()); | 1316 CHECK(try_catch.HasCaught()); |
| 1315 v8::String::Utf8Value exception(try_catch.Exception()); | 1317 v8::String::Utf8Value exception(try_catch.Exception()); |
| 1316 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", | 1318 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", |
| 1317 *exception); | 1319 *exception); |
| 1318 } | 1320 } |
| OLD | NEW |