From 93ea866f0141dbad92edc7be0555b1510582ee2b Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 12 Feb 2016 18:15:49 +0100 Subject: [PATCH] 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`. --- src/core/evaluator.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 2fa42d7b6..df4fa0953 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -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'); } }