Beispiel #1
0
        public static ElementType GetElementType(KnownTypeCode typeCode)
        {
            switch (typeCode)
            {
            case KnownTypeCode.Object: return(ElementType.Object);

            case KnownTypeCode.Boolean: return(ElementType.Boolean);

            case KnownTypeCode.Char: return(ElementType.Char);

            case KnownTypeCode.SByte: return(ElementType.UInt8);

            case KnownTypeCode.Byte: return(ElementType.Int8);

            case KnownTypeCode.UInt16: return(ElementType.UInt16);

            case KnownTypeCode.Int16: return(ElementType.Int16);

            case KnownTypeCode.UInt32: return(ElementType.UInt32);

            case KnownTypeCode.Int32: return(ElementType.Int32);

            case KnownTypeCode.UInt64: return(ElementType.UInt64);

            case KnownTypeCode.Int64: return(ElementType.Int64);

            case KnownTypeCode.UIntPtr: return(ElementType.UIntPtr);

            case KnownTypeCode.IntPtr: return(ElementType.IntPtr);

            case KnownTypeCode.Single: return(ElementType.Single);

            case KnownTypeCode.Double: return(ElementType.Double);

            case KnownTypeCode.Decimal: return(ElementType.ValueType);

            case KnownTypeCode.String: return(ElementType.String);

            case KnownTypeCode.Void: return(ElementType.Void);

            default: throw new UnknownTypeException(typeCode.ToString());
            }
        }
Beispiel #2
0
        public static TypeReference GetType(KnownTypeCode typeCode)
        {
            switch (typeCode)
            {
            case KnownTypeCode.Object: return(Object);

            case KnownTypeCode.Boolean: return(Boolean);

            case KnownTypeCode.Char: return(Char);

            case KnownTypeCode.SByte: return(SByte);

            case KnownTypeCode.Byte: return(Byte);

            case KnownTypeCode.UInt16: return(UInt16);

            case KnownTypeCode.Int16: return(Int16);

            case KnownTypeCode.UInt32: return(UInt32);

            case KnownTypeCode.Int32: return(Int32);

            case KnownTypeCode.UInt64: return(UInt64);

            case KnownTypeCode.Int64: return(Int64);

            case KnownTypeCode.UIntPtr: return(UIntPtr);

            case KnownTypeCode.IntPtr: return(IntPtr);

            case KnownTypeCode.Single: return(Single);

            case KnownTypeCode.Double: return(Double);

            case KnownTypeCode.Decimal: return(Decimal);

            case KnownTypeCode.String: return(String);

            case KnownTypeCode.Void: return(Void);

            default: throw new UnknownTypeException(typeCode.ToString());
            }
        }
        public IType FindType(KnownTypeCode typeCode)
        {
            switch(typeCode){
            case KnownTypeCode.Void:
                return FindType(BVEPrimitiveTypeCode.None);

            case KnownTypeCode.Int32:
                return FindType(BVEPrimitiveTypeCode.Integer);

            case KnownTypeCode.Double:
                return FindType(BVEPrimitiveTypeCode.Float);

            case KnownTypeCode.String:
                return FindType(BVEPrimitiveTypeCode.Name);

            default:
                return new UnknownType("global", typeCode.ToString(), 0);
            }
        }
Beispiel #4
0
        LiteralExpression CreateDefaultValue(KnownTypeCode type)
        {
            LiteralExpression result = null;
            var loc = CurrentLocation;
            var type_name = type.ToString().ToLower();

            switch(type){
            case KnownTypeCode.Int:
            case KnownTypeCode.UInt:
            case KnownTypeCode.Byte:
            result = Expression.MakeConstant(type_name, 0, loc);
            break;

            case KnownTypeCode.Bool:
            result = Expression.MakeConstant(type_name, false, loc);
            break;

            case KnownTypeCode.Float:
            result = Expression.MakeConstant(type_name, 0.0, loc);
            break;

            case KnownTypeCode.String:
            result = Expression.MakeConstant(type_name, "", loc);
            break;

            case KnownTypeCode.Char:
            result = Expression.MakeConstant(type_name, '\0', loc);
            break;

            default:
            SemanticError("Error ES0030: Unknown object type");
            break;
            }

            return result;
        }