public VariableReference appendStaticFieldStmt(Field field) { Class<?> declaringClass = field.getDeclaringClass(); final GenericField genericField = new GenericField(field, declaringClass); // static field (receiver is null) FieldStatement stmt = new FieldStatement(tc, genericField, null); tc.addStatement(stmt); return stmt.getReturnValue(); }
public VariableReference appendFieldStmt(VariableReference receiver, Field field) { if (receiver == null) { throw new NullPointerException( "Receiver object for a non-static field cannot be null"); } FieldStatement stmt = new FieldStatement(tc, new GenericField(field, receiver.getType()), receiver); tc.addStatement(stmt); return stmt.getReturnValue(); }
StringBuilder builder = new StringBuilder(); VariableReference retval = statement.getReturnValue(); GenericField field = statement.getField();
/** {@inheritDoc} */ @Override public Statement copy(TestCase newTestCase, int offset) { if (field.isStatic()) { FieldStatement s = new FieldStatement(newTestCase, field.copy(), null); s.getReturnValue().setType(retval.getType()); // Actual type may have changed, e.g. subtype // s.assertions = copyAssertions(newTestCase, offset); return s; } else { VariableReference newSource = source.copy(newTestCase, offset); FieldStatement s = new FieldStatement(newTestCase, field.copy(), newSource); s.getReturnValue().setType(retval.getType()); // Actual type may have changed, e.g. subtype // s.assertions = copyAssertions(newTestCase, offset); return s; } }
private void after(FieldStatement s, Scope scope) { ReferenceExpressionPair readResult; if (s.getSource() != null) { readResult = readInstanceField(s.getSource(), s.getField().getField(), scope); } else { readResult = readStaticField(s.getField().getField()); } String lhs_name = s.getReturnValue().getName(); Expression<?> expr = readResult.getExpression(); ReferenceExpression ref = readResult.getReference(); if (expr != null) symb_expressions.put(lhs_name, expr); if (ref != null) symb_references.put(lhs_name, ref); }
VariableReference fieldReference = fieldStatement.getReturnValue(); if (Properties.RESET_STATIC_FIELD_GETS) { moreClassesForStaticReset.add(fieldStatement.getField().getOwnerClass().getClassName());