Remove getAll from EvaluatorPreprocessor_read

For the operators that we currently support, the arguments are not `Dict`s, which means that it's not really necessary to use `Dict_getAll` in `EvaluatorPreprocessor_read`.
Also, I do think that if/when we support operators that use `Dict`s as arguments, that should be dealt with in the corresponding `case` in `PartialEvaluator_getOperatorList` which handles the operator.

The only reason that I can find for using `Dict_getAll` like that, is that prior to PR 6550 we would just append certain (currently unsupported) operators without doing any further processing/checking. But as issue 6549 showed, that can lead to issues in practice, which is why it was changed.

In an effort to prevent possible issue with unsupported operators, this patch simply ignores operators with `Dict` arguments in `PartialEvaluator_getOperatorList`.
This commit is contained in:
Jonas Jenwald 2016-02-12 18:15:49 +01:00
parent 62b17ad36e
commit 93ea866f01

View File

@ -1005,9 +1005,20 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// but doing so is meaningless without knowing the semantics.
continue;
default:
// Note: Let's hope that the ignored operator does not have any
// non-serializable arguments, otherwise postMessage will throw
// Note: Ignore the operator if it has `Dict` arguments, since
// those are non-serializable, otherwise postMessage will throw
// "An object could not be cloned.".
if (args !== null) {
for (i = 0, ii = args.length; i < ii; i++) {
if (args[i] instanceof Dict) {
break;
}
}
if (i < ii) {
warn('getOperatorList - ignoring operator: ' + fn);
continue;
}
}
}
operatorList.addOp(fn, args);
}
@ -2555,7 +2566,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
if (!args) {
args = [];
}
args.push((obj instanceof Dict ? obj.getAll() : obj));
args.push(obj);
assert(args.length <= 33, 'Too many arguments');
}
}