ExpressionIF.java

package edu.udel.cis.vsl.tass.model.IF.expression;

import java.util.Collection;

import edu.udel.cis.vsl.tass.model.IF.type.TypeIF;
import edu.udel.cis.vsl.tass.model.IF.variable.VariableIF;
import edu.udel.cis.vsl.tass.util.Sourceable;

public interface ExpressionIF extends Sourceable {

	enum ExpressionKind {
		/** Arithmetic addtion: x+y */
		ADD,
		/**
		 * The address of a left-hand side expression, a pointer value. In C,
		 * "&e".
		 */
		ADDRESS_OF,
		/**
		 * Logical and; in C "x && y".
		 */
		AND,
		/**
		 * A special expression that can be used in a receive statement to
		 * indicate the incoming message can originate from any process. Has
		 * form any(e), where e is null or a left-hand-side expression. If
		 * non-null, the PID of the sender of the message is written to e upon
		 * receiving the message.
		 */
		ANY,
		/**
		 * A special kind of expression used to define an array value using a
		 * lambda expression, as in "the array of int of length N for which the
		 * element in position i is i*i+b[i-j]+10."
		 */
		ARRAY_LAMBDA,
		CAST,
		DEREFERENCE,
		DIVIDE,
		EQUALS,
		EXISTS,
		FORALL,
		FUNCTION,
		IF_THEN_ELSE,
		LAMBDA,
		LENGTH,
		LEQ,
		LESS_THAN,
		LITERAL,
		MODULO,
		MULTIPLY,
		NAVIGATE,
		NEGATIVE,
		NOT,
		NOT_EMPTY,
		NOT_FULL,
		OR,
		POINTER_ADD,
		PROCESS_REF,
		SIZEOF,
		SUBSCRIPT,
		SUBTRACT,
		VARIABLE
	}

	/**
	 * A string representation of the expression that can be included in other
	 * expressions because it has been made an "atom", usually by surrounding it
	 * with parens (...). For example "(a+b)".
	 */
	String atomString();

	/**
	 * Returns the kind of this expression, an element of the enumerated type
	 * ExpressionKind.
	 */
	ExpressionKind kind();

	/**
	 * Returns the set of all variables referenced in this expression. These are
	 * the "free" variables that occur in the expression. A bound variable
	 * (which is declared inside the expression) is not included in this set.
	 * For example, if the expression is "x>0 && exists y.x=y" then {x} is
	 * returned. However, for the sub-expressions "x=y", both x and y would be
	 * returned because both of those variables are free within that expression.
	 */
	Collection<VariableIF> freeVariables();

	/**
	 * A string representation of the expression suitable for printing as long
	 * as it is not included as a subexpressions of another expression. For
	 * example, "a+b".
	 */
	String toString();

	/** Returns the static type of this expression. */
	TypeIF type();

	/**
	 * A hook on which the user of this class can hang any kind of object he
	 * wants. Intended use: instance of ValueIF, which is the result of
	 * evaluating the expression.
	 */
	void setDynamicValue(Object object);

	/** Gets the object set by setDynamicValue(). */
	Object dynamicValue();
}