@NotNull private static DfaMemoryStateImpl createClosureState(@NotNull DfaMemoryState memState) { DfaMemoryStateImpl copy = (DfaMemoryStateImpl) memState.createCopy(); copy.flushFields(); Set<DfaVariableValue> vars = new HashSet<DfaVariableValue>(copy.getVariableStates().keySet()); for (DfaVariableValue value : vars) { copy.flushDependencies(value); } copy.emptyStack(); return copy; }
@Nullable private static DfaInstructionState[] handleConstantComparison( BinopInstruction instruction, DataFlowRunner runner, DfaMemoryState memState, DfaValue dfaRight, DfaValue dfaLeft, IElementType opSign) { if (dfaRight instanceof DfaConstValue && dfaLeft instanceof DfaVariableValue) { Object value = ((DfaConstValue) dfaRight).getValue(); if (value instanceof Number) { DfaInstructionState[] result = checkComparingWithConstant( instruction, runner, memState, (DfaVariableValue) dfaLeft, opSign, ((Number) value).doubleValue()); if (result != null) { return result; } } } if (dfaRight instanceof DfaVariableValue && dfaLeft instanceof DfaConstValue) { return handleConstantComparison( instruction, runner, memState, dfaLeft, dfaRight, DfaRelationValue.getSymmetricOperation(opSign)); } if (EQEQ != opSign && NE != opSign) { return null; } if (dfaLeft instanceof DfaConstValue && dfaRight instanceof DfaConstValue || dfaLeft == runner.getFactory().getConstFactory().getContractFail() || dfaRight == runner.getFactory().getConstFactory().getContractFail()) { boolean negated = (NE == opSign) ^ (DfaMemoryStateImpl.isNaN(dfaLeft) || DfaMemoryStateImpl.isNaN(dfaRight)); if (dfaLeft == dfaRight ^ negated) { return alwaysTrue(instruction, runner, memState); } return alwaysFalse(instruction, runner, memState); } return null; }