コード例 #1
0
        public PortableLambdaType(PortableLambdaTypeBuilder builder) : base(builder.Name)
        {
            LambdaKind          = builder.LambdaKind;
            Parameters          = builder.Parameters;
            ReturnType          = builder.ReturnType;
            ReturnsValue        = builder.ReturnsValue;
            ParameterTypesKnown = builder.ParameterTypesKnown;

            Attributes.ContainsGenerics = (Parameters?.Any(p => p.Attributes.ContainsGenerics) ?? false) || (ReturnsValue && ReturnType.Attributes.ContainsGenerics);

            // Make the lambda assignable if the LambdaKind is compatible.
            if (LambdaKind == LambdaKind.Portable)
            {
                Operations.AddAssignmentOperator();
            }

            // Set Generics.
            IEnumerable <CodeType> generics = Enumerable.Empty <CodeType>();

            if (Parameters != null)
            {
                generics = generics.Concat(Parameters);
            }
            if (ReturnType != null)
            {
                generics = generics.Append(ReturnType);
            }
            Generics = generics.ToArray();

            // Add the invoke function.
            AddInvokeFunction();
        }
コード例 #2
0
        public StructInstance(IStructProvider provider, InstanceAnonymousTypeLinker typeLinker) : base(provider.Name)
        {
            ObjectScope = new Scope("struct " + Name);
            StaticScope = new Scope("struct " + Name);

            Generics      = typeLinker.SafeTypeArgsFromAnonymousTypes(provider.GenericTypes);
            Attributes    = new StructAttributes(this);
            TypeSemantics = new StructSemantics(this);
            _provider     = provider;
            _typeLinker   = typeLinker;
            ArrayHandler  = this;

            Operations.AddAssignmentOperator();
        }