示例#1
0
        public IteratorStateMachine(VariableSlotAllocator slotAllocatorOpt, TypeCompilationState compilationState, MethodSymbol iteratorMethod, int iteratorMethodOrdinal, bool isEnumerable, TypeSymbol elementType)
            : base(slotAllocatorOpt, compilationState, iteratorMethod, iteratorMethodOrdinal)
        {
            this.ElementType = TypeMap.SubstituteType(elementType).TypeSymbol;

            throw new NotImplementedException("TODO");

            var interfaces = ArrayBuilder <NamedTypeSymbol> .GetInstance();

            // TODO: Add proper arguments
            interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.core_Iterable_T_TIterator).Construct(ElementType));

            _interfaces = interfaces.ToImmutableAndFree();

            _constructor = new IteratorConstructor(this);
        }
示例#2
0
            public IteratorClass(MethodSymbol method, bool isEnumerable, TypeSymbol elementType, TypeCompilationState compilationState)
                : base(method, GeneratedNames.MakeIteratorOrAsyncDisplayClassName(method.Name, compilationState.GenerateTempNumber()), TypeKind.Class)
            {
                this.ElementType = TypeMap.SubstituteType(elementType);
                var interfaces = ArrayBuilder <NamedTypeSymbol> .GetInstance();

                if (isEnumerable)
                {
                    interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T).Construct(ElementType));
                    interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_IEnumerable));
                }

                interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerator_T).Construct(ElementType));
                interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_IDisposable));
                interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_IEnumerator));
                this.interfaces = interfaces.ToImmutableAndFree();

                this.constructor = new IteratorConstructor(this);
            }
示例#3
0
        public IteratorStateMachine(VariableSlotAllocator slotAllocatorOpt, TypeCompilationState compilationState, MethodSymbol iteratorMethod, int iteratorMethodOrdinal, bool isEnumerable, TypeWithAnnotations elementType)
            : base(slotAllocatorOpt, compilationState, iteratorMethod, iteratorMethodOrdinal)
        {
            this.ElementType = TypeMap.SubstituteType(elementType);

            var interfaces = ArrayBuilder <NamedTypeSymbol> .GetInstance();

            if (isEnumerable)
            {
                interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T).Construct(ElementType.Type));
                interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_IEnumerable));
            }

            interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerator_T).Construct(ElementType.Type));
            interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_IDisposable));
            interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_IEnumerator));
            _interfaces = interfaces.ToImmutableAndFree();

            _constructor = new IteratorConstructor(this);
        }
 private NamedTypeSymbol GetDefaultBaseType()
 {
     return(ContainingAssembly.GetSpecialType(SpecialType.System_Object));
 }