Minor refactoring of EvaluatorPreprocessor_read
This commit is contained in:
parent
e0bf7e2151
commit
6731de6829
@ -2074,7 +2074,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
|
|||||||
}
|
}
|
||||||
if (!isCmd(obj)) {
|
if (!isCmd(obj)) {
|
||||||
// argument
|
// argument
|
||||||
if (obj != null) {
|
if (obj !== null) {
|
||||||
args.push((obj instanceof Dict ? obj.getAll() : obj));
|
args.push((obj instanceof Dict ? obj.getAll() : obj));
|
||||||
assert(args.length <= 33, 'Too many arguments');
|
assert(args.length <= 33, 'Too many arguments');
|
||||||
}
|
}
|
||||||
@ -2090,37 +2090,32 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fn = opSpec.id;
|
var fn = opSpec.id;
|
||||||
|
var numArgs = opSpec.numArgs;
|
||||||
|
|
||||||
// Some post script commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf
|
if (!opSpec.variableArgs) {
|
||||||
if (!opSpec.variableArgs && args.length !== opSpec.numArgs) {
|
// Some post script commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf
|
||||||
while (args.length > opSpec.numArgs) {
|
if (args.length !== numArgs) {
|
||||||
this.nonProcessedArgs.push(args.shift());
|
var nonProcessedArgs = this.nonProcessedArgs;
|
||||||
|
while (args.length > numArgs) {
|
||||||
|
nonProcessedArgs.push(args.shift());
|
||||||
|
}
|
||||||
|
while (args.length < numArgs && nonProcessedArgs.length !== 0) {
|
||||||
|
args.unshift(nonProcessedArgs.pop());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (args.length < opSpec.numArgs && this.nonProcessedArgs.length) {
|
if (args.length < numArgs) {
|
||||||
args.unshift(this.nonProcessedArgs.pop());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate the number of arguments for the command
|
|
||||||
if (opSpec.variableArgs) {
|
|
||||||
if (args.length > opSpec.numArgs) {
|
|
||||||
info('Command ' + fn + ': expected [0,' + opSpec.numArgs +
|
|
||||||
'] args, but received ' + args.length + ' args');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (args.length < opSpec.numArgs) {
|
|
||||||
// If we receive too few args, it's not possible to possible
|
// If we receive too few args, it's not possible to possible
|
||||||
// to execute the command, so skip the command
|
// to execute the command, so skip the command
|
||||||
info('Command ' + fn + ': because expected ' +
|
info('Command ' + fn + ': because expected ' +
|
||||||
opSpec.numArgs + ' args, but received ' + args.length +
|
numArgs + ' args, but received ' + args.length +
|
||||||
' args; skipping');
|
' args; skipping');
|
||||||
args = [];
|
args = [];
|
||||||
continue;
|
continue;
|
||||||
} else if (args.length > opSpec.numArgs) {
|
|
||||||
info('Command ' + fn + ': expected ' + opSpec.numArgs +
|
|
||||||
' args, but received ' + args.length + ' args');
|
|
||||||
}
|
}
|
||||||
|
} else if (args.length > numArgs) {
|
||||||
|
info('Command ' + fn + ': expected [0,' + numArgs +
|
||||||
|
'] args, but received ' + args.length + ' args');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO figure out how to type-check vararg functions
|
// TODO figure out how to type-check vararg functions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user