Example #1
0
        public void ReplaceTypeWithPredefined(TypeSpec ts, BuildinTypeSpec pts)
        {
            var found = types [ts.Name];

            cached_types.Remove(ts.Name);
            if (found.Count == 1)
            {
                types[ts.Name][0] = pts;
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Example #2
0
        public BuildinTypes()
        {
            Object    = new BuildinTypeSpec(MemberKind.Class, "System", "Object", BuildinTypeSpec.Type.Object);
            ValueType = new BuildinTypeSpec(MemberKind.Class, "System", "ValueType", BuildinTypeSpec.Type.ValueType);
            Attribute = new BuildinTypeSpec(MemberKind.Class, "System", "Attribute", BuildinTypeSpec.Type.Attribute);

            Int    = new BuildinTypeSpec(MemberKind.Struct, "System", "Int32", BuildinTypeSpec.Type.Int);
            Long   = new BuildinTypeSpec(MemberKind.Struct, "System", "Int64", BuildinTypeSpec.Type.Long);
            UInt   = new BuildinTypeSpec(MemberKind.Struct, "System", "UInt32", BuildinTypeSpec.Type.UInt);
            ULong  = new BuildinTypeSpec(MemberKind.Struct, "System", "UInt64", BuildinTypeSpec.Type.ULong);
            Byte   = new BuildinTypeSpec(MemberKind.Struct, "System", "Byte", BuildinTypeSpec.Type.Byte);
            SByte  = new BuildinTypeSpec(MemberKind.Struct, "System", "SByte", BuildinTypeSpec.Type.SByte);
            Short  = new BuildinTypeSpec(MemberKind.Struct, "System", "Int16", BuildinTypeSpec.Type.Short);
            UShort = new BuildinTypeSpec(MemberKind.Struct, "System", "UInt16", BuildinTypeSpec.Type.UShort);

            IEnumerator = new BuildinTypeSpec(MemberKind.Interface, "System.Collections", "IEnumerator", BuildinTypeSpec.Type.IEnumerator);
            IEnumerable = new BuildinTypeSpec(MemberKind.Interface, "System.Collections", "IEnumerable", BuildinTypeSpec.Type.IEnumerable);
            IDisposable = new BuildinTypeSpec(MemberKind.Interface, "System", "IDisposable", BuildinTypeSpec.Type.IDisposable);

            Char    = new BuildinTypeSpec(MemberKind.Struct, "System", "Char", BuildinTypeSpec.Type.Char);
            String  = new BuildinTypeSpec(MemberKind.Class, "System", "String", BuildinTypeSpec.Type.String);
            Float   = new BuildinTypeSpec(MemberKind.Struct, "System", "Single", BuildinTypeSpec.Type.Float);
            Double  = new BuildinTypeSpec(MemberKind.Struct, "System", "Double", BuildinTypeSpec.Type.Double);
            Decimal = new BuildinTypeSpec(MemberKind.Struct, "System", "Decimal", BuildinTypeSpec.Type.Decimal);
            Bool    = new BuildinTypeSpec(MemberKind.Struct, "System", "Boolean", BuildinTypeSpec.Type.Bool);
            IntPtr  = new BuildinTypeSpec(MemberKind.Struct, "System", "IntPtr", BuildinTypeSpec.Type.IntPtr);
            UIntPtr = new BuildinTypeSpec(MemberKind.Struct, "System", "UIntPtr", BuildinTypeSpec.Type.UIntPtr);

            MulticastDelegate = new BuildinTypeSpec(MemberKind.Class, "System", "MulticastDelegate", BuildinTypeSpec.Type.MulticastDelegate);
            Delegate          = new BuildinTypeSpec(MemberKind.Class, "System", "Delegate", BuildinTypeSpec.Type.Delegate);
            Enum               = new BuildinTypeSpec(MemberKind.Class, "System", "Enum", BuildinTypeSpec.Type.Enum);
            Array              = new BuildinTypeSpec(MemberKind.Class, "System", "Array", BuildinTypeSpec.Type.Array);
            Void               = new BuildinTypeSpec(MemberKind.Struct, "System", "Void", BuildinTypeSpec.Type.Void);
            Type               = new BuildinTypeSpec(MemberKind.Class, "System", "Type", BuildinTypeSpec.Type.Type);
            Exception          = new BuildinTypeSpec(MemberKind.Class, "System", "Exception", BuildinTypeSpec.Type.Exception);
            RuntimeFieldHandle = new BuildinTypeSpec(MemberKind.Struct, "System", "RuntimeFieldHandle", BuildinTypeSpec.Type.RuntimeFieldHandle);
            RuntimeTypeHandle  = new BuildinTypeSpec(MemberKind.Struct, "System", "RuntimeTypeHandle", BuildinTypeSpec.Type.RuntimeTypeHandle);

            Dynamic          = new BuildinTypeSpec("dynamic", BuildinTypeSpec.Type.Dynamic);
            Null             = new BuildinTypeSpec("null", BuildinTypeSpec.Type.Null);
            Null.MemberCache = MemberCache.Empty;

            types = new BuildinTypeSpec[] {
                Object, ValueType, Attribute,
                Int, UInt, Long, ULong, Float, Double, Char, Short, Decimal, Bool, SByte, Byte, UShort, String,
                Enum, Delegate, MulticastDelegate, Void, Array, Type, IEnumerator, IEnumerable, IDisposable,
                IntPtr, UIntPtr, RuntimeFieldHandle, RuntimeTypeHandle, Exception
            };

            // Deal with obsolete static types
            // TODO: remove
            TypeManager.object_type               = Object;
            TypeManager.value_type                = ValueType;
            TypeManager.string_type               = String;
            TypeManager.int32_type                = Int;
            TypeManager.uint32_type               = UInt;
            TypeManager.int64_type                = Long;
            TypeManager.uint64_type               = ULong;
            TypeManager.float_type                = Float;
            TypeManager.double_type               = Double;
            TypeManager.char_type                 = Char;
            TypeManager.short_type                = Short;
            TypeManager.decimal_type              = Decimal;
            TypeManager.bool_type                 = Bool;
            TypeManager.sbyte_type                = SByte;
            TypeManager.byte_type                 = Byte;
            TypeManager.ushort_type               = UShort;
            TypeManager.enum_type                 = Enum;
            TypeManager.delegate_type             = Delegate;
            TypeManager.multicast_delegate_type   = MulticastDelegate;;
            TypeManager.void_type                 = Void;
            TypeManager.array_type                = Array;;
            TypeManager.runtime_handle_type       = RuntimeTypeHandle;
            TypeManager.type_type                 = Type;
            TypeManager.ienumerator_type          = IEnumerator;
            TypeManager.ienumerable_type          = IEnumerable;
            TypeManager.idisposable_type          = IDisposable;
            TypeManager.intptr_type               = IntPtr;
            TypeManager.uintptr_type              = UIntPtr;
            TypeManager.runtime_field_handle_type = RuntimeFieldHandle;
            TypeManager.attribute_type            = Attribute;
            TypeManager.exception_type            = Exception;

            InternalType.Dynamic = Dynamic;
            InternalType.Null    = Null;
        }