| 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 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 for (int i = 0; i < length; i++) { | 1326 for (int i = 0; i < length; i++) { |
| 1327 result[i] = start[i + 1]; | 1327 result[i] = start[i + 1]; |
| 1328 } | 1328 } |
| 1329 result[length] = '\0'; | 1329 result[length] = '\0'; |
| 1330 return result; | 1330 return result; |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 | 1333 |
| 1334 i::Handle<i::String> FormatMessage(i::Vector<unsigned> data) { | 1334 i::Handle<i::String> FormatMessage(i::Vector<unsigned> data) { |
| 1335 i::Isolate* isolate = CcTest::i_isolate(); | 1335 i::Isolate* isolate = CcTest::i_isolate(); |
| 1336 i::Factory* factory = isolate->factory(); | 1336 int message = data[i::PreparseDataConstants::kMessageTemplatePos]; |
| 1337 const char* message = | |
| 1338 ReadString(&data[i::PreparseDataConstants::kMessageTextPos]); | |
| 1339 i::Handle<i::String> format = v8::Utils::OpenHandle( | |
| 1340 *v8::String::NewFromUtf8(CcTest::isolate(), message)); | |
| 1341 int arg_count = data[i::PreparseDataConstants::kMessageArgCountPos]; | 1337 int arg_count = data[i::PreparseDataConstants::kMessageArgCountPos]; |
| 1342 const char* arg = NULL; | 1338 i::Handle<i::Object> arg_object; |
| 1343 i::Handle<i::JSArray> args_array; | |
| 1344 if (arg_count == 1) { | 1339 if (arg_count == 1) { |
| 1345 // Position after text found by skipping past length field and | 1340 // Position after text found by skipping past length field and |
| 1346 // length field content words. | 1341 // length field content words. |
| 1347 int pos = i::PreparseDataConstants::kMessageTextPos + 1 + | 1342 const char* arg = |
| 1348 data[i::PreparseDataConstants::kMessageTextPos]; | 1343 ReadString(&data[i::PreparseDataConstants::kMessageArgPos]); |
| 1349 arg = ReadString(&data[pos]); | 1344 arg_object = |
| 1350 args_array = factory->NewJSArray(1); | 1345 v8::Utils::OpenHandle(*v8::String::NewFromUtf8(CcTest::isolate(), arg)); |
| 1351 i::JSArray::SetElement(args_array, 0, v8::Utils::OpenHandle(*v8_str(arg)), | 1346 i::DeleteArray(arg); |
| 1352 NONE, i::SLOPPY).Check(); | |
| 1353 } else { | 1347 } else { |
| 1354 CHECK_EQ(0, arg_count); | 1348 CHECK_EQ(0, arg_count); |
| 1355 args_array = factory->NewJSArray(0); | 1349 arg_object = isolate->factory()->undefined_value(); |
| 1356 } | 1350 } |
| 1357 | 1351 |
| 1358 i::Handle<i::JSObject> builtins(isolate->js_builtins_object()); | |
| 1359 i::Handle<i::Object> format_fun = | |
| 1360 i::Object::GetProperty(isolate, builtins, "$formatMessage") | |
| 1361 .ToHandleChecked(); | |
| 1362 i::Handle<i::Object> arg_handles[] = { format, args_array }; | |
| 1363 i::Handle<i::Object> result = i::Execution::Call( | |
| 1364 isolate, format_fun, builtins, 2, arg_handles).ToHandleChecked(); | |
| 1365 CHECK(result->IsString()); | |
| 1366 i::DeleteArray(message); | |
| 1367 i::DeleteArray(arg); | |
| 1368 data.Dispose(); | 1352 data.Dispose(); |
| 1369 return i::Handle<i::String>::cast(result); | 1353 return i::MessageTemplate::FormatMessage(isolate, message, arg_object); |
| 1370 } | 1354 } |
| 1371 | 1355 |
| 1372 | 1356 |
| 1373 enum ParserFlag { | 1357 enum ParserFlag { |
| 1374 kAllowLazy, | 1358 kAllowLazy, |
| 1375 kAllowNatives, | 1359 kAllowNatives, |
| 1376 kAllowHarmonyModules, | 1360 kAllowHarmonyModules, |
| 1377 kAllowHarmonyArrowFunctions, | 1361 kAllowHarmonyArrowFunctions, |
| 1378 kAllowHarmonyClasses, | 1362 kAllowHarmonyClasses, |
| 1379 kAllowHarmonyObjectLiterals, | 1363 kAllowHarmonyObjectLiterals, |
| (...skipping 5092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6472 const char* data[] = { | 6456 const char* data[] = { |
| 6473 "yield", | 6457 "yield", |
| 6474 "[yield]", | 6458 "[yield]", |
| 6475 "{ x : yield }", | 6459 "{ x : yield }", |
| 6476 NULL}; | 6460 NULL}; |
| 6477 // clang-format on | 6461 // clang-format on |
| 6478 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 6462 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 6479 arraysize(always_flags)); | 6463 arraysize(always_flags)); |
| 6480 } | 6464 } |
| 6481 } | 6465 } |
| OLD | NEW |