All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.evosuite.symbolic.expr.ref.GetFieldExpression Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2010-2018 Gordon Fraser, Andrea Arcuri and EvoSuite
 * contributors
 *
 * This file is part of EvoSuite.
 *
 * EvoSuite is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3.0 of the License, or
 * (at your option) any later version.
 *
 * EvoSuite is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with EvoSuite. If not, see .
 */
package org.evosuite.symbolic.expr.ref;

import java.util.Set;

import org.evosuite.symbolic.expr.ExpressionVisitor;
import org.evosuite.symbolic.expr.Variable;
import org.objectweb.asm.Type;

public final class GetFieldExpression extends ReferenceExpression {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4517401722564017247L;

	private final ReferenceExpression receiverExpr;

	private final String fieldName;

	/**
	 * Creates a symbolic expression of the form "expr.F" where expr is the
	 * ReferenceExpression, F is the string fieldName
	 * and the concrete value of the symbolic expression "expr.F" is
	 * concreteValue
	 * 
	 * @param receiverExpr
	 *            the symbolic expression of the receiver object
	 * @param fieldName
	 *            the field name
	 * @param concreteValue
	 *            the concrete object for the symbolic expression expr.F
	 */
	public GetFieldExpression(Type objectType, int instanceId, ReferenceExpression receiverExpr, String fieldName,
			Object concreteValue) {
		super(objectType, instanceId, 1 + receiverExpr.getSize(), receiverExpr.containsSymbolicVariable());
		this.receiverExpr = receiverExpr;
		this.fieldName = fieldName;
		this.initializeReference(concreteValue);
	}

	/**
	 * Returns the set of all the variables in the receiver expression (the expr
	 * in expr.F)
	 * 
	 * @return
	 */
	@Override
	public Set> getVariables() {
		return this.receiverExpr.getVariables();
	}

	@Override
	public  K accept(ExpressionVisitor v, V arg) {
		return v.visit(this, arg);
	}

	/**
	 * Returns the receiver expression (the expr in expr.F)
	 * 
	 * @return
	 */
	public ReferenceExpression getReceiverExpr() {
		return receiverExpr;
	}

	/**
	 * Returns the field name (the F in expr.F)
	 * 
	 * @return
	 */
	public String getFieldName() {
		return fieldName;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy