Changeset 189431 in webkit for trunk/Source/JavaScriptCore/jsc.cpp
- Timestamp:
- Sep 5, 2015, 12:44:35 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jsc.cpp
r189160 r189431 500 500 static EncodedJSValue JSC_HOST_CALL functionLoadWebAssembly(ExecState*); 501 501 #endif 502 #if ENABLE(ES6_MODULES) 502 static EncodedJSValue JSC_HOST_CALL functionLoadModule(ExecState*); 503 503 static EncodedJSValue JSC_HOST_CALL functionCheckModuleSyntax(ExecState*); 504 #endif505 504 506 505 #if ENABLE(SAMPLING_FLAGS) … … 679 678 addFunction(vm, "loadWebAssembly", functionLoadWebAssembly, 1); 680 679 #endif 681 #if ENABLE(ES6_MODULES) 680 addFunction(vm, "loadModule", functionLoadModule, 1); 682 681 addFunction(vm, "checkModuleSyntax", functionCheckModuleSyntax, 1); 683 #endif684 682 685 683 JSArray* array = constructEmptyArray(globalExec(), 0); … … 1361 1359 #endif 1362 1360 1363 #if ENABLE(ES6_MODULES) 1361 EncodedJSValue JSC_HOST_CALL functionLoadModule(ExecState* exec) 1362 { 1363 String fileName = exec->argument(0).toString(exec)->value(exec); 1364 Vector<char> script; 1365 if (!fillBufferWithContentsOfFile(fileName, script)) 1366 return JSValue::encode(exec->vm().throwException(exec, createError(exec, ASCIILiteral("Could not open file.")))); 1367 1368 JSInternalPromise* promise = evaluateModule(exec, fileName); 1369 if (exec->hadException()) 1370 return JSValue::encode(jsUndefined()); 1371 1372 JSValue error; 1373 JSFunction* errorHandler = JSNativeStdFunction::create(exec->vm(), exec->lexicalGlobalObject(), 1, String(), [&](ExecState* exec) { 1374 error = exec->argument(0); 1375 return JSValue::encode(jsUndefined()); 1376 }); 1377 1378 promise->then(exec, nullptr, errorHandler); 1379 exec->vm().drainMicrotasks(); 1380 if (error) 1381 return JSValue::encode(exec->vm().throwException(exec, error)); 1382 return JSValue::encode(jsUndefined()); 1383 } 1384 1364 1385 EncodedJSValue JSC_HOST_CALL functionCheckModuleSyntax(ExecState* exec) 1365 1386 { … … 1377 1398 return JSValue::encode(jsNumber(stopWatch.getElapsedMS())); 1378 1399 } 1379 #endif1380 1400 1381 1401 // Use SEH for Release builds only to get rid of the crash report dialog … … 1505 1525 bool success = true; 1506 1526 1507 #if ENABLE(ES6_MODULES)1508 1527 JSFunction* errorHandler = JSNativeStdFunction::create(vm, globalObject, 1, String(), [&](ExecState* exec) { 1509 1528 success = false; … … 1511 1530 return JSValue::encode(jsUndefined()); 1512 1531 }); 1513 #endif1514 1532 1515 1533 #if ENABLE(SAMPLING_FLAGS) … … 1518 1536 1519 1537 for (size_t i = 0; i < scripts.size(); i++) { 1520 #if ENABLE(ES6_MODULES)1521 1538 JSInternalPromise* promise = nullptr; 1522 #endif1523 1539 if (scripts[i].isFile) { 1524 1540 fileName = scripts[i].argument; 1525 if (module) { 1526 #if ENABLE(ES6_MODULES) 1541 if (module) 1527 1542 promise = evaluateModule(globalObject->globalExec(), fileName); 1528 #else 1529 RELEASE_ASSERT_NOT_REACHED(); 1530 #endif 1531 } else { 1543 else { 1532 1544 if (!fillBufferWithContentsOfFile(fileName, scriptBuffer)) 1533 1545 return false; // fail early so we can catch missing files … … 1542 1554 1543 1555 if (module) { 1544 #if ENABLE(ES6_MODULES)1545 1556 if (!promise) 1546 1557 promise = evaluateModule(globalObject->globalExec(), jscSource(script, fileName)); … … 1548 1559 promise->then(globalObject->globalExec(), nullptr, errorHandler); 1549 1560 globalObject->vm().drainMicrotasks(); 1550 #else1551 RELEASE_ASSERT_NOT_REACHED();1552 #endif1553 1561 } else { 1554 1562 NakedPtr<Exception> evaluationException; … … 1649 1657 fprintf(stderr, " -h|--help Prints this help message\n"); 1650 1658 fprintf(stderr, " -i Enables interactive mode (default if no files are specified)\n"); 1651 #if ENABLE(ES6_MODULES)1652 1659 fprintf(stderr, " -m Execute as a module\n"); 1653 #endif1654 1660 #if HAVE(SIGNAL_H) 1655 1661 fprintf(stderr, " -s Installs signal handlers that exit on a crash (Unix platforms only)\n"); … … 1703 1709 continue; 1704 1710 } 1705 #if ENABLE(ES6_MODULES)1706 1711 if (!strcmp(arg, "-m")) { 1707 1712 m_module = true; 1708 1713 continue; 1709 1714 } 1710 #endif1711 1715 if (!strcmp(arg, "-s")) { 1712 1716 #if HAVE(SIGNAL_H)
Note:
See TracChangeset
for help on using the changeset viewer.