prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
78 lines (59 loc) • 3.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.NestedOptimizedFunctionSideEffect = exports.InvariantError = exports.InfeasiblePathError = exports.FatalError = exports.CompilerDiagnostic = void 0;
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/* strict */
// Information: Just an informative message with no semantic implications whatsoever.
// Warning: Prepack will produce code that matches the behavior of the original code, but the original code might have an error.
// RecoverableError: Prepack might produce code that deviates in behavior from the original code, if the original code is not well behaved.
// FatalError: Prepack is unable to produce code that could possibly match the behavior of the original code.
// This is the error format used to report errors to the caller-supplied
// error-handler
class CompilerDiagnostic extends Error {
constructor(message, location, errorCode, severity, sourceFilePaths) {
super(message);
this.location = location;
this.severity = severity;
this.errorCode = errorCode;
this.sourceFilePaths = sourceFilePaths;
}
} // This error is thrown to exit Prepack when an ErrorHandler returns 'FatalError'
// This should just be a class but Babel classes doesn't work with
// built-in super classes.
exports.CompilerDiagnostic = CompilerDiagnostic;
class FatalError extends Error {
constructor(message) {
super(message === undefined ? "A fatal error occurred while prepacking." : message);
}
} // This error is thrown when exploring a path whose entry conditon implies that an earlier path conditon must be false.
// Such paths are infeasible (dead) and must be elided from the evaluation.
exports.FatalError = FatalError;
class InfeasiblePathError extends Error {
constructor() {
super("Infeasible path explored");
}
} // This error is thrown when a false invariant is encountered. This error should never be swallowed.
exports.InfeasiblePathError = InfeasiblePathError;
class InvariantError extends Error {
constructor(message) {
super(message);
}
}
exports.InvariantError = InvariantError;
// When a side-effect occurs when evaluating a pure nested optimized function, we stop execution of that function
// and catch the error to properly handle the according logic (either bail-out or report the error).
// Ideally this should extend FatalError, but that will mean re-working every call-site that catches FatalError
// and make it treat NestedOptimizedFunctionSideEffect errors differently, which isn't ideal so maybe a better
// FatalError catching/handling process is needed throughout the codebase at some point.
class NestedOptimizedFunctionSideEffect extends Error {}
exports.NestedOptimizedFunctionSideEffect = NestedOptimizedFunctionSideEffect;
//# sourceMappingURL=errors.js.map