pdfjs-dist 2.0.943 → 2.4.456
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
package/lib/core/function.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,267 +19,291 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.
|
28
|
-
|
29
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
30
|
-
|
31
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
32
|
-
|
33
|
-
var _util = require('../shared/util');
|
27
|
+
exports.isPDFFunction = isPDFFunction;
|
28
|
+
exports.PostScriptCompiler = exports.PostScriptEvaluator = exports.PDFFunctionFactory = void 0;
|
34
29
|
|
35
|
-
var
|
30
|
+
var _util = require("../shared/util.js");
|
36
31
|
|
37
|
-
var
|
32
|
+
var _primitives = require("./primitives.js");
|
38
33
|
|
39
|
-
|
34
|
+
var _ps_parser = require("./ps_parser.js");
|
40
35
|
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
class PDFFunctionFactory {
|
37
|
+
constructor({
|
38
|
+
xref,
|
39
|
+
isEvalSupported = true
|
40
|
+
}) {
|
41
|
+
this.xref = xref;
|
42
|
+
this.isEvalSupported = isEvalSupported !== false;
|
44
43
|
}
|
45
|
-
};
|
46
|
-
|
47
|
-
var PDFFunctionFactory = function () {
|
48
|
-
function PDFFunctionFactory(_ref) {
|
49
|
-
var xref = _ref.xref,
|
50
|
-
_ref$isEvalSupported = _ref.isEvalSupported,
|
51
|
-
isEvalSupported = _ref$isEvalSupported === undefined ? true : _ref$isEvalSupported;
|
52
44
|
|
53
|
-
|
45
|
+
create(fn) {
|
46
|
+
return PDFFunction.parse({
|
47
|
+
xref: this.xref,
|
48
|
+
isEvalSupported: this.isEvalSupported,
|
49
|
+
fn
|
50
|
+
});
|
51
|
+
}
|
54
52
|
|
55
|
-
|
56
|
-
|
53
|
+
createFromArray(fnObj) {
|
54
|
+
return PDFFunction.parseArray({
|
55
|
+
xref: this.xref,
|
56
|
+
isEvalSupported: this.isEvalSupported,
|
57
|
+
fnObj
|
58
|
+
});
|
57
59
|
}
|
58
60
|
|
59
|
-
|
60
|
-
key: 'create',
|
61
|
-
value: function create(fn) {
|
62
|
-
return PDFFunction.parse({
|
63
|
-
xref: this.xref,
|
64
|
-
isEvalSupported: this.isEvalSupported,
|
65
|
-
fn: fn
|
66
|
-
});
|
67
|
-
}
|
68
|
-
}, {
|
69
|
-
key: 'createFromArray',
|
70
|
-
value: function createFromArray(fnObj) {
|
71
|
-
return PDFFunction.parseArray({
|
72
|
-
xref: this.xref,
|
73
|
-
isEvalSupported: this.isEvalSupported,
|
74
|
-
fnObj: fnObj
|
75
|
-
});
|
76
|
-
}
|
77
|
-
}]);
|
61
|
+
}
|
78
62
|
|
79
|
-
|
80
|
-
}();
|
63
|
+
exports.PDFFunctionFactory = PDFFunctionFactory;
|
81
64
|
|
82
65
|
function toNumberArray(arr) {
|
83
66
|
if (!Array.isArray(arr)) {
|
84
67
|
return null;
|
85
68
|
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
69
|
+
|
70
|
+
const length = arr.length;
|
71
|
+
|
72
|
+
for (let i = 0; i < length; i++) {
|
73
|
+
if (typeof arr[i] !== "number") {
|
74
|
+
const result = new Array(length);
|
75
|
+
|
76
|
+
for (let i = 0; i < length; i++) {
|
77
|
+
result[i] = +arr[i];
|
92
78
|
}
|
79
|
+
|
93
80
|
return result;
|
94
81
|
}
|
95
82
|
}
|
83
|
+
|
96
84
|
return arr;
|
97
85
|
}
|
86
|
+
|
98
87
|
var PDFFunction = function PDFFunctionClosure() {
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
88
|
+
const CONSTRUCT_SAMPLED = 0;
|
89
|
+
const CONSTRUCT_INTERPOLATED = 2;
|
90
|
+
const CONSTRUCT_STICHED = 3;
|
91
|
+
const CONSTRUCT_POSTSCRIPT = 4;
|
103
92
|
return {
|
104
|
-
getSampleArray
|
93
|
+
getSampleArray(size, outputSize, bps, stream) {
|
105
94
|
var i, ii;
|
106
95
|
var length = 1;
|
96
|
+
|
107
97
|
for (i = 0, ii = size.length; i < ii; i++) {
|
108
98
|
length *= size[i];
|
109
99
|
}
|
100
|
+
|
110
101
|
length *= outputSize;
|
111
102
|
var array = new Array(length);
|
112
103
|
var codeSize = 0;
|
113
104
|
var codeBuf = 0;
|
114
|
-
var sampleMul = 1.0 / (
|
105
|
+
var sampleMul = 1.0 / (2.0 ** bps - 1);
|
115
106
|
var strBytes = stream.getBytes((length * bps + 7) / 8);
|
116
107
|
var strIdx = 0;
|
108
|
+
|
117
109
|
for (i = 0; i < length; i++) {
|
118
110
|
while (codeSize < bps) {
|
119
111
|
codeBuf <<= 8;
|
120
112
|
codeBuf |= strBytes[strIdx++];
|
121
113
|
codeSize += 8;
|
122
114
|
}
|
115
|
+
|
123
116
|
codeSize -= bps;
|
124
117
|
array[i] = (codeBuf >> codeSize) * sampleMul;
|
125
118
|
codeBuf &= (1 << codeSize) - 1;
|
126
119
|
}
|
120
|
+
|
127
121
|
return array;
|
128
122
|
},
|
129
|
-
getIR: function getIR(_ref2) {
|
130
|
-
var xref = _ref2.xref,
|
131
|
-
isEvalSupported = _ref2.isEvalSupported,
|
132
|
-
fn = _ref2.fn;
|
133
123
|
|
124
|
+
getIR({
|
125
|
+
xref,
|
126
|
+
isEvalSupported,
|
127
|
+
fn
|
128
|
+
}) {
|
134
129
|
var dict = fn.dict;
|
130
|
+
|
135
131
|
if (!dict) {
|
136
132
|
dict = fn;
|
137
133
|
}
|
134
|
+
|
138
135
|
var types = [this.constructSampled, null, this.constructInterpolated, this.constructStiched, this.constructPostScript];
|
139
|
-
var typeNum = dict.get(
|
136
|
+
var typeNum = dict.get("FunctionType");
|
140
137
|
var typeFn = types[typeNum];
|
138
|
+
|
141
139
|
if (!typeFn) {
|
142
|
-
throw new _util.FormatError(
|
140
|
+
throw new _util.FormatError("Unknown type of function");
|
143
141
|
}
|
142
|
+
|
144
143
|
return typeFn.call(this, {
|
145
|
-
xref
|
146
|
-
isEvalSupported
|
147
|
-
fn
|
148
|
-
dict
|
144
|
+
xref,
|
145
|
+
isEvalSupported,
|
146
|
+
fn,
|
147
|
+
dict
|
149
148
|
});
|
150
149
|
},
|
151
|
-
fromIR: function fromIR(_ref3) {
|
152
|
-
var xref = _ref3.xref,
|
153
|
-
isEvalSupported = _ref3.isEvalSupported,
|
154
|
-
IR = _ref3.IR;
|
155
150
|
|
151
|
+
fromIR({
|
152
|
+
xref,
|
153
|
+
isEvalSupported,
|
154
|
+
IR
|
155
|
+
}) {
|
156
156
|
var type = IR[0];
|
157
|
+
|
157
158
|
switch (type) {
|
158
159
|
case CONSTRUCT_SAMPLED:
|
159
160
|
return this.constructSampledFromIR({
|
160
|
-
xref
|
161
|
-
isEvalSupported
|
162
|
-
IR
|
161
|
+
xref,
|
162
|
+
isEvalSupported,
|
163
|
+
IR
|
163
164
|
});
|
165
|
+
|
164
166
|
case CONSTRUCT_INTERPOLATED:
|
165
167
|
return this.constructInterpolatedFromIR({
|
166
|
-
xref
|
167
|
-
isEvalSupported
|
168
|
-
IR
|
168
|
+
xref,
|
169
|
+
isEvalSupported,
|
170
|
+
IR
|
169
171
|
});
|
172
|
+
|
170
173
|
case CONSTRUCT_STICHED:
|
171
174
|
return this.constructStichedFromIR({
|
172
|
-
xref
|
173
|
-
isEvalSupported
|
174
|
-
IR
|
175
|
+
xref,
|
176
|
+
isEvalSupported,
|
177
|
+
IR
|
175
178
|
});
|
179
|
+
|
176
180
|
default:
|
177
181
|
return this.constructPostScriptFromIR({
|
178
|
-
xref
|
179
|
-
isEvalSupported
|
180
|
-
IR
|
182
|
+
xref,
|
183
|
+
isEvalSupported,
|
184
|
+
IR
|
181
185
|
});
|
182
186
|
}
|
183
187
|
},
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
188
|
+
|
189
|
+
parse({
|
190
|
+
xref,
|
191
|
+
isEvalSupported,
|
192
|
+
fn
|
193
|
+
}) {
|
194
|
+
const IR = this.getIR({
|
195
|
+
xref,
|
196
|
+
isEvalSupported,
|
197
|
+
fn
|
193
198
|
});
|
194
199
|
return this.fromIR({
|
195
|
-
xref
|
196
|
-
isEvalSupported
|
197
|
-
IR
|
200
|
+
xref,
|
201
|
+
isEvalSupported,
|
202
|
+
IR
|
198
203
|
});
|
199
204
|
},
|
200
|
-
parseArray: function parseArray(_ref5) {
|
201
|
-
var xref = _ref5.xref,
|
202
|
-
isEvalSupported = _ref5.isEvalSupported,
|
203
|
-
fnObj = _ref5.fnObj;
|
204
205
|
|
206
|
+
parseArray({
|
207
|
+
xref,
|
208
|
+
isEvalSupported,
|
209
|
+
fnObj
|
210
|
+
}) {
|
205
211
|
if (!Array.isArray(fnObj)) {
|
206
212
|
return this.parse({
|
207
|
-
xref
|
208
|
-
isEvalSupported
|
213
|
+
xref,
|
214
|
+
isEvalSupported,
|
209
215
|
fn: fnObj
|
210
216
|
});
|
211
217
|
}
|
218
|
+
|
212
219
|
var fnArray = [];
|
220
|
+
|
213
221
|
for (var j = 0, jj = fnObj.length; j < jj; j++) {
|
214
222
|
fnArray.push(this.parse({
|
215
|
-
xref
|
216
|
-
isEvalSupported
|
223
|
+
xref,
|
224
|
+
isEvalSupported,
|
217
225
|
fn: xref.fetchIfRef(fnObj[j])
|
218
226
|
}));
|
219
227
|
}
|
228
|
+
|
220
229
|
return function (src, srcOffset, dest, destOffset) {
|
221
230
|
for (var i = 0, ii = fnArray.length; i < ii; i++) {
|
222
231
|
fnArray[i](src, srcOffset, dest, destOffset + i);
|
223
232
|
}
|
224
233
|
};
|
225
234
|
},
|
226
|
-
constructSampled: function constructSampled(_ref6) {
|
227
|
-
var xref = _ref6.xref,
|
228
|
-
isEvalSupported = _ref6.isEvalSupported,
|
229
|
-
fn = _ref6.fn,
|
230
|
-
dict = _ref6.dict;
|
231
235
|
|
236
|
+
constructSampled({
|
237
|
+
xref,
|
238
|
+
isEvalSupported,
|
239
|
+
fn,
|
240
|
+
dict
|
241
|
+
}) {
|
232
242
|
function toMultiArray(arr) {
|
233
243
|
var inputLength = arr.length;
|
234
244
|
var out = [];
|
235
245
|
var index = 0;
|
246
|
+
|
236
247
|
for (var i = 0; i < inputLength; i += 2) {
|
237
248
|
out[index] = [arr[i], arr[i + 1]];
|
238
249
|
++index;
|
239
250
|
}
|
251
|
+
|
240
252
|
return out;
|
241
253
|
}
|
242
|
-
|
243
|
-
var
|
254
|
+
|
255
|
+
var domain = toNumberArray(dict.getArray("Domain"));
|
256
|
+
var range = toNumberArray(dict.getArray("Range"));
|
257
|
+
|
244
258
|
if (!domain || !range) {
|
245
|
-
throw new _util.FormatError(
|
259
|
+
throw new _util.FormatError("No domain or range");
|
246
260
|
}
|
261
|
+
|
247
262
|
var inputSize = domain.length / 2;
|
248
263
|
var outputSize = range.length / 2;
|
249
264
|
domain = toMultiArray(domain);
|
250
265
|
range = toMultiArray(range);
|
251
|
-
var size = toNumberArray(dict.getArray(
|
252
|
-
var bps = dict.get(
|
253
|
-
var order = dict.get(
|
266
|
+
var size = toNumberArray(dict.getArray("Size"));
|
267
|
+
var bps = dict.get("BitsPerSample");
|
268
|
+
var order = dict.get("Order") || 1;
|
269
|
+
|
254
270
|
if (order !== 1) {
|
255
|
-
(0, _util.info)(
|
271
|
+
(0, _util.info)("No support for cubic spline interpolation: " + order);
|
256
272
|
}
|
257
|
-
|
273
|
+
|
274
|
+
var encode = toNumberArray(dict.getArray("Encode"));
|
275
|
+
|
258
276
|
if (!encode) {
|
259
277
|
encode = [];
|
278
|
+
|
260
279
|
for (var i = 0; i < inputSize; ++i) {
|
261
280
|
encode.push([0, size[i] - 1]);
|
262
281
|
}
|
263
282
|
} else {
|
264
283
|
encode = toMultiArray(encode);
|
265
284
|
}
|
266
|
-
|
285
|
+
|
286
|
+
var decode = toNumberArray(dict.getArray("Decode"));
|
287
|
+
|
267
288
|
if (!decode) {
|
268
289
|
decode = range;
|
269
290
|
} else {
|
270
291
|
decode = toMultiArray(decode);
|
271
292
|
}
|
293
|
+
|
272
294
|
var samples = this.getSampleArray(size, outputSize, bps, fn);
|
273
|
-
return [CONSTRUCT_SAMPLED, inputSize, domain, encode, decode, samples, size, outputSize,
|
295
|
+
return [CONSTRUCT_SAMPLED, inputSize, domain, encode, decode, samples, size, outputSize, 2 ** bps - 1, range];
|
274
296
|
},
|
275
|
-
constructSampledFromIR: function constructSampledFromIR(_ref7) {
|
276
|
-
var xref = _ref7.xref,
|
277
|
-
isEvalSupported = _ref7.isEvalSupported,
|
278
|
-
IR = _ref7.IR;
|
279
297
|
|
298
|
+
constructSampledFromIR({
|
299
|
+
xref,
|
300
|
+
isEvalSupported,
|
301
|
+
IR
|
302
|
+
}) {
|
280
303
|
function interpolate(x, xmin, xmax, ymin, ymax) {
|
281
304
|
return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
|
282
305
|
}
|
306
|
+
|
283
307
|
return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
|
284
308
|
var m = IR[1];
|
285
309
|
var domain = IR[2];
|
@@ -293,11 +317,14 @@ var PDFFunction = function PDFFunctionClosure() {
|
|
293
317
|
var cubeN = new Float64Array(cubeVertices);
|
294
318
|
var cubeVertex = new Uint32Array(cubeVertices);
|
295
319
|
var i, j;
|
320
|
+
|
296
321
|
for (j = 0; j < cubeVertices; j++) {
|
297
322
|
cubeN[j] = 1;
|
298
323
|
}
|
324
|
+
|
299
325
|
var k = n,
|
300
326
|
pos = 1;
|
327
|
+
|
301
328
|
for (i = 0; i < m; ++i) {
|
302
329
|
var domain_2i = domain[i][0];
|
303
330
|
var domain_2i_1 = domain[i][1];
|
@@ -310,6 +337,7 @@ var PDFFunction = function PDFFunctionClosure() {
|
|
310
337
|
var n1 = e - e0;
|
311
338
|
var offset0 = e0 * k;
|
312
339
|
var offset1 = offset0 + k;
|
340
|
+
|
313
341
|
for (j = 0; j < cubeVertices; j++) {
|
314
342
|
if (j & pos) {
|
315
343
|
cubeN[j] *= n1;
|
@@ -319,83 +347,100 @@ var PDFFunction = function PDFFunctionClosure() {
|
|
319
347
|
cubeVertex[j] += offset0;
|
320
348
|
}
|
321
349
|
}
|
350
|
+
|
322
351
|
k *= size_i;
|
323
352
|
pos <<= 1;
|
324
353
|
}
|
354
|
+
|
325
355
|
for (j = 0; j < n; ++j) {
|
326
356
|
var rj = 0;
|
357
|
+
|
327
358
|
for (i = 0; i < cubeVertices; i++) {
|
328
359
|
rj += samples[cubeVertex[i] + j] * cubeN[i];
|
329
360
|
}
|
361
|
+
|
330
362
|
rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
|
331
363
|
dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
|
332
364
|
}
|
333
365
|
};
|
334
366
|
},
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
var
|
343
|
-
var
|
367
|
+
|
368
|
+
constructInterpolated({
|
369
|
+
xref,
|
370
|
+
isEvalSupported,
|
371
|
+
fn,
|
372
|
+
dict
|
373
|
+
}) {
|
374
|
+
var c0 = toNumberArray(dict.getArray("C0")) || [0];
|
375
|
+
var c1 = toNumberArray(dict.getArray("C1")) || [1];
|
376
|
+
var n = dict.get("N");
|
344
377
|
var length = c0.length;
|
345
378
|
var diff = [];
|
379
|
+
|
346
380
|
for (var i = 0; i < length; ++i) {
|
347
381
|
diff.push(c1[i] - c0[i]);
|
348
382
|
}
|
383
|
+
|
349
384
|
return [CONSTRUCT_INTERPOLATED, c0, diff, n];
|
350
385
|
},
|
351
|
-
constructInterpolatedFromIR: function constructInterpolatedFromIR(_ref9) {
|
352
|
-
var xref = _ref9.xref,
|
353
|
-
isEvalSupported = _ref9.isEvalSupported,
|
354
|
-
IR = _ref9.IR;
|
355
386
|
|
387
|
+
constructInterpolatedFromIR({
|
388
|
+
xref,
|
389
|
+
isEvalSupported,
|
390
|
+
IR
|
391
|
+
}) {
|
356
392
|
var c0 = IR[1];
|
357
393
|
var diff = IR[2];
|
358
394
|
var n = IR[3];
|
359
395
|
var length = diff.length;
|
360
396
|
return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
|
361
|
-
var x = n === 1 ? src[srcOffset] :
|
397
|
+
var x = n === 1 ? src[srcOffset] : src[srcOffset] ** n;
|
398
|
+
|
362
399
|
for (var j = 0; j < length; ++j) {
|
363
400
|
dest[destOffset + j] = c0[j] + x * diff[j];
|
364
401
|
}
|
365
402
|
};
|
366
403
|
},
|
367
|
-
constructStiched: function constructStiched(_ref10) {
|
368
|
-
var xref = _ref10.xref,
|
369
|
-
isEvalSupported = _ref10.isEvalSupported,
|
370
|
-
fn = _ref10.fn,
|
371
|
-
dict = _ref10.dict;
|
372
404
|
|
373
|
-
|
405
|
+
constructStiched({
|
406
|
+
xref,
|
407
|
+
isEvalSupported,
|
408
|
+
fn,
|
409
|
+
dict
|
410
|
+
}) {
|
411
|
+
var domain = toNumberArray(dict.getArray("Domain"));
|
412
|
+
|
374
413
|
if (!domain) {
|
375
|
-
throw new _util.FormatError(
|
414
|
+
throw new _util.FormatError("No domain");
|
376
415
|
}
|
416
|
+
|
377
417
|
var inputSize = domain.length / 2;
|
418
|
+
|
378
419
|
if (inputSize !== 1) {
|
379
|
-
throw new _util.FormatError(
|
420
|
+
throw new _util.FormatError("Bad domain for stiched function");
|
380
421
|
}
|
381
|
-
|
422
|
+
|
423
|
+
var fnRefs = dict.get("Functions");
|
382
424
|
var fns = [];
|
425
|
+
|
383
426
|
for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
|
384
427
|
fns.push(this.parse({
|
385
|
-
xref
|
386
|
-
isEvalSupported
|
428
|
+
xref,
|
429
|
+
isEvalSupported,
|
387
430
|
fn: xref.fetchIfRef(fnRefs[i])
|
388
431
|
}));
|
389
432
|
}
|
390
|
-
|
391
|
-
var
|
433
|
+
|
434
|
+
var bounds = toNumberArray(dict.getArray("Bounds"));
|
435
|
+
var encode = toNumberArray(dict.getArray("Encode"));
|
392
436
|
return [CONSTRUCT_STICHED, domain, bounds, encode, fns];
|
393
437
|
},
|
394
|
-
constructStichedFromIR: function constructStichedFromIR(_ref11) {
|
395
|
-
var xref = _ref11.xref,
|
396
|
-
isEvalSupported = _ref11.isEvalSupported,
|
397
|
-
IR = _ref11.IR;
|
398
438
|
|
439
|
+
constructStichedFromIR({
|
440
|
+
xref,
|
441
|
+
isEvalSupported,
|
442
|
+
IR
|
443
|
+
}) {
|
399
444
|
var domain = IR[1];
|
400
445
|
var bounds = IR[2];
|
401
446
|
var encode = IR[3];
|
@@ -408,62 +453,78 @@ var PDFFunction = function PDFFunctionClosure() {
|
|
408
453
|
} else if (v < min) {
|
409
454
|
v = min;
|
410
455
|
}
|
456
|
+
|
411
457
|
return v;
|
412
458
|
};
|
459
|
+
|
413
460
|
var v = clip(src[srcOffset], domain[0], domain[1]);
|
461
|
+
|
414
462
|
for (var i = 0, ii = bounds.length; i < ii; ++i) {
|
415
463
|
if (v < bounds[i]) {
|
416
464
|
break;
|
417
465
|
}
|
418
466
|
}
|
467
|
+
|
419
468
|
var dmin = domain[0];
|
469
|
+
|
420
470
|
if (i > 0) {
|
421
471
|
dmin = bounds[i - 1];
|
422
472
|
}
|
473
|
+
|
423
474
|
var dmax = domain[1];
|
475
|
+
|
424
476
|
if (i < bounds.length) {
|
425
477
|
dmax = bounds[i];
|
426
478
|
}
|
479
|
+
|
427
480
|
var rmin = encode[2 * i];
|
428
481
|
var rmax = encode[2 * i + 1];
|
429
482
|
tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
|
430
483
|
fns[i](tmpBuf, 0, dest, destOffset);
|
431
484
|
};
|
432
485
|
},
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
var
|
486
|
+
|
487
|
+
constructPostScript({
|
488
|
+
xref,
|
489
|
+
isEvalSupported,
|
490
|
+
fn,
|
491
|
+
dict
|
492
|
+
}) {
|
493
|
+
var domain = toNumberArray(dict.getArray("Domain"));
|
494
|
+
var range = toNumberArray(dict.getArray("Range"));
|
495
|
+
|
441
496
|
if (!domain) {
|
442
|
-
throw new _util.FormatError(
|
497
|
+
throw new _util.FormatError("No domain.");
|
443
498
|
}
|
499
|
+
|
444
500
|
if (!range) {
|
445
|
-
throw new _util.FormatError(
|
501
|
+
throw new _util.FormatError("No range.");
|
446
502
|
}
|
503
|
+
|
447
504
|
var lexer = new _ps_parser.PostScriptLexer(fn);
|
448
505
|
var parser = new _ps_parser.PostScriptParser(lexer);
|
449
506
|
var code = parser.parse();
|
450
507
|
return [CONSTRUCT_POSTSCRIPT, domain, range, code];
|
451
508
|
},
|
452
|
-
constructPostScriptFromIR: function constructPostScriptFromIR(_ref13) {
|
453
|
-
var xref = _ref13.xref,
|
454
|
-
isEvalSupported = _ref13.isEvalSupported,
|
455
|
-
IR = _ref13.IR;
|
456
509
|
|
510
|
+
constructPostScriptFromIR({
|
511
|
+
xref,
|
512
|
+
isEvalSupported,
|
513
|
+
IR
|
514
|
+
}) {
|
457
515
|
var domain = IR[1];
|
458
516
|
var range = IR[2];
|
459
517
|
var code = IR[3];
|
460
|
-
|
461
|
-
|
518
|
+
|
519
|
+
if (isEvalSupported && _util.IsEvalSupportedCached.value) {
|
520
|
+
const compiled = new PostScriptCompiler().compile(code, domain, range);
|
521
|
+
|
462
522
|
if (compiled) {
|
463
|
-
return new Function(
|
523
|
+
return new Function("src", "srcOffset", "dest", "destOffset", compiled);
|
464
524
|
}
|
465
525
|
}
|
466
|
-
|
526
|
+
|
527
|
+
(0, _util.info)("Unable to compile PS function");
|
467
528
|
var numOutputs = range.length >> 1;
|
468
529
|
var numInputs = domain.length >> 1;
|
469
530
|
var evaluator = new PostScriptEvaluator(code);
|
@@ -473,46 +534,59 @@ var PDFFunction = function PDFFunctionClosure() {
|
|
473
534
|
var tmpBuf = new Float32Array(numInputs);
|
474
535
|
return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
|
475
536
|
var i, value;
|
476
|
-
var key =
|
537
|
+
var key = "";
|
477
538
|
var input = tmpBuf;
|
539
|
+
|
478
540
|
for (i = 0; i < numInputs; i++) {
|
479
541
|
value = src[srcOffset + i];
|
480
542
|
input[i] = value;
|
481
|
-
key += value +
|
543
|
+
key += value + "_";
|
482
544
|
}
|
545
|
+
|
483
546
|
var cachedValue = cache[key];
|
547
|
+
|
484
548
|
if (cachedValue !== undefined) {
|
485
549
|
dest.set(cachedValue, destOffset);
|
486
550
|
return;
|
487
551
|
}
|
552
|
+
|
488
553
|
var output = new Float32Array(numOutputs);
|
489
554
|
var stack = evaluator.execute(input);
|
490
555
|
var stackIndex = stack.length - numOutputs;
|
556
|
+
|
491
557
|
for (i = 0; i < numOutputs; i++) {
|
492
558
|
value = stack[stackIndex + i];
|
493
559
|
var bound = range[i * 2];
|
560
|
+
|
494
561
|
if (value < bound) {
|
495
562
|
value = bound;
|
496
563
|
} else {
|
497
564
|
bound = range[i * 2 + 1];
|
565
|
+
|
498
566
|
if (value > bound) {
|
499
567
|
value = bound;
|
500
568
|
}
|
501
569
|
}
|
570
|
+
|
502
571
|
output[i] = value;
|
503
572
|
}
|
573
|
+
|
504
574
|
if (cache_available > 0) {
|
505
575
|
cache_available--;
|
506
576
|
cache[key] = output;
|
507
577
|
}
|
578
|
+
|
508
579
|
dest.set(output, destOffset);
|
509
580
|
};
|
510
581
|
}
|
582
|
+
|
511
583
|
};
|
512
584
|
}();
|
585
|
+
|
513
586
|
function isPDFFunction(v) {
|
514
587
|
var fnDict;
|
515
|
-
|
588
|
+
|
589
|
+
if (typeof v !== "object") {
|
516
590
|
return false;
|
517
591
|
} else if ((0, _primitives.isDict)(v)) {
|
518
592
|
fnDict = v;
|
@@ -521,31 +595,39 @@ function isPDFFunction(v) {
|
|
521
595
|
} else {
|
522
596
|
return false;
|
523
597
|
}
|
524
|
-
|
598
|
+
|
599
|
+
return fnDict.has("FunctionType");
|
525
600
|
}
|
601
|
+
|
526
602
|
var PostScriptStack = function PostScriptStackClosure() {
|
527
603
|
var MAX_STACK_SIZE = 100;
|
604
|
+
|
528
605
|
function PostScriptStack(initialStack) {
|
529
606
|
this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
|
530
607
|
}
|
608
|
+
|
531
609
|
PostScriptStack.prototype = {
|
532
610
|
push: function PostScriptStack_push(value) {
|
533
611
|
if (this.stack.length >= MAX_STACK_SIZE) {
|
534
|
-
throw new Error(
|
612
|
+
throw new Error("PostScript function stack overflow.");
|
535
613
|
}
|
614
|
+
|
536
615
|
this.stack.push(value);
|
537
616
|
},
|
538
617
|
pop: function PostScriptStack_pop() {
|
539
618
|
if (this.stack.length <= 0) {
|
540
|
-
throw new Error(
|
619
|
+
throw new Error("PostScript function stack underflow.");
|
541
620
|
}
|
621
|
+
|
542
622
|
return this.stack.pop();
|
543
623
|
},
|
544
624
|
copy: function PostScriptStack_copy(n) {
|
545
625
|
if (this.stack.length + n >= MAX_STACK_SIZE) {
|
546
|
-
throw new Error(
|
626
|
+
throw new Error("PostScript function stack overflow.");
|
547
627
|
}
|
628
|
+
|
548
629
|
var stack = this.stack;
|
630
|
+
|
549
631
|
for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
|
550
632
|
stack.push(stack[i]);
|
551
633
|
}
|
@@ -561,16 +643,19 @@ var PostScriptStack = function PostScriptStackClosure() {
|
|
561
643
|
i,
|
562
644
|
j,
|
563
645
|
t;
|
646
|
+
|
564
647
|
for (i = l, j = r; i < j; i++, j--) {
|
565
648
|
t = stack[i];
|
566
649
|
stack[i] = stack[j];
|
567
650
|
stack[j] = t;
|
568
651
|
}
|
652
|
+
|
569
653
|
for (i = l, j = c - 1; i < j; i++, j--) {
|
570
654
|
t = stack[i];
|
571
655
|
stack[i] = stack[j];
|
572
656
|
stack[j] = t;
|
573
657
|
}
|
658
|
+
|
574
659
|
for (i = c, j = r; i < j; i++, j--) {
|
575
660
|
t = stack[i];
|
576
661
|
stack[i] = stack[j];
|
@@ -580,10 +665,12 @@ var PostScriptStack = function PostScriptStackClosure() {
|
|
580
665
|
};
|
581
666
|
return PostScriptStack;
|
582
667
|
}();
|
668
|
+
|
583
669
|
var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
|
584
670
|
function PostScriptEvaluator(operators) {
|
585
671
|
this.operators = operators;
|
586
672
|
}
|
673
|
+
|
587
674
|
PostScriptEvaluator.prototype = {
|
588
675
|
execute: function PostScriptEvaluator_execute(initialStack) {
|
589
676
|
var stack = new PostScriptStack(initialStack);
|
@@ -591,384 +678,487 @@ var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
|
|
591
678
|
var operators = this.operators;
|
592
679
|
var length = operators.length;
|
593
680
|
var operator, a, b;
|
681
|
+
|
594
682
|
while (counter < length) {
|
595
683
|
operator = operators[counter++];
|
596
|
-
|
684
|
+
|
685
|
+
if (typeof operator === "number") {
|
597
686
|
stack.push(operator);
|
598
687
|
continue;
|
599
688
|
}
|
689
|
+
|
600
690
|
switch (operator) {
|
601
|
-
case
|
691
|
+
case "jz":
|
602
692
|
b = stack.pop();
|
603
693
|
a = stack.pop();
|
694
|
+
|
604
695
|
if (!a) {
|
605
696
|
counter = b;
|
606
697
|
}
|
698
|
+
|
607
699
|
break;
|
608
|
-
|
700
|
+
|
701
|
+
case "j":
|
609
702
|
a = stack.pop();
|
610
703
|
counter = a;
|
611
704
|
break;
|
612
|
-
|
705
|
+
|
706
|
+
case "abs":
|
613
707
|
a = stack.pop();
|
614
708
|
stack.push(Math.abs(a));
|
615
709
|
break;
|
616
|
-
|
710
|
+
|
711
|
+
case "add":
|
617
712
|
b = stack.pop();
|
618
713
|
a = stack.pop();
|
619
714
|
stack.push(a + b);
|
620
715
|
break;
|
621
|
-
|
716
|
+
|
717
|
+
case "and":
|
622
718
|
b = stack.pop();
|
623
719
|
a = stack.pop();
|
720
|
+
|
624
721
|
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
|
625
722
|
stack.push(a && b);
|
626
723
|
} else {
|
627
724
|
stack.push(a & b);
|
628
725
|
}
|
726
|
+
|
629
727
|
break;
|
630
|
-
|
728
|
+
|
729
|
+
case "atan":
|
631
730
|
a = stack.pop();
|
632
731
|
stack.push(Math.atan(a));
|
633
732
|
break;
|
634
|
-
|
733
|
+
|
734
|
+
case "bitshift":
|
635
735
|
b = stack.pop();
|
636
736
|
a = stack.pop();
|
737
|
+
|
637
738
|
if (a > 0) {
|
638
739
|
stack.push(a << b);
|
639
740
|
} else {
|
640
741
|
stack.push(a >> b);
|
641
742
|
}
|
743
|
+
|
642
744
|
break;
|
643
|
-
|
745
|
+
|
746
|
+
case "ceiling":
|
644
747
|
a = stack.pop();
|
645
748
|
stack.push(Math.ceil(a));
|
646
749
|
break;
|
647
|
-
|
750
|
+
|
751
|
+
case "copy":
|
648
752
|
a = stack.pop();
|
649
753
|
stack.copy(a);
|
650
754
|
break;
|
651
|
-
|
755
|
+
|
756
|
+
case "cos":
|
652
757
|
a = stack.pop();
|
653
758
|
stack.push(Math.cos(a));
|
654
759
|
break;
|
655
|
-
|
760
|
+
|
761
|
+
case "cvi":
|
656
762
|
a = stack.pop() | 0;
|
657
763
|
stack.push(a);
|
658
764
|
break;
|
659
|
-
|
765
|
+
|
766
|
+
case "cvr":
|
660
767
|
break;
|
661
|
-
|
768
|
+
|
769
|
+
case "div":
|
662
770
|
b = stack.pop();
|
663
771
|
a = stack.pop();
|
664
772
|
stack.push(a / b);
|
665
773
|
break;
|
666
|
-
|
774
|
+
|
775
|
+
case "dup":
|
667
776
|
stack.copy(1);
|
668
777
|
break;
|
669
|
-
|
778
|
+
|
779
|
+
case "eq":
|
670
780
|
b = stack.pop();
|
671
781
|
a = stack.pop();
|
672
782
|
stack.push(a === b);
|
673
783
|
break;
|
674
|
-
|
784
|
+
|
785
|
+
case "exch":
|
675
786
|
stack.roll(2, 1);
|
676
787
|
break;
|
677
|
-
|
788
|
+
|
789
|
+
case "exp":
|
678
790
|
b = stack.pop();
|
679
791
|
a = stack.pop();
|
680
|
-
stack.push(
|
792
|
+
stack.push(a ** b);
|
681
793
|
break;
|
682
|
-
|
794
|
+
|
795
|
+
case "false":
|
683
796
|
stack.push(false);
|
684
797
|
break;
|
685
|
-
|
798
|
+
|
799
|
+
case "floor":
|
686
800
|
a = stack.pop();
|
687
801
|
stack.push(Math.floor(a));
|
688
802
|
break;
|
689
|
-
|
803
|
+
|
804
|
+
case "ge":
|
690
805
|
b = stack.pop();
|
691
806
|
a = stack.pop();
|
692
807
|
stack.push(a >= b);
|
693
808
|
break;
|
694
|
-
|
809
|
+
|
810
|
+
case "gt":
|
695
811
|
b = stack.pop();
|
696
812
|
a = stack.pop();
|
697
813
|
stack.push(a > b);
|
698
814
|
break;
|
699
|
-
|
815
|
+
|
816
|
+
case "idiv":
|
700
817
|
b = stack.pop();
|
701
818
|
a = stack.pop();
|
702
819
|
stack.push(a / b | 0);
|
703
820
|
break;
|
704
|
-
|
821
|
+
|
822
|
+
case "index":
|
705
823
|
a = stack.pop();
|
706
824
|
stack.index(a);
|
707
825
|
break;
|
708
|
-
|
826
|
+
|
827
|
+
case "le":
|
709
828
|
b = stack.pop();
|
710
829
|
a = stack.pop();
|
711
830
|
stack.push(a <= b);
|
712
831
|
break;
|
713
|
-
|
832
|
+
|
833
|
+
case "ln":
|
714
834
|
a = stack.pop();
|
715
835
|
stack.push(Math.log(a));
|
716
836
|
break;
|
717
|
-
|
837
|
+
|
838
|
+
case "log":
|
718
839
|
a = stack.pop();
|
719
840
|
stack.push(Math.log(a) / Math.LN10);
|
720
841
|
break;
|
721
|
-
|
842
|
+
|
843
|
+
case "lt":
|
722
844
|
b = stack.pop();
|
723
845
|
a = stack.pop();
|
724
846
|
stack.push(a < b);
|
725
847
|
break;
|
726
|
-
|
848
|
+
|
849
|
+
case "mod":
|
727
850
|
b = stack.pop();
|
728
851
|
a = stack.pop();
|
729
852
|
stack.push(a % b);
|
730
853
|
break;
|
731
|
-
|
854
|
+
|
855
|
+
case "mul":
|
732
856
|
b = stack.pop();
|
733
857
|
a = stack.pop();
|
734
858
|
stack.push(a * b);
|
735
859
|
break;
|
736
|
-
|
860
|
+
|
861
|
+
case "ne":
|
737
862
|
b = stack.pop();
|
738
863
|
a = stack.pop();
|
739
864
|
stack.push(a !== b);
|
740
865
|
break;
|
741
|
-
|
866
|
+
|
867
|
+
case "neg":
|
742
868
|
a = stack.pop();
|
743
869
|
stack.push(-a);
|
744
870
|
break;
|
745
|
-
|
871
|
+
|
872
|
+
case "not":
|
746
873
|
a = stack.pop();
|
874
|
+
|
747
875
|
if ((0, _util.isBool)(a)) {
|
748
876
|
stack.push(!a);
|
749
877
|
} else {
|
750
878
|
stack.push(~a);
|
751
879
|
}
|
880
|
+
|
752
881
|
break;
|
753
|
-
|
882
|
+
|
883
|
+
case "or":
|
754
884
|
b = stack.pop();
|
755
885
|
a = stack.pop();
|
886
|
+
|
756
887
|
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
|
757
888
|
stack.push(a || b);
|
758
889
|
} else {
|
759
890
|
stack.push(a | b);
|
760
891
|
}
|
892
|
+
|
761
893
|
break;
|
762
|
-
|
894
|
+
|
895
|
+
case "pop":
|
763
896
|
stack.pop();
|
764
897
|
break;
|
765
|
-
|
898
|
+
|
899
|
+
case "roll":
|
766
900
|
b = stack.pop();
|
767
901
|
a = stack.pop();
|
768
902
|
stack.roll(a, b);
|
769
903
|
break;
|
770
|
-
|
904
|
+
|
905
|
+
case "round":
|
771
906
|
a = stack.pop();
|
772
907
|
stack.push(Math.round(a));
|
773
908
|
break;
|
774
|
-
|
909
|
+
|
910
|
+
case "sin":
|
775
911
|
a = stack.pop();
|
776
912
|
stack.push(Math.sin(a));
|
777
913
|
break;
|
778
|
-
|
914
|
+
|
915
|
+
case "sqrt":
|
779
916
|
a = stack.pop();
|
780
917
|
stack.push(Math.sqrt(a));
|
781
918
|
break;
|
782
|
-
|
919
|
+
|
920
|
+
case "sub":
|
783
921
|
b = stack.pop();
|
784
922
|
a = stack.pop();
|
785
923
|
stack.push(a - b);
|
786
924
|
break;
|
787
|
-
|
925
|
+
|
926
|
+
case "true":
|
788
927
|
stack.push(true);
|
789
928
|
break;
|
790
|
-
|
929
|
+
|
930
|
+
case "truncate":
|
791
931
|
a = stack.pop();
|
792
932
|
a = a < 0 ? Math.ceil(a) : Math.floor(a);
|
793
933
|
stack.push(a);
|
794
934
|
break;
|
795
|
-
|
935
|
+
|
936
|
+
case "xor":
|
796
937
|
b = stack.pop();
|
797
938
|
a = stack.pop();
|
939
|
+
|
798
940
|
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
|
799
941
|
stack.push(a !== b);
|
800
942
|
} else {
|
801
943
|
stack.push(a ^ b);
|
802
944
|
}
|
945
|
+
|
803
946
|
break;
|
947
|
+
|
804
948
|
default:
|
805
|
-
throw new _util.FormatError(
|
949
|
+
throw new _util.FormatError(`Unknown operator ${operator}`);
|
806
950
|
}
|
807
951
|
}
|
952
|
+
|
808
953
|
return stack.stack;
|
809
954
|
}
|
810
955
|
};
|
811
956
|
return PostScriptEvaluator;
|
812
957
|
}();
|
958
|
+
|
959
|
+
exports.PostScriptEvaluator = PostScriptEvaluator;
|
960
|
+
|
813
961
|
var PostScriptCompiler = function PostScriptCompilerClosure() {
|
814
962
|
function AstNode(type) {
|
815
963
|
this.type = type;
|
816
964
|
}
|
965
|
+
|
817
966
|
AstNode.prototype.visit = function (visitor) {
|
818
|
-
(0, _util.unreachable)(
|
967
|
+
(0, _util.unreachable)("abstract method");
|
819
968
|
};
|
969
|
+
|
820
970
|
function AstArgument(index, min, max) {
|
821
|
-
AstNode.call(this,
|
971
|
+
AstNode.call(this, "args");
|
822
972
|
this.index = index;
|
823
973
|
this.min = min;
|
824
974
|
this.max = max;
|
825
975
|
}
|
976
|
+
|
826
977
|
AstArgument.prototype = Object.create(AstNode.prototype);
|
978
|
+
|
827
979
|
AstArgument.prototype.visit = function (visitor) {
|
828
980
|
visitor.visitArgument(this);
|
829
981
|
};
|
982
|
+
|
830
983
|
function AstLiteral(number) {
|
831
|
-
AstNode.call(this,
|
984
|
+
AstNode.call(this, "literal");
|
832
985
|
this.number = number;
|
833
986
|
this.min = number;
|
834
987
|
this.max = number;
|
835
988
|
}
|
989
|
+
|
836
990
|
AstLiteral.prototype = Object.create(AstNode.prototype);
|
991
|
+
|
837
992
|
AstLiteral.prototype.visit = function (visitor) {
|
838
993
|
visitor.visitLiteral(this);
|
839
994
|
};
|
995
|
+
|
840
996
|
function AstBinaryOperation(op, arg1, arg2, min, max) {
|
841
|
-
AstNode.call(this,
|
997
|
+
AstNode.call(this, "binary");
|
842
998
|
this.op = op;
|
843
999
|
this.arg1 = arg1;
|
844
1000
|
this.arg2 = arg2;
|
845
1001
|
this.min = min;
|
846
1002
|
this.max = max;
|
847
1003
|
}
|
1004
|
+
|
848
1005
|
AstBinaryOperation.prototype = Object.create(AstNode.prototype);
|
1006
|
+
|
849
1007
|
AstBinaryOperation.prototype.visit = function (visitor) {
|
850
1008
|
visitor.visitBinaryOperation(this);
|
851
1009
|
};
|
1010
|
+
|
852
1011
|
function AstMin(arg, max) {
|
853
|
-
AstNode.call(this,
|
1012
|
+
AstNode.call(this, "max");
|
854
1013
|
this.arg = arg;
|
855
1014
|
this.min = arg.min;
|
856
1015
|
this.max = max;
|
857
1016
|
}
|
1017
|
+
|
858
1018
|
AstMin.prototype = Object.create(AstNode.prototype);
|
1019
|
+
|
859
1020
|
AstMin.prototype.visit = function (visitor) {
|
860
1021
|
visitor.visitMin(this);
|
861
1022
|
};
|
1023
|
+
|
862
1024
|
function AstVariable(index, min, max) {
|
863
|
-
AstNode.call(this,
|
1025
|
+
AstNode.call(this, "var");
|
864
1026
|
this.index = index;
|
865
1027
|
this.min = min;
|
866
1028
|
this.max = max;
|
867
1029
|
}
|
1030
|
+
|
868
1031
|
AstVariable.prototype = Object.create(AstNode.prototype);
|
1032
|
+
|
869
1033
|
AstVariable.prototype.visit = function (visitor) {
|
870
1034
|
visitor.visitVariable(this);
|
871
1035
|
};
|
1036
|
+
|
872
1037
|
function AstVariableDefinition(variable, arg) {
|
873
|
-
AstNode.call(this,
|
1038
|
+
AstNode.call(this, "definition");
|
874
1039
|
this.variable = variable;
|
875
1040
|
this.arg = arg;
|
876
1041
|
}
|
1042
|
+
|
877
1043
|
AstVariableDefinition.prototype = Object.create(AstNode.prototype);
|
1044
|
+
|
878
1045
|
AstVariableDefinition.prototype.visit = function (visitor) {
|
879
1046
|
visitor.visitVariableDefinition(this);
|
880
1047
|
};
|
1048
|
+
|
881
1049
|
function ExpressionBuilderVisitor() {
|
882
1050
|
this.parts = [];
|
883
1051
|
}
|
1052
|
+
|
884
1053
|
ExpressionBuilderVisitor.prototype = {
|
885
|
-
visitArgument
|
886
|
-
this.parts.push(
|
1054
|
+
visitArgument(arg) {
|
1055
|
+
this.parts.push("Math.max(", arg.min, ", Math.min(", arg.max, ", src[srcOffset + ", arg.index, "]))");
|
887
1056
|
},
|
888
|
-
|
889
|
-
|
1057
|
+
|
1058
|
+
visitVariable(variable) {
|
1059
|
+
this.parts.push("v", variable.index);
|
890
1060
|
},
|
891
|
-
|
1061
|
+
|
1062
|
+
visitLiteral(literal) {
|
892
1063
|
this.parts.push(literal.number);
|
893
1064
|
},
|
894
|
-
|
895
|
-
|
1065
|
+
|
1066
|
+
visitBinaryOperation(operation) {
|
1067
|
+
this.parts.push("(");
|
896
1068
|
operation.arg1.visit(this);
|
897
|
-
this.parts.push(
|
1069
|
+
this.parts.push(" ", operation.op, " ");
|
898
1070
|
operation.arg2.visit(this);
|
899
|
-
this.parts.push(
|
1071
|
+
this.parts.push(")");
|
900
1072
|
},
|
901
|
-
|
902
|
-
|
1073
|
+
|
1074
|
+
visitVariableDefinition(definition) {
|
1075
|
+
this.parts.push("var ");
|
903
1076
|
definition.variable.visit(this);
|
904
|
-
this.parts.push(
|
1077
|
+
this.parts.push(" = ");
|
905
1078
|
definition.arg.visit(this);
|
906
|
-
this.parts.push(
|
1079
|
+
this.parts.push(";");
|
907
1080
|
},
|
908
|
-
|
909
|
-
|
1081
|
+
|
1082
|
+
visitMin(max) {
|
1083
|
+
this.parts.push("Math.min(");
|
910
1084
|
max.arg.visit(this);
|
911
|
-
this.parts.push(
|
1085
|
+
this.parts.push(", ", max.max, ")");
|
912
1086
|
},
|
913
|
-
|
914
|
-
|
1087
|
+
|
1088
|
+
toString() {
|
1089
|
+
return this.parts.join("");
|
915
1090
|
}
|
1091
|
+
|
916
1092
|
};
|
1093
|
+
|
917
1094
|
function buildAddOperation(num1, num2) {
|
918
|
-
if (num2.type ===
|
1095
|
+
if (num2.type === "literal" && num2.number === 0) {
|
919
1096
|
return num1;
|
920
1097
|
}
|
921
|
-
|
1098
|
+
|
1099
|
+
if (num1.type === "literal" && num1.number === 0) {
|
922
1100
|
return num2;
|
923
1101
|
}
|
924
|
-
|
1102
|
+
|
1103
|
+
if (num2.type === "literal" && num1.type === "literal") {
|
925
1104
|
return new AstLiteral(num1.number + num2.number);
|
926
1105
|
}
|
927
|
-
|
1106
|
+
|
1107
|
+
return new AstBinaryOperation("+", num1, num2, num1.min + num2.min, num1.max + num2.max);
|
928
1108
|
}
|
1109
|
+
|
929
1110
|
function buildMulOperation(num1, num2) {
|
930
|
-
if (num2.type ===
|
1111
|
+
if (num2.type === "literal") {
|
931
1112
|
if (num2.number === 0) {
|
932
1113
|
return new AstLiteral(0);
|
933
1114
|
} else if (num2.number === 1) {
|
934
1115
|
return num1;
|
935
|
-
} else if (num1.type ===
|
1116
|
+
} else if (num1.type === "literal") {
|
936
1117
|
return new AstLiteral(num1.number * num2.number);
|
937
1118
|
}
|
938
1119
|
}
|
939
|
-
|
1120
|
+
|
1121
|
+
if (num1.type === "literal") {
|
940
1122
|
if (num1.number === 0) {
|
941
1123
|
return new AstLiteral(0);
|
942
1124
|
} else if (num1.number === 1) {
|
943
1125
|
return num2;
|
944
1126
|
}
|
945
1127
|
}
|
1128
|
+
|
946
1129
|
var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
|
947
1130
|
var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
|
948
|
-
return new AstBinaryOperation(
|
1131
|
+
return new AstBinaryOperation("*", num1, num2, min, max);
|
949
1132
|
}
|
1133
|
+
|
950
1134
|
function buildSubOperation(num1, num2) {
|
951
|
-
if (num2.type ===
|
1135
|
+
if (num2.type === "literal") {
|
952
1136
|
if (num2.number === 0) {
|
953
1137
|
return num1;
|
954
|
-
} else if (num1.type ===
|
1138
|
+
} else if (num1.type === "literal") {
|
955
1139
|
return new AstLiteral(num1.number - num2.number);
|
956
1140
|
}
|
957
1141
|
}
|
958
|
-
|
1142
|
+
|
1143
|
+
if (num2.type === "binary" && num2.op === "-" && num1.type === "literal" && num1.number === 1 && num2.arg1.type === "literal" && num2.arg1.number === 1) {
|
959
1144
|
return num2.arg2;
|
960
1145
|
}
|
961
|
-
|
1146
|
+
|
1147
|
+
return new AstBinaryOperation("-", num1, num2, num1.min - num2.max, num1.max - num2.min);
|
962
1148
|
}
|
1149
|
+
|
963
1150
|
function buildMinOperation(num1, max) {
|
964
1151
|
if (num1.min >= max) {
|
965
1152
|
return new AstLiteral(max);
|
966
1153
|
} else if (num1.max <= max) {
|
967
1154
|
return num1;
|
968
1155
|
}
|
1156
|
+
|
969
1157
|
return new AstMin(num1, max);
|
970
1158
|
}
|
1159
|
+
|
971
1160
|
function PostScriptCompiler() {}
|
1161
|
+
|
972
1162
|
PostScriptCompiler.prototype = {
|
973
1163
|
compile: function PostScriptCompiler_compile(code, domain, range) {
|
974
1164
|
var stack = [];
|
@@ -979,128 +1169,167 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
|
|
979
1169
|
var lastRegister = 0;
|
980
1170
|
var n, j;
|
981
1171
|
var num1, num2, ast1, ast2, tmpVar, item;
|
1172
|
+
|
982
1173
|
for (i = 0; i < inputSize; i++) {
|
983
1174
|
stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
|
984
1175
|
}
|
1176
|
+
|
985
1177
|
for (i = 0, ii = code.length; i < ii; i++) {
|
986
1178
|
item = code[i];
|
987
|
-
|
1179
|
+
|
1180
|
+
if (typeof item === "number") {
|
988
1181
|
stack.push(new AstLiteral(item));
|
989
1182
|
continue;
|
990
1183
|
}
|
1184
|
+
|
991
1185
|
switch (item) {
|
992
|
-
case
|
1186
|
+
case "add":
|
993
1187
|
if (stack.length < 2) {
|
994
1188
|
return null;
|
995
1189
|
}
|
1190
|
+
|
996
1191
|
num2 = stack.pop();
|
997
1192
|
num1 = stack.pop();
|
998
1193
|
stack.push(buildAddOperation(num1, num2));
|
999
1194
|
break;
|
1000
|
-
|
1195
|
+
|
1196
|
+
case "cvr":
|
1001
1197
|
if (stack.length < 1) {
|
1002
1198
|
return null;
|
1003
1199
|
}
|
1200
|
+
|
1004
1201
|
break;
|
1005
|
-
|
1202
|
+
|
1203
|
+
case "mul":
|
1006
1204
|
if (stack.length < 2) {
|
1007
1205
|
return null;
|
1008
1206
|
}
|
1207
|
+
|
1009
1208
|
num2 = stack.pop();
|
1010
1209
|
num1 = stack.pop();
|
1011
1210
|
stack.push(buildMulOperation(num1, num2));
|
1012
1211
|
break;
|
1013
|
-
|
1212
|
+
|
1213
|
+
case "sub":
|
1014
1214
|
if (stack.length < 2) {
|
1015
1215
|
return null;
|
1016
1216
|
}
|
1217
|
+
|
1017
1218
|
num2 = stack.pop();
|
1018
1219
|
num1 = stack.pop();
|
1019
1220
|
stack.push(buildSubOperation(num1, num2));
|
1020
1221
|
break;
|
1021
|
-
|
1222
|
+
|
1223
|
+
case "exch":
|
1022
1224
|
if (stack.length < 2) {
|
1023
1225
|
return null;
|
1024
1226
|
}
|
1227
|
+
|
1025
1228
|
ast1 = stack.pop();
|
1026
1229
|
ast2 = stack.pop();
|
1027
1230
|
stack.push(ast1, ast2);
|
1028
1231
|
break;
|
1029
|
-
|
1232
|
+
|
1233
|
+
case "pop":
|
1030
1234
|
if (stack.length < 1) {
|
1031
1235
|
return null;
|
1032
1236
|
}
|
1237
|
+
|
1033
1238
|
stack.pop();
|
1034
1239
|
break;
|
1035
|
-
|
1240
|
+
|
1241
|
+
case "index":
|
1036
1242
|
if (stack.length < 1) {
|
1037
1243
|
return null;
|
1038
1244
|
}
|
1245
|
+
|
1039
1246
|
num1 = stack.pop();
|
1040
|
-
|
1247
|
+
|
1248
|
+
if (num1.type !== "literal") {
|
1041
1249
|
return null;
|
1042
1250
|
}
|
1251
|
+
|
1043
1252
|
n = num1.number;
|
1253
|
+
|
1044
1254
|
if (n < 0 || !Number.isInteger(n) || stack.length < n) {
|
1045
1255
|
return null;
|
1046
1256
|
}
|
1257
|
+
|
1047
1258
|
ast1 = stack[stack.length - n - 1];
|
1048
|
-
|
1259
|
+
|
1260
|
+
if (ast1.type === "literal" || ast1.type === "var") {
|
1049
1261
|
stack.push(ast1);
|
1050
1262
|
break;
|
1051
1263
|
}
|
1264
|
+
|
1052
1265
|
tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
|
1053
1266
|
stack[stack.length - n - 1] = tmpVar;
|
1054
1267
|
stack.push(tmpVar);
|
1055
1268
|
instructions.push(new AstVariableDefinition(tmpVar, ast1));
|
1056
1269
|
break;
|
1057
|
-
|
1270
|
+
|
1271
|
+
case "dup":
|
1058
1272
|
if (stack.length < 1) {
|
1059
1273
|
return null;
|
1060
1274
|
}
|
1061
|
-
|
1275
|
+
|
1276
|
+
if (typeof code[i + 1] === "number" && code[i + 2] === "gt" && code[i + 3] === i + 7 && code[i + 4] === "jz" && code[i + 5] === "pop" && code[i + 6] === code[i + 1]) {
|
1062
1277
|
num1 = stack.pop();
|
1063
1278
|
stack.push(buildMinOperation(num1, code[i + 1]));
|
1064
1279
|
i += 6;
|
1065
1280
|
break;
|
1066
1281
|
}
|
1282
|
+
|
1067
1283
|
ast1 = stack[stack.length - 1];
|
1068
|
-
|
1284
|
+
|
1285
|
+
if (ast1.type === "literal" || ast1.type === "var") {
|
1069
1286
|
stack.push(ast1);
|
1070
1287
|
break;
|
1071
1288
|
}
|
1289
|
+
|
1072
1290
|
tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
|
1073
1291
|
stack[stack.length - 1] = tmpVar;
|
1074
1292
|
stack.push(tmpVar);
|
1075
1293
|
instructions.push(new AstVariableDefinition(tmpVar, ast1));
|
1076
1294
|
break;
|
1077
|
-
|
1295
|
+
|
1296
|
+
case "roll":
|
1078
1297
|
if (stack.length < 2) {
|
1079
1298
|
return null;
|
1080
1299
|
}
|
1300
|
+
|
1081
1301
|
num2 = stack.pop();
|
1082
1302
|
num1 = stack.pop();
|
1083
|
-
|
1303
|
+
|
1304
|
+
if (num2.type !== "literal" || num1.type !== "literal") {
|
1084
1305
|
return null;
|
1085
1306
|
}
|
1307
|
+
|
1086
1308
|
j = num2.number;
|
1087
1309
|
n = num1.number;
|
1310
|
+
|
1088
1311
|
if (n <= 0 || !Number.isInteger(n) || !Number.isInteger(j) || stack.length < n) {
|
1089
1312
|
return null;
|
1090
1313
|
}
|
1314
|
+
|
1091
1315
|
j = (j % n + n) % n;
|
1316
|
+
|
1092
1317
|
if (j === 0) {
|
1093
1318
|
break;
|
1094
1319
|
}
|
1320
|
+
|
1095
1321
|
Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
|
1096
1322
|
break;
|
1323
|
+
|
1097
1324
|
default:
|
1098
1325
|
return null;
|
1099
1326
|
}
|
1100
1327
|
}
|
1328
|
+
|
1101
1329
|
if (stack.length !== outputSize) {
|
1102
1330
|
return null;
|
1103
1331
|
}
|
1332
|
+
|
1104
1333
|
var result = [];
|
1105
1334
|
instructions.forEach(function (instruction) {
|
1106
1335
|
var statementBuilder = new ExpressionBuilderVisitor();
|
@@ -1113,24 +1342,25 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
|
|
1113
1342
|
var min = range[i * 2],
|
1114
1343
|
max = range[i * 2 + 1];
|
1115
1344
|
var out = [statementBuilder.toString()];
|
1345
|
+
|
1116
1346
|
if (min > expr.min) {
|
1117
|
-
out.unshift(
|
1118
|
-
out.push(
|
1347
|
+
out.unshift("Math.max(", min, ", ");
|
1348
|
+
out.push(")");
|
1119
1349
|
}
|
1350
|
+
|
1120
1351
|
if (max < expr.max) {
|
1121
|
-
out.unshift(
|
1122
|
-
out.push(
|
1352
|
+
out.unshift("Math.min(", max, ", ");
|
1353
|
+
out.push(")");
|
1123
1354
|
}
|
1124
|
-
|
1125
|
-
out.
|
1126
|
-
|
1355
|
+
|
1356
|
+
out.unshift("dest[destOffset + ", i, "] = ");
|
1357
|
+
out.push(";");
|
1358
|
+
result.push(out.join(""));
|
1127
1359
|
});
|
1128
|
-
return result.join(
|
1360
|
+
return result.join("\n");
|
1129
1361
|
}
|
1130
1362
|
};
|
1131
1363
|
return PostScriptCompiler;
|
1132
1364
|
}();
|
1133
|
-
|
1134
|
-
exports.PDFFunctionFactory = PDFFunctionFactory;
|
1135
|
-
exports.PostScriptEvaluator = PostScriptEvaluator;
|
1365
|
+
|
1136
1366
|
exports.PostScriptCompiler = PostScriptCompiler;
|