mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-15 01:34:02 +02:00
Add an optional parameter in buildPostScriptJsFunction to force use of the PSStackBasedInterpreter code
This way the test-only function `buildPostScriptProgramFunction` can be removed.
This commit is contained in:
parent
853d5436c1
commit
ccab310a39
@ -795,9 +795,15 @@ class PSStackBasedInterpreter {
|
||||
* @param {number[]} range – flat [min0,max0, …]
|
||||
* @returns {Function} – `(src, srcOffset, dest, destOffset) => void`
|
||||
*/
|
||||
function buildPostScriptJsFunction(source, domain, range) {
|
||||
function buildPostScriptJsFunction(
|
||||
source,
|
||||
domain,
|
||||
range,
|
||||
forceInterpreter = false
|
||||
) {
|
||||
const program = parsePostScriptFunction(source);
|
||||
const ir = new PsJsCompiler(domain, range).compile(program);
|
||||
const ir =
|
||||
!forceInterpreter && new PsJsCompiler(domain, range).compile(program);
|
||||
if (ir) {
|
||||
return (src, srcOffset, dest, destOffset) => {
|
||||
PsJsCompiler.execute(ir, src, srcOffset, dest, destOffset);
|
||||
@ -807,14 +813,4 @@ function buildPostScriptJsFunction(source, domain, range) {
|
||||
return PSStackBasedInterpreter.build(program, domain, range);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("./ast.js").PsProgram} program
|
||||
* @param {number[]} domain – flat [min0,max0, …]
|
||||
* @param {number[]} range – flat [min0,max0, …]
|
||||
* @returns {Function} – `(src, srcOffset, dest, destOffset) => void`
|
||||
*/
|
||||
function buildPostScriptProgramFunction(program, domain, range) {
|
||||
return PSStackBasedInterpreter.build(program, domain, range);
|
||||
}
|
||||
|
||||
export { buildPostScriptJsFunction, buildPostScriptProgramFunction };
|
||||
export { buildPostScriptJsFunction };
|
||||
|
||||
@ -13,10 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
buildPostScriptJsFunction,
|
||||
buildPostScriptProgramFunction,
|
||||
} from "../../src/core/postscript/js_evaluator.js";
|
||||
import {
|
||||
buildPostScriptWasmFunction,
|
||||
compilePostScriptToWasm,
|
||||
@ -39,6 +35,7 @@ import {
|
||||
PsTernaryNode,
|
||||
PsUnaryNode,
|
||||
} from "../../src/core/postscript/ast.js";
|
||||
import { buildPostScriptJsFunction } from "../../src/core/postscript/js_evaluator.js";
|
||||
|
||||
// Precision argument for toBeCloseTo() in trigonometric tests.
|
||||
const TRIGONOMETRY_EPS = 1e-10;
|
||||
@ -209,10 +206,11 @@ describe("PostScript Type 4 lexer, parser, and Wasm compiler", function () {
|
||||
// direct program interpreter otherwise.
|
||||
const jsFn = buildPostScriptJsFunction(src, domain, range);
|
||||
// Direct interpreter: always available, never uses PSStackToTree.
|
||||
const interpFn = buildPostScriptProgramFunction(
|
||||
parsePostScriptFunction(src),
|
||||
const interpFn = buildPostScriptJsFunction(
|
||||
src,
|
||||
domain,
|
||||
range
|
||||
range,
|
||||
/* forceInterpreter = */ true
|
||||
);
|
||||
|
||||
if (!wasmFn) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user