RealTypeNode.java

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

import java.io.PrintWriter;
import java.util.NoSuchElementException;

import edu.udel.cis.vsl.tass.ast.IF.ASTNodeIF;
import edu.udel.cis.vsl.tass.ast.IF.type.RealTypeNodeIF;
import edu.udel.cis.vsl.tass.ast.impl.ASTNode;

public class RealTypeNode extends ASTNode implements RealTypeNodeIF {

	private FloatType floatType;

	public RealTypeNode(long id) {
		super(id);
	}
	
	public RealTypeNode(long id, FloatType floatType) {
		super(id);
		this.floatType = floatType;
	}

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

	@Override
	public ASTNodeIF child(int index) throws NoSuchElementException {
		throw new NoSuchElementException("Node " + id()
				+ " does not have a child with index " + index + ".");
	}

	@Override
	public void setChild(int i, ASTNodeIF child) throws NoSuchElementException {
		throw new NoSuchElementException("Node " + id()
				+ " does not have a child with index " + i + ".");
	}

	@Override
	public String toString() {
		return floatType.toString();
	}

	@Override
	public void print(String prefix, PrintWriter out) {
		out.println(prefix + " AST Node " + id() + ", " + toString());
	}

	@Override
	public FloatType floatType() {
		return floatType;
	}

	@Override
	public void setFloatType(FloatType type) {
		this.floatType = type;
	}

}