Browse Source

Restructured EvaluatorPreprocessor_read to be more natural.

Fabian Lange 11 years ago
parent
commit
60f67c3961
  1. 31
      src/core/evaluator.js

31
src/core/evaluator.js

@ -2104,21 +2104,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
var args = null; var args = null;
while (true) { while (true) {
var obj = this.parser.getObj(); var obj = this.parser.getObj();
if (isEOF(obj)) { if (isCmd(obj)) {
return false; // no more commands
}
if (!isCmd(obj)) {
// argument
if (obj !== null) {
if (!args) {
args = [];
}
args.push((obj instanceof Dict ? obj.getAll() : obj));
assert(args.length <= 33, 'Too many arguments');
}
continue;
}
var cmd = obj.cmd; var cmd = obj.cmd;
// Check that the command is valid // Check that the command is valid
var opSpec = OP_MAP[cmd]; var opSpec = OP_MAP[cmd];
@ -2131,7 +2117,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
var numArgs = opSpec.numArgs; var numArgs = opSpec.numArgs;
if (!opSpec.variableArgs) { if (!opSpec.variableArgs) {
// Some post script commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf // Postscript commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf
var argsLength = args !== null ? args.length : 0; var argsLength = args !== null ? args.length : 0;
if (argsLength !== numArgs) { if (argsLength !== numArgs) {
var nonProcessedArgs = this.nonProcessedArgs; var nonProcessedArgs = this.nonProcessedArgs;
@ -2168,6 +2154,19 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
operation.fn = fn; operation.fn = fn;
operation.args = args; operation.args = args;
return true; return true;
} else {
if (isEOF(obj)) {
return false; // no more commands
}
// argument
if (obj !== null) {
if (!args) {
args = [];
}
args.push((obj instanceof Dict ? obj.getAll() : obj));
assert(args.length <= 33, 'Too many arguments');
}
}
} }
}, },

Loading…
Cancel
Save