NoopStatement.java

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

import java.util.Collection;

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.location.LocationIF;
import edu.udel.cis.vsl.tass.model.IF.statement.NoopStatementIF;
import edu.udel.cis.vsl.tass.model.IF.variable.SharedVariableIF;
import edu.udel.cis.vsl.tass.model.IF.variable.VariableIF;

public class NoopStatement extends Statement implements NoopStatementIF {

	public NoopStatement(ModelFactoryIF factory, LocationIF sourceLocation,
			ExpressionIF guard) throws SyntaxException {
		super(factory, guard, sourceLocation, StatementKind.NOOP);
	}

	public String toString() {
		return "when " + guard;
	}

	public void complete() throws SyntaxException {
		Collection<SharedVariableIF> shared = process().model().scope()
				.properSharedVariables();

		super.complete();
		isLocal = true;
		for (VariableIF variable : guard.freeVariables()) {
			if (variable instanceof SharedVariableIF
					&& shared.contains((SharedVariableIF) variable)) {
				isLocal = false;
				break;
			}
		}
	}

}