(context, block)
| 220 | } |
| 221 | |
| 222 | function checkSubBlockEqualities(context, block) { |
| 223 | // if we have an equality that is with a constant, then we need to add |
| 224 | // a node for that equality since we couldn't fold the constant into the variable |
| 225 | let equalityIx = 0; |
| 226 | for(let equality of block.equalities) { |
| 227 | if(!equality) continue; |
| 228 | let [left, right] = equality; |
| 229 | let needsEquality; |
| 230 | let hasLeft = context.hasVariable(left); |
| 231 | let hasRight = context.hasVariable(right); |
| 232 | if(left.type === "constant" && (hasRight || right.type === "constant")) { |
| 233 | needsEquality = true; |
| 234 | } else if(right.type === "constant" && (hasLeft || left.type === "constant")) { |
| 235 | needsEquality = true; |
| 236 | } else if(hasLeft && hasRight) { |
| 237 | needsEquality = true; |
| 238 | } else if(hasLeft && !join.isVariable(context.getValue(left))) { |
| 239 | needsEquality = true; |
| 240 | } else if(hasRight && !join.isVariable(context.getValue(right))) { |
| 241 | needsEquality = true; |
| 242 | } |
| 243 | // console.log("branch equality", left, right, leftVal, rightVal); |
| 244 | if(needsEquality) { |
| 245 | let expression = {type: "expression", op: "=", args: equality}; |
| 246 | block.expressions.push(expression) |
| 247 | block.equalities[equalityIx] = undefined; |
| 248 | } |
| 249 | equalityIx++; |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | function buildScans(block, context, scanLikes, outputScans) { |
| 254 | let {unprovided} = block; |
no test coverage detected