Exemplo n.º 1
0
        public static Type GetCLRType(TigerType t)
        {
            if (t is IntType)
                return typeof(int);

            if (t is StringType)
                return typeof(string);

            if (t is VoidType)
                return typeof(void);

            if (t is ArrayType)
            {
                Type elemType = GetCLRType(((ArrayType)t).ElementsType);
                return Array.CreateInstance(elemType, 1).GetType();
            }

            if (t is RecordType)
                return ((RecordType)t).TypeBuilder;

            return typeof(object);
        }
Exemplo n.º 2
0
 public override bool MatchWith(TigerType type)
 {
     return type is RecordType || type is ArrayType || type == StringType.StringInstance || type == UndefinedType.UndefinedInstance;
 }
Exemplo n.º 3
0
 public virtual bool MatchWith(TigerType type)
 {
     return this == type || type == UndefinedType.UndefinedInstance;
 }
Exemplo n.º 4
0
 public override bool MatchWith(TigerType type)
 {
     return this == type || type == UndefinedType.UndefinedInstance || type == NillType.NillInstance;
 }
Exemplo n.º 5
0
 public ArrayType(TigerType elementsType, string typeName)
 {
     ElementsType = elementsType;
     this.typeName = typeName;
 }
Exemplo n.º 6
0
 public bool HasType(TigerType t)
 {
     if (t is VoidType || t is UndefinedType || t is NillType)
         return true;
     return typesDic.Values.Any(typedecl => typedecl.MatchWith(t)) || (Parent != null && Parent.HasType(t));
 }
Exemplo n.º 7
0
 public void AddType(string name, TigerType type)
 {
     typesDic.Add(name, type);
 }
Exemplo n.º 8
0
 public override bool MatchWith(TigerType type)
 {
     return true;
 }