Ejemplo n.º 1
0
 public LllType(LllType copyFrom, int pointerDepth)
     : base(copyFrom)
 {
     IsPrimitive  = copyFrom.IsPrimitive;
     Extensions   = copyFrom.Extensions;
     IsAReference = copyFrom.IsAReference;
     PointerDepth = pointerDepth;
 }
Ejemplo n.º 2
0
        public virtual LllType Clone(int withPtrDepth, bool isAReference)
        {
            var ty = new LllType(this, withPtrDepth)
            {
                IsAReference = isAReference
            };

            return(ty);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public virtual bool TryCast(LllType toType)
 {
     return(false);
 }