SendStatement.java

package edu.udel.cis.vsl.tass.model.impl.statement;

import edu.udel.cis.vsl.tass.model.IF.ModelFactoryIF;
import edu.udel.cis.vsl.tass.model.IF.SyntaxException;
import edu.udel.cis.vsl.tass.model.IF.expression.ExpressionIF;
import edu.udel.cis.vsl.tass.model.IF.expression.LHSExpressionIF;
import edu.udel.cis.vsl.tass.model.IF.location.SendLocationIF;
import edu.udel.cis.vsl.tass.model.IF.statement.SendStatementIF;
import edu.udel.cis.vsl.tass.model.IF.type.TypeIF.TypeKind;

public class SendStatement extends Statement implements SendStatementIF {

	private LHSExpressionIF buffer;

	private ExpressionIF destination;

	private ExpressionIF tag;

	public SendStatement(ModelFactoryIF factory, SendLocationIF sourceLocation,
			LHSExpressionIF buffer, ExpressionIF destination, ExpressionIF tag)
			throws SyntaxException {
		super(factory, factory.notFullExpression(sourceLocation.model(),
				factory
						.integerLiteralExpression(sourceLocation.process()
								.pid()), destination, tag), sourceLocation,
				StatementKind.SEND);
		if (destination.type().kind() != TypeKind.INTEGER)
			throw new SyntaxException(destination,
					"Source argument should be integer type, not "
							+ destination.type());
		if (tag.type().kind() != TypeKind.INTEGER)
			throw new SyntaxException(tag,
					"Tag argument should be integer type, not " + tag.type());
		factory.checkScope(buffer, sourceLocation.scope());
		factory.checkScope(tag, sourceLocation.scope());
		factory.checkScope(destination, sourceLocation.scope());
		this.buffer = buffer;
		this.tag = tag;
		this.destination = destination;
	}

	public LHSExpressionIF buffer() {
		return buffer;
	}

	public ExpressionIF tag() {
		return tag;
	}

	public ExpressionIF destination() {
		return destination;
	}

	public String toString() {
		return "send(" + buffer + "," + destination + "," + tag + ");";
	}

	public void complete() throws SyntaxException {
		super.complete();
		isLocal = false;
	}

}