mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-20 07:44:29 +08:00
Adding method for JSCreateSourceCodeFromFile.
Reviewed By: amnn Differential Revision: D4365790 fbshipit-source-id: b62ee9c7d3fa3f89c22a10a6fde21cd9c30fceb2
This commit is contained in:
committed by
Facebook Github Bot
parent
b15c042a21
commit
a0dd54b4d7
@@ -315,23 +315,20 @@ void JSCExecutor::terminateOnJSVMThread() {
|
||||
}
|
||||
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
static const char* explainLoadSourceError(JSLoadSourceError err) {
|
||||
switch (err) {
|
||||
case JSLoadSourceErrorNone:
|
||||
static const char* explainLoadSourceStatus(JSLoadSourceStatus status) {
|
||||
switch (status) {
|
||||
case JSLoadSourceIsCompiled:
|
||||
return "No error encountered during source load";
|
||||
|
||||
case JSLoadSourceErrorOnRead:
|
||||
return "Error reading source";
|
||||
|
||||
case JSLoadSourceErrorNotCompiled:
|
||||
case JSLoadSourceIsNotCompiled:
|
||||
return "Source is not compiled";
|
||||
|
||||
case JSLoadSourceErrorVersionMismatch:
|
||||
return "Source version not supported";
|
||||
|
||||
case JSLoadSourceErrorUnknown:
|
||||
return "Unknown error occurred when loading source";
|
||||
|
||||
default:
|
||||
return "Bad error code";
|
||||
}
|
||||
@@ -365,11 +362,11 @@ void JSCExecutor::loadApplicationScript(
|
||||
});
|
||||
SCOPE_EXIT { close(fd); };
|
||||
|
||||
JSLoadSourceError jsError;
|
||||
sourceCode = JSCreateCompiledSourceCode(fd, jsSourceURL, &jsError);
|
||||
JSLoadSourceStatus jsStatus;
|
||||
sourceCode = JSCreateCompiledSourceCode(fd, jsSourceURL, &jsStatus);
|
||||
|
||||
if (!sourceCode) {
|
||||
throw RecoverableError(explainLoadSourceError(jsError));
|
||||
throw RecoverableError(explainLoadSourceStatus(jsStatus));
|
||||
}
|
||||
} else {
|
||||
auto jsScriptBigString = JSBigOptimizedBundleString::fromOptimizedBundle(bundlePath);
|
||||
@@ -406,11 +403,11 @@ void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> scrip
|
||||
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
if (auto fileStr = dynamic_cast<const JSBigFileString *>(script.get())) {
|
||||
JSLoadSourceError jsError;
|
||||
auto bcSourceCode = JSCreateCompiledSourceCode(fileStr->fd(), jsSourceURL, &jsError);
|
||||
JSLoadSourceStatus jsStatus;
|
||||
auto bcSourceCode = JSCreateCompiledSourceCode(fileStr->fd(), jsSourceURL, &jsStatus);
|
||||
|
||||
switch (jsError) {
|
||||
case JSLoadSourceErrorNone:
|
||||
switch (jsStatus) {
|
||||
case JSLoadSourceIsCompiled:
|
||||
if (!bcSourceCode) {
|
||||
throw std::runtime_error("Unexpected error opening compiled bundle");
|
||||
}
|
||||
@@ -429,11 +426,10 @@ void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> scrip
|
||||
return;
|
||||
|
||||
case JSLoadSourceErrorVersionMismatch:
|
||||
case JSLoadSourceErrorUnknown:
|
||||
throw RecoverableError(explainLoadSourceError(jsError));
|
||||
throw RecoverableError(explainLoadSourceStatus(jsStatus));
|
||||
|
||||
case JSLoadSourceErrorOnRead:
|
||||
case JSLoadSourceErrorNotCompiled:
|
||||
case JSLoadSourceIsNotCompiled:
|
||||
// Not bytecode, fall through.
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user