@Test public void fillStackWithResolvedDotMemberValue() throws Exception { state = state.pushToStack(BuiltInObjectSymbolicValue.STRING_PROTOTYPE); assertThat(dotMemberPoint.execute(state).isPresent()).isTrue(); dotMemberPoint.execute(state).ifPresent(s -> assertThat(s.getConstraint(s.peekStack())).isEqualTo(Constraint.POSITIVE_NUMBER_PRIMITIVE.or(Constraint.ZERO))); }
@Override public Optional<ProgramState> execute(final ProgramState state) { final SymbolicValue objectValue; final ExpressionStack expressionStack = state.getStack(); final ExpressionStack newExpressionStack; Optional<ProgramState> newState; if (element.is(Tree.Kind.BRACKET_MEMBER_EXPRESSION)) { objectValue = state.peekStack(1); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.pop(); stack.push(UnknownSymbolicValue.UNKNOWN); }); } else { objectValue = state.peekStack(0); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.push(resolvePropertyValue(newState.get(), objectValue)); }); } return Optional.of(newState.get().withStack(newExpressionStack)); }
MemberProgramPoint implements ProgramPoint { @Override public Optional<ProgramState> execute(final ProgramState state) { final SymbolicValue objectValue; final ExpressionStack expressionStack = state.getStack(); final ExpressionStack newExpressionStack; Optional<ProgramState> newState; if (element.is(Tree.Kind.BRACKET_MEMBER_EXPRESSION)) { objectValue = state.peekStack(1); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.pop(); stack.push(UnknownSymbolicValue.UNKNOWN); }); } else { objectValue = state.peekStack(0); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.push(resolvePropertyValue(newState.get(), objectValue)); }); } return Optional.of(newState.get().withStack(newExpressionStack)); } }
MemberProgramPoint implements ProgramPoint { @Override public Optional<ProgramState> execute(final ProgramState state) { final SymbolicValue objectValue; final ExpressionStack expressionStack = state.getStack(); final ExpressionStack newExpressionStack; Optional<ProgramState> newState; if (element.is(Tree.Kind.BRACKET_MEMBER_EXPRESSION)) { objectValue = state.peekStack(1); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.pop(); stack.push(UnknownSymbolicValue.UNKNOWN); }); } else { objectValue = state.peekStack(0); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.push(resolvePropertyValue(newState.get(), objectValue)); }); } return Optional.of(newState.get().withStack(newExpressionStack)); } MemberProgramPoint(Tree element); }
MemberProgramPoint implements ProgramPoint { @Override public Optional<ProgramState> execute(final ProgramState state) { final SymbolicValue objectValue; final ExpressionStack expressionStack = state.getStack(); final ExpressionStack newExpressionStack; Optional<ProgramState> newState; if (element.is(Tree.Kind.BRACKET_MEMBER_EXPRESSION)) { objectValue = state.peekStack(1); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.pop(); stack.push(UnknownSymbolicValue.UNKNOWN); }); } else { objectValue = state.peekStack(0); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.push(resolvePropertyValue(newState.get(), objectValue)); }); } return Optional.of(newState.get().withStack(newExpressionStack)); } MemberProgramPoint(Tree element); static boolean originatesFrom(Tree element); @Override Optional<ProgramState> execute(final ProgramState state); Optional<ProgramState> executeStrictMode(final  ProgramState state); }
MemberProgramPoint implements ProgramPoint { @Override public Optional<ProgramState> execute(final ProgramState state) { final SymbolicValue objectValue; final ExpressionStack expressionStack = state.getStack(); final ExpressionStack newExpressionStack; Optional<ProgramState> newState; if (element.is(Tree.Kind.BRACKET_MEMBER_EXPRESSION)) { objectValue = state.peekStack(1); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.pop(); stack.push(UnknownSymbolicValue.UNKNOWN); }); } else { objectValue = state.peekStack(0); newState = state.constrain(objectValue, Constraint.NOT_NULLY); if(!newState.isPresent()) { return newState; } newExpressionStack = expressionStack.apply(stack -> { stack.pop(); stack.push(resolvePropertyValue(newState.get(), objectValue)); }); } return Optional.of(newState.get().withStack(newExpressionStack)); } MemberProgramPoint(Tree element); static boolean originatesFrom(Tree element); @Override Optional<ProgramState> execute(final ProgramState state); Optional<ProgramState> executeStrictMode(final  ProgramState state);  }