use of com.intellij.codeInspection.bytecodeAnalysis.Direction.In in project intellij-community by JetBrains.
the class Analysis method createStartFrame.
final Frame<BasicValue> createStartFrame() {
Frame<BasicValue> frame = new Frame<>(methodNode.maxLocals, methodNode.maxStack);
Type returnType = Type.getReturnType(methodNode.desc);
BasicValue returnValue = Type.VOID_TYPE.equals(returnType) ? null : new BasicValue(returnType);
frame.setReturn(returnValue);
Type[] args = Type.getArgumentTypes(methodNode.desc);
int local = 0;
if ((methodNode.access & Opcodes.ACC_STATIC) == 0) {
frame.setLocal(local++, new AbstractValues.NotNullValue(Type.getObjectType(controlFlow.className)));
}
for (int i = 0; i < args.length; i++) {
BasicValue value;
if (direction instanceof InOut && ((InOut) direction).paramIndex == i || direction instanceof In && ((In) direction).paramIndex == i) {
value = new AbstractValues.ParamValue(args[i]);
} else {
value = new BasicValue(args[i]);
}
frame.setLocal(local++, value);
if (args[i].getSize() == 2) {
frame.setLocal(local++, BasicValue.UNINITIALIZED_VALUE);
}
}
while (local < methodNode.maxLocals) {
frame.setLocal(local++, BasicValue.UNINITIALIZED_VALUE);
}
return frame;
}
use of com.intellij.codeInspection.bytecodeAnalysis.Direction.In in project intellij-community by JetBrains.
the class NullableInterpreter method naryOperation.
@Override
public BasicValue naryOperation(AbstractInsnNode insn, List<? extends BasicValue> values) throws AnalyzerException {
int opcode = insn.getOpcode();
boolean isStaticInvoke = opcode == INVOKESTATIC;
int shift = isStaticInvoke ? 0 : 1;
if ((opcode == INVOKESPECIAL || opcode == INVOKEINTERFACE || opcode == INVOKEVIRTUAL) && values.get(0) instanceof ParamValue) {
subResult = NPE;
}
switch(opcode) {
case INVOKEINTERFACE:
if (nullableAnalysis) {
for (int i = shift; i < values.size(); i++) {
if (values.get(i) instanceof ParamValue) {
top = true;
return super.naryOperation(insn, values);
}
}
}
break;
case INVOKESTATIC:
case INVOKESPECIAL:
case INVOKEVIRTUAL:
boolean stable = opcode == INVOKESTATIC || opcode == INVOKESPECIAL;
MethodInsnNode methodNode = (MethodInsnNode) insn;
Method method = new Method(methodNode.owner, methodNode.name, methodNode.desc);
for (int i = shift; i < values.size(); i++) {
BasicValue value = values.get(i);
if (value instanceof ParamValue || (NullValue == value && nullityMask == In.NULLABLE_MASK && "<init>".equals(methodNode.name))) {
subResult = combine(subResult, new ConditionalNPE(new Key(method, new In(i - shift, nullityMask), stable)));
}
}
break;
default:
}
return super.naryOperation(insn, values);
}
Aggregations