public LllType(LllType copyFrom, int pointerDepth) : base(copyFrom) { IsPrimitive = copyFrom.IsPrimitive; Extensions = copyFrom.Extensions; IsAReference = copyFrom.IsAReference; PointerDepth = pointerDepth; }
public virtual LllType Clone(int withPtrDepth, bool isAReference) { var ty = new LllType(this, withPtrDepth) { IsAReference = isAReference }; return(ty); }
public override bool TryCast(LllType toType) { // IMPLICIT TYPE COERCION FOR INTEGER TYPES: // if the from-type (this), is unsigned it is only allowed to up-cast to the next tier // if the to-type is signed. // if the from-type (this), is signed, it is only allowed to cast to other signed types. var tt = toType as LllIntegerType; if (tt == null) { return(false); } if (Equals(tt)) { return(true); } // disallow casting pointers to actual integer types if (tt.PointerDepth != 0 || PointerDepth != 0) { return(false); } // disallow casting a signed type to an unsigned type. if (Signed && !tt.Signed) { return(false); } // up-casting unsigned to a larger signed type. if (!Signed && tt.Signed) { return(tt.Size > Size); } // Up or side-casting for same-signed integers return(tt.Size >= Size); }
public virtual bool TryCast(LllType toType) { return(false); }