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 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 i::Handle<i::String> source( | 1020 i::Handle<i::String> source( |
1021 factory->NewStringFromUtf8(i::CStrVector(program.start()))); | 1021 factory->NewStringFromUtf8(i::CStrVector(program.start()))); |
1022 CHECK_EQ(source->length(), kProgramSize); | 1022 CHECK_EQ(source->length(), kProgramSize); |
1023 i::Handle<i::Script> script = factory->NewScript(source); | 1023 i::Handle<i::Script> script = factory->NewScript(source); |
1024 i::CompilationInfoWithZone info(script); | 1024 i::CompilationInfoWithZone info(script); |
1025 i::Parser parser(&info); | 1025 i::Parser parser(&info); |
1026 parser.set_allow_lazy(true); | 1026 parser.set_allow_lazy(true); |
1027 parser.set_allow_harmony_scoping(true); | 1027 parser.set_allow_harmony_scoping(true); |
1028 info.MarkAsGlobal(); | 1028 info.MarkAsGlobal(); |
1029 info.SetLanguageMode(source_data[i].language_mode); | 1029 info.SetLanguageMode(source_data[i].language_mode); |
1030 i::FunctionLiteral* function = parser.ParseProgram(); | 1030 parser.Parse(); |
1031 CHECK(function != NULL); | 1031 CHECK(info.function() != NULL); |
1032 | 1032 |
1033 // Check scope types and positions. | 1033 // Check scope types and positions. |
1034 i::Scope* scope = function->scope(); | 1034 i::Scope* scope = info.function()->scope(); |
1035 CHECK(scope->is_global_scope()); | 1035 CHECK(scope->is_global_scope()); |
1036 CHECK_EQ(scope->start_position(), 0); | 1036 CHECK_EQ(scope->start_position(), 0); |
1037 CHECK_EQ(scope->end_position(), kProgramSize); | 1037 CHECK_EQ(scope->end_position(), kProgramSize); |
1038 CHECK_EQ(scope->inner_scopes()->length(), 1); | 1038 CHECK_EQ(scope->inner_scopes()->length(), 1); |
1039 | 1039 |
1040 i::Scope* inner_scope = scope->inner_scopes()->at(0); | 1040 i::Scope* inner_scope = scope->inner_scopes()->at(0); |
1041 CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type); | 1041 CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type); |
1042 CHECK_EQ(inner_scope->start_position(), kPrefixLen); | 1042 CHECK_EQ(inner_scope->start_position(), kPrefixLen); |
1043 // The end position of a token is one position after the last | 1043 // The end position of a token is one position after the last |
1044 // character belonging to that token. | 1044 // character belonging to that token. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 i::ScriptDataImpl data(log.ExtractData()); | 1130 i::ScriptDataImpl data(log.ExtractData()); |
1131 | 1131 |
1132 // Parse the data | 1132 // Parse the data |
1133 i::FunctionLiteral* function; | 1133 i::FunctionLiteral* function; |
1134 { | 1134 { |
1135 i::Handle<i::Script> script = factory->NewScript(source); | 1135 i::Handle<i::Script> script = factory->NewScript(source); |
1136 i::CompilationInfoWithZone info(script); | 1136 i::CompilationInfoWithZone info(script); |
1137 i::Parser parser(&info); | 1137 i::Parser parser(&info); |
1138 SET_PARSER_FLAGS(parser, flags); | 1138 SET_PARSER_FLAGS(parser, flags); |
1139 info.MarkAsGlobal(); | 1139 info.MarkAsGlobal(); |
1140 function = parser.ParseProgram(); | 1140 parser.Parse(); |
| 1141 function = info.function(); |
1141 } | 1142 } |
1142 | 1143 |
1143 // Check that preparsing fails iff parsing fails. | 1144 // Check that preparsing fails iff parsing fails. |
1144 if (function == NULL) { | 1145 if (function == NULL) { |
1145 // Extract exception from the parser. | 1146 // Extract exception from the parser. |
1146 CHECK(isolate->has_pending_exception()); | 1147 CHECK(isolate->has_pending_exception()); |
1147 i::MaybeObject* maybe_object = isolate->pending_exception(); | 1148 i::MaybeObject* maybe_object = isolate->pending_exception(); |
1148 i::JSObject* exception = NULL; | 1149 i::JSObject* exception = NULL; |
1149 CHECK(maybe_object->To(&exception)); | 1150 CHECK(maybe_object->To(&exception)); |
1150 i::Handle<i::JSObject> exception_handle(exception); | 1151 i::Handle<i::JSObject> exception_handle(exception); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 " b = function() { \n" | 1319 " b = function() { \n" |
1319 " 01; \n" | 1320 " 01; \n" |
1320 " }; \n" | 1321 " }; \n" |
1321 "}; \n"; | 1322 "}; \n"; |
1322 v8::Script::Compile(v8::String::New(script)); | 1323 v8::Script::Compile(v8::String::New(script)); |
1323 CHECK(try_catch.HasCaught()); | 1324 CHECK(try_catch.HasCaught()); |
1324 v8::String::Utf8Value exception(try_catch.Exception()); | 1325 v8::String::Utf8Value exception(try_catch.Exception()); |
1325 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", | 1326 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", |
1326 *exception); | 1327 *exception); |
1327 } | 1328 } |
OLD | NEW |