Esempio n. 1
0
        public TypeSystemServices(CompilerContext context)
        {
            if (null == context)
            {
                throw new ArgumentNullException("context");
            }

            _context = context;
            _anonymousCallablesManager = new AnonymousCallablesManager(this);
            _genericsServices          = new GenericsServices(context);

            CodeBuilder = new BooCodeBuilder(this);

            Cache(typeof(Builtins.duck), DuckType = new DuckTypeImpl(this));
            Cache(IQuackFuType             = new ExternalType(this, typeof(IQuackFu)));
            Cache(VoidType                 = new VoidTypeImpl(this));
            Cache(ObjectType               = new ExternalType(this, Types.Object));
            Cache(RegexType                = new ExternalType(this, Types.Regex));
            Cache(ValueTypeType            = new ExternalType(this, typeof(ValueType)));
            Cache(EnumType                 = new ExternalType(this, typeof(Enum)));
            Cache(ArrayType                = new ExternalType(this, Types.Array));
            Cache(TypeType                 = new ExternalType(this, Types.Type));
            Cache(StringType               = new ExternalType(this, Types.String));
            Cache(BoolType                 = new ExternalType(this, Types.Bool));
            Cache(SByteType                = new ExternalType(this, Types.SByte));
            Cache(CharType                 = new ExternalType(this, Types.Char));
            Cache(ShortType                = new ExternalType(this, Types.Short));
            Cache(IntType                  = new ExternalType(this, Types.Int));
            Cache(LongType                 = new ExternalType(this, Types.Long));
            Cache(ByteType                 = new ExternalType(this, Types.Byte));
            Cache(UShortType               = new ExternalType(this, Types.UShort));
            Cache(UIntType                 = new ExternalType(this, Types.UInt));
            Cache(ULongType                = new ExternalType(this, Types.ULong));
            Cache(SingleType               = new ExternalType(this, Types.Single));
            Cache(DoubleType               = new ExternalType(this, Types.Double));
            Cache(DecimalType              = new ExternalType(this, Types.Decimal));
            Cache(TimeSpanType             = new ExternalType(this, Types.TimeSpan));
            Cache(DateTimeType             = new ExternalType(this, Types.DateTime));
            Cache(RuntimeServicesType      = new ExternalType(this, Types.RuntimeServices));
            Cache(BuiltinsType             = new ExternalType(this, Types.Builtins));
            Cache(ListType                 = new ExternalType(this, Types.List));
            Cache(HashType                 = new ExternalType(this, Types.Hash));
            Cache(ICallableType            = new ExternalType(this, Types.ICallable));
            Cache(IEnumerableType          = new ExternalType(this, Types.IEnumerable));
            Cache(IEnumeratorType          = new ExternalType(this, typeof(IEnumerator)));
            Cache(ICollectionType          = new ExternalType(this, Types.ICollection));
            Cache(IListType                = new ExternalType(this, Types.IList));
            Cache(IDictionaryType          = new ExternalType(this, Types.IDictionary));
            Cache(ApplicationExceptionType = new ExternalType(this, Types.ApplicationException));
            Cache(ExceptionType            = new ExternalType(this, Types.Exception));
            Cache(IntPtrType               = new ExternalType(this, Types.IntPtr));
            Cache(UIntPtrType              = new ExternalType(this, Types.UIntPtr));
            Cache(MulticastDelegateType    = new ExternalType(this, Types.MulticastDelegate));
            Cache(DelegateType             = new ExternalType(this, Types.Delegate));
            Cache(SystemAttribute          = new ExternalType(this, typeof(System.Attribute)));
            Cache(IEnumerableGenericType   = new ExternalType(this, typeof(System.Collections.Generic.IEnumerable <>)));
            Cache(IEnumeratorGenericType   = new ExternalType(this, typeof(System.Collections.Generic.IEnumerator <>)));

            ObjectArrayType = GetArrayType(ObjectType, 1);

            PreparePrimitives();
            PrepareBuiltinFunctions();
        }
Esempio n. 2
0
        public TypeSystemServices(CompilerContext context)
        {
            if (null == context)
            {
                throw new ArgumentNullException("context");
            }

            _context = context;
            _anonymousCallablesManager = new AnonymousCallablesManager(this);

            _findImplicitConversionOperator =
                new MemoizedFunction <IType, IType, IMethod>((fromType, toType) => FindConversionOperator("op_Implicit", fromType, toType));
            _findExplicitConversionOperator =
                new MemoizedFunction <IType, IType, IMethod>((fromType, toType) => FindConversionOperator("op_Explicit", fromType, toType));

            My <CurrentScope> .Instance.Changed += (sender, args) => ClearScopeDependentMemoizedFunctions();

            _canBeReachedByPromotion = new MemoizedFunction <IType, IType, bool>(CanBeReachedByPromotionImpl);

            DuckType               = Map(typeof(Builtins.duck));
            IQuackFuType           = Map(typeof(IQuackFu));
            VoidType               = Map(Types.Void);
            ObjectType             = Map(Types.Object);
            RegexType              = Map(Types.Regex);
            ValueTypeType          = Map(typeof(ValueType));
            EnumType               = Map(typeof(Enum));
            ArrayType              = Map(Types.Array);
            TypeType               = Map(Types.Type);
            StringType             = Map(Types.String);
            BoolType               = Map(Types.Bool);
            SByteType              = Map(Types.SByte);
            CharType               = Map(Types.Char);
            ShortType              = Map(Types.Short);
            IntType                = Map(Types.Int);
            LongType               = Map(Types.Long);
            ByteType               = Map(Types.Byte);
            UShortType             = Map(Types.UShort);
            UIntType               = Map(Types.UInt);
            ULongType              = Map(Types.ULong);
            SingleType             = Map(Types.Single);
            DoubleType             = Map(Types.Double);
            DecimalType            = Map(Types.Decimal);
            TimeSpanType           = Map(Types.TimeSpan);
            DateTimeType           = Map(Types.DateTime);
            RuntimeServicesType    = Map(Types.RuntimeServices);
            BuiltinsType           = Map(Types.Builtins);
            ListType               = Map(Types.List);
            HashType               = Map(Types.Hash);
            ICallableType          = Map(Types.ICallable);
            IEnumerableType        = Map(Types.IEnumerable);
            IEnumeratorType        = Map(typeof(IEnumerator));
            ICollectionType        = Map(Types.ICollection);
            IDisposableType        = Map(typeof(IDisposable));
            IntPtrType             = Map(Types.IntPtr);
            UIntPtrType            = Map(Types.UIntPtr);
            MulticastDelegateType  = Map(Types.MulticastDelegate);
            DelegateType           = Map(Types.Delegate);
            SystemAttribute        = Map(typeof(Attribute));
            ConditionalAttribute   = Map(typeof(ConditionalAttribute));
            IEnumerableGenericType = Map(Types.IEnumerableGeneric);
            IEnumeratorGenericType = Map(typeof(IEnumerator <>));
            ICollectionGenericType = Map(typeof(ICollection <>));
            IListGenericType       = Map(typeof(IList <>));
            IListType              = Map(typeof(IList));
            IAstMacroType          = Map(typeof(IAstMacro));
            IAstGeneratorMacroType = Map(typeof(IAstGeneratorMacro));

            ObjectArrayType = ObjectType.MakeArrayType(1);

            PreparePrimitives();
            PrepareBuiltinFunctions();
        }
Esempio n. 3
0
        public TypeSystemServices(CompilerContext context)
        {
            if (null == context) throw new ArgumentNullException("context");

            _context = context;
            _anonymousCallablesManager = new AnonymousCallablesManager(this);
            _genericsServices = new GenericsServices(context);

            CodeBuilder = new BooCodeBuilder(this);

            Cache(typeof(Builtins.duck), DuckType = new DuckTypeImpl(this));
            Cache(IQuackFuType = new ExternalType(this, typeof(IQuackFu)));
            Cache(VoidType = new VoidTypeImpl(this));
            Cache(ObjectType = new ExternalType(this, Types.Object));
            Cache(RegexType = new ExternalType(this, Types.Regex));
            Cache(ValueTypeType = new ExternalType(this, typeof(ValueType)));
            Cache(EnumType = new ExternalType(this, typeof(Enum)));
            Cache(ArrayType = new ExternalType(this, Types.Array));
            Cache(TypeType = new ExternalType(this, Types.Type));
            Cache(StringType = new ExternalType(this, Types.String));
            Cache(BoolType = new ExternalType(this, Types.Bool));
            Cache(SByteType = new ExternalType(this, Types.SByte));
            Cache(CharType = new ExternalType(this, Types.Char));
            Cache(ShortType = new ExternalType(this, Types.Short));
            Cache(IntType = new ExternalType(this, Types.Int));
            Cache(LongType = new ExternalType(this, Types.Long));
            Cache(ByteType = new ExternalType(this, Types.Byte));
            Cache(UShortType = new ExternalType(this, Types.UShort));
            Cache(UIntType = new ExternalType(this, Types.UInt));
            Cache(ULongType = new ExternalType(this, Types.ULong));
            Cache(SingleType = new ExternalType(this, Types.Single));
            Cache(DoubleType = new ExternalType(this, Types.Double));
            Cache(DecimalType = new ExternalType(this, Types.Decimal));
            Cache(TimeSpanType = new ExternalType(this, Types.TimeSpan));
            Cache(DateTimeType = new ExternalType(this, Types.DateTime));
            Cache(RuntimeServicesType = new ExternalType(this, Types.RuntimeServices));
            Cache(BuiltinsType = new ExternalType(this, Types.Builtins));
            Cache(ListType = new ExternalType(this, Types.List));
            Cache(HashType = new ExternalType(this, Types.Hash));
            Cache(ICallableType = new ExternalType(this, Types.ICallable));
            Cache(IEnumerableType = new ExternalType(this, Types.IEnumerable));
            Cache(IEnumeratorType = new ExternalType(this, typeof(IEnumerator)));
            Cache(ICollectionType = new ExternalType(this, Types.ICollection));
            Cache(IListType = new ExternalType(this, Types.IList));
            Cache(IDictionaryType = new ExternalType(this, Types.IDictionary));
            Cache(IntPtrType = new ExternalType(this, Types.IntPtr));
            Cache(UIntPtrType = new ExternalType(this, Types.UIntPtr));
            Cache(MulticastDelegateType = new ExternalType(this, Types.MulticastDelegate));
            Cache(DelegateType = new ExternalType(this, Types.Delegate));
            Cache(SystemAttribute = new ExternalType(this, typeof(System.Attribute)));
            Cache(ConditionalAttribute = new ExternalType(this, typeof(System.Diagnostics.ConditionalAttribute)));
            Cache(IEnumerableGenericType = new ExternalType(this, typeof(System.Collections.Generic.IEnumerable<>)));
            Cache(IEnumeratorGenericType = new ExternalType(this, typeof(System.Collections.Generic.IEnumerator<>)));

            ObjectArrayType = GetArrayType(ObjectType, 1);

            PreparePrimitives();
            PrepareBuiltinFunctions();
        }