Package tree.type

Source Code of tree.type.Enum

package tree.type;

import imp.parser.antlr.HaxeParser;

import java.util.ArrayList;
import java.util.List;

import org.antlr.runtime.Token;

import tree.HaxeTree;
import tree.expression.Declaration;
import tree.statement.BlockScope;

public class Enum extends HaxeType
  public Enum(final Token t) {
    super(t);
  }

  public HaxeTree getInherits()
  {
    for (HaxeTree tree : (ArrayList<HaxeTree>)getChildren())
    {
      if (tree.getType() == HaxeParser.EXTENDS)
      {
        return (HaxeTree) tree;
      }
    }
    return null;
  }
 
  /**
   * class D extends A, implements B, implements C {}
   * Каждый экземпляр D будет иметь тип D, но также имеет типы A , B и C.
   *
   * @return Class Name type with implemented types record for each class/interface 
   * it extended/implemented
   */
  @Override
  public HaxeType getHaxeType()
  {
    return this;
  }

  /**
   * Gets the all declared vars.
   *
   * @return the all declared vars
   */
  public List<HaxeTree> getAllMembers() {
    List<HaxeTree> list = new ArrayList<HaxeTree>();

    BlockScope blockScope = getBlockScope();
    if (blockScope == null)
    {
        return list;
    }
    for (HaxeTree x: blockScope.getChildren())
      if (x instanceof Declaration)
        list.add(x);
    return list;
  }

    @Override
    public HaxeTree getDeclaration(final String name)
    {
        for (HaxeTree child : getAllMembers())
        {
            if (child.getText().equals(name))
            {
                return child;
            }
        }
        return null;
    }

}
TOP

Related Classes of tree.type.Enum

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.