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