FunctionInvocationNode.java

package edu.udel.cis.vsl.tass.ast.impl.expression;

import java.util.NoSuchElementException;

import edu.udel.cis.vsl.tass.ast.IF.ASTNodeIF;
import edu.udel.cis.vsl.tass.ast.IF.LabelNodeIF;
import edu.udel.cis.vsl.tass.ast.IF.SequenceNodeIF;
import edu.udel.cis.vsl.tass.ast.IF.expression.ExpressionNodeIF;
import edu.udel.cis.vsl.tass.ast.IF.expression.FunctionInvocationNodeIF;
import edu.udel.cis.vsl.tass.ast.impl.ASTNode;

public class FunctionInvocationNode extends ASTNode implements
		FunctionInvocationNodeIF {

	ExpressionNodeIF function;
	SequenceNodeIF<ExpressionNodeIF> arguments;
	
	public FunctionInvocationNode(long id) {
		super(id);
	}
	
	public FunctionInvocationNode(long id, ExpressionNodeIF function, SequenceNodeIF<ExpressionNodeIF> arguments) {
		super(id);
		this.function = function;
		this.arguments = arguments;
	}

	@Override
	public SequenceNodeIF<LabelNodeIF> labels() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setLabels(SequenceNodeIF<LabelNodeIF> labels) {
		// TODO Auto-generated method stub

	}

	@Override
	public int numChildren() {
		return 2;
	}

	@Override
	public ASTNodeIF child(int index) throws NoSuchElementException {
		if (index == 0) {
			return function;
		}
		if (index == 1) {
			return arguments;
		}
		throw new NoSuchElementException("Node " + id()
				+ " does not have a child with index " + index + ".");
	}

	@SuppressWarnings("unchecked")
	@Override
	public void setChild(int i, ASTNodeIF child) throws NoSuchElementException {
		if (i == 0) {
			this.function = (ExpressionNodeIF) child;
		} else if (i == 1) {
			this.arguments = (SequenceNodeIF<ExpressionNodeIF>) child;
		} else {
			throw new NoSuchElementException("Node " + id()
					+ " does not have a child with index " + i + ".");
		}
	}

	@Override
	public ExpressionNodeIF function() {
		return function;
	}

	@Override
	public SequenceNodeIF<ExpressionNodeIF> arguments() {
		return arguments;
	}

	@Override
	public void setFunction(ExpressionNodeIF function) {
		this.function = function;
	}

	@Override
	public void setArguments(SequenceNodeIF<ExpressionNodeIF> arguments) {
		this.arguments = arguments;
	}

}