Esempio 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);
        }
Esempio n. 2
0
 public override bool MatchWith(TigerType type)
 {
     return type is RecordType || type is ArrayType || type == StringType.StringInstance || type == UndefinedType.UndefinedInstance;
 }
Esempio n. 3
0
 public virtual bool MatchWith(TigerType type)
 {
     return this == type || type == UndefinedType.UndefinedInstance;
 }
Esempio n. 4
0
 public override bool MatchWith(TigerType type)
 {
     return this == type || type == UndefinedType.UndefinedInstance || type == NillType.NillInstance;
 }
Esempio n. 5
0
 public ArrayType(TigerType elementsType, string typeName)
 {
     ElementsType = elementsType;
     this.typeName = typeName;
 }
Esempio 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));
 }
Esempio n. 7
0
 public void AddType(string name, TigerType type)
 {
     typesDic.Add(name, type);
 }
Esempio n. 8
0
 public override bool MatchWith(TigerType type)
 {
     return true;
 }