mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DfaMemoryState#castTopOfStack moved to StandardInstructionVisitor and made private
GitOrigin-RevId: e17486569a2472b4b36563209f8ee40bb2ba0b48
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d7b90a0272
commit
8691569a6f
@@ -63,15 +63,6 @@ public interface DfaMemoryState {
|
||||
|
||||
void setVarValue(DfaVariableValue var, DfaValue value);
|
||||
|
||||
/**
|
||||
* Ensures that top-of-stack value is either null or belongs to the supplied type
|
||||
*
|
||||
* @param type the type to cast to
|
||||
* @return true if cast is successful; false if top-of-stack value type is incompatible with supplied type
|
||||
* @throws java.util.EmptyStackException if stack is empty
|
||||
*/
|
||||
boolean castTopOfStack(@NotNull TypeConstraint type);
|
||||
|
||||
/**
|
||||
* Returns a relation between given values within this state, if known
|
||||
* @param left first value
|
||||
|
||||
-15
@@ -519,21 +519,6 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
return myStack.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean castTopOfStack(@NotNull TypeConstraint type) {
|
||||
DfaValue value = peek();
|
||||
DfType dfType = getDfType(value);
|
||||
DfType result = dfType.meet(type.asDfType());
|
||||
if (!result.equals(dfType)) {
|
||||
if (result == DfTypes.NULL || !meetDfType(value, result)) return false;
|
||||
if (!(value instanceof DfaVariableValue)) {
|
||||
pop();
|
||||
push(myFactory.fromDfType(result));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void convertReferenceEqualityToValueEquality(DfaValue value) {
|
||||
int id = canonicalize(value).getID();
|
||||
Integer index = myIdToEqClassesIndices.get(id);
|
||||
|
||||
+18
-2
@@ -282,7 +282,7 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
if (transfer != null) {
|
||||
DfaMemoryState castFail = memState.createCopy();
|
||||
if (fromType != null && type.isConvertibleFrom(fromType)) {
|
||||
if (!memState.castTopOfStack(constraint)) {
|
||||
if (!castTopOfStack(factory, memState, constraint)) {
|
||||
castPossible = false;
|
||||
} else {
|
||||
result.add(new DfaInstructionState(runner.getInstruction(instruction.getIndex() + 1), memState));
|
||||
@@ -302,7 +302,7 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
}
|
||||
} else {
|
||||
if (fromType != null && type.isConvertibleFrom(fromType)) {
|
||||
if (!memState.castTopOfStack(constraint)) {
|
||||
if (!castTopOfStack(factory, memState, constraint)) {
|
||||
castPossible = false;
|
||||
}
|
||||
}
|
||||
@@ -315,6 +315,22 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
return result.toArray(DfaInstructionState.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
private static boolean castTopOfStack(@NotNull DfaValueFactory factory,
|
||||
@NotNull DfaMemoryState state,
|
||||
@NotNull TypeConstraint type) {
|
||||
DfaValue value = state.peek();
|
||||
DfType dfType = state.getDfType(value);
|
||||
DfType result = dfType.meet(type.asDfType());
|
||||
if (!result.equals(dfType)) {
|
||||
if (result == DfTypes.NULL || !state.meetDfType(value, result)) return false;
|
||||
if (!(value instanceof DfaVariableValue)) {
|
||||
state.pop();
|
||||
state.push(factory.fromDfType(result));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void onTypeCast(PsiTypeCastExpression castExpression, DfaMemoryState state, boolean castPossible) {}
|
||||
|
||||
protected void beforeMethodCall(@NotNull PsiExpression expression,
|
||||
|
||||
Reference in New Issue
Block a user