package eu.bryants.anthony.toylanguage.ast.type;

import java.util.HashSet;
import java.util.Set;

import eu.bryants.anthony.toylanguage.ast.LexicalPhrase;
import eu.bryants.anthony.toylanguage.ast.member.Member;

/*
 * Created on 14 Jul 2012
 */

/**
 * A special type that represents the value <code>null</code>. It should never be possible to declare something (e.g. variable, returned value) to be of this type.
 * @author Anthony Bryant
 */
public class NullType extends Type
{

  public NullType(LexicalPhrase lexicalPhrase)
  {
    super(true, lexicalPhrase);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public boolean canAssign(Type type)
  {
    return type instanceof NullType;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isEquivalent(Type type)
  {
    return type instanceof NullType;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public Set<Member> getMembers(String name)
  {
    return new HashSet<Member>();
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public String getMangledName()
  {
    throw new UnsupportedOperationException("The null type does not have a mangled name");
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public boolean hasDefaultValue()
  {
    return true;
  }
}

@@ -1231,11 +1231,109 @@
 rue;%0A  %7D
+%0A%0A  /**%0A   * %7B@inheritDoc%7D%0A   */%0A  @Override%0A  public String toString()%0A  %7B%0A    return %22null%22;%0A  %7D
 %0A%7D%0A

Add NullType.toString(), it returns "null"