Beispiel #1
0
 public IParameter[] GetParameters()
 {
     if (null == _parameters)
     {
         _parameters = _typeSystemServices.Map(_property.GetIndexParameters());
     }
     return(_parameters);
 }
Beispiel #2
0
        private BooClassBuilder SetUpEnumerableClassBuilder(Node sourceNode, Method enclosingMethod, IType generatorItemType,
                                                            TypeReplacer replacer)
        {
            var builder = CodeBuilder.CreateClass(
                Context.GetUniqueName(enclosingMethod.Name, "Enumerable"),
                TypeMemberModifiers.Internal | TypeMemberModifiers.Final);

            if (enclosingMethod.DeclaringType.IsTransient)
            {
                builder.Modifiers |= TypeMemberModifiers.Transient;
            }

            builder.LexicalInfo = new LexicalInfo(sourceNode.LexicalInfo);
            builder.AddAttribute(CodeBuilder.CreateAttribute(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute)));
            foreach (var gen in enclosingMethod.DeclaringType.GenericParameters.Concat(enclosingMethod.GenericParameters))
            {
                var replacement = builder.AddGenericParameter(gen.Name);
                CopyConstraints(gen, replacement);
                replacer.Replace((IType)gen.Entity, (IType)replacement.Entity);
            }
            generatorItemType = replacer.MapType(generatorItemType);
            builder.AddBaseType(
                TypeSystemServices.Map(typeof(GenericGenerator <>)).GenericInfo.ConstructType(generatorItemType));

            return(builder);
        }
Beispiel #3
0
        void CreateAnonymousGeneratorType()
        {
            _enumerable = (BooClassBuilder)_generator["GeneratorClassBuilder"];

            _enumerator = _collector.CreateSkeletonClass("Enumerator");
            _enumerator.AddBaseType(TypeSystemServices.IEnumeratorType);
            _enumerator.AddBaseType(TypeSystemServices.Map(typeof(ICloneable)));

            _enumeratorField = _enumerator.AddField("____enumerator",
                                                    TypeSystemServices.IEnumeratorType);
            _current = _enumerator.AddField("____current",
                                            TypeSystemServices.ObjectType);

            CreateReset();
            CreateCurrent();
            CreateMoveNext();
            CreateClone();
            EnumeratorConstructorMustCallReset();

            _collector.AdjustReferences();

            _collector.DeclareFieldsAndConstructor(_enumerable);

            CreateGetEnumerator();
            _enumerable.ClassDefinition.Members.Add(_enumerator.ClassDefinition);
        }
Beispiel #4
0
        private Expression InjectCast(Expression exp)
        {
            var method = exp.Entity as IMethod;

            if (method == null)
            {
                return(exp);
            }

            IType castTargetType;
            var   parameters = method.GetParameters();

            if (parameters.Length > 0 || (method.ReturnType != TypeSystemServices.VoidType && method.ReturnType != null))
            {
                var isFunc = method.ReturnType != null && method.ReturnType != TypeSystemServices.VoidType;
                var genericTypeParameters = parameters.Select(p => p.Type).ToList();
                if (isFunc)
                {
                    genericTypeParameters.Add(method.ReturnType);
                }

                castTargetType = new GenericConstructedType(TypeSystemServices.Map(isFunc ? typeof(Func <>) : typeof(Action <>)), genericTypeParameters.ToArray());
            }
            else
            {
                castTargetType = TypeSystemServices.Map(typeof(Action));
            }

            return(CodeBuilder.CreateCast(castTargetType, exp));
        }
        IType FindBestEnumeratorType()
        {
            //type is already an IEnumerator, use it
            if (IsAssignableFrom(TypeSystemServices.IEnumeratorType, CurrentEnumeratorType))
            {
                return(CurrentEnumeratorType);
            }

            IType bestEnumeratorType = null;

            _candidates.Clear();

            //resolution order:
            //1) type contains an applicable GetEnumerator() [whether or not type implements IEnumerator (as C# does)]
            CurrentEnumeratorType.Resolve(_candidates, "GetEnumerator", EntityType.Method);
            foreach (IEntity candidate in _candidates)
            {
                IMethod m = (IMethod)candidate;
                if (null != m.GenericInfo || 0 != m.GetParameters().Length || !m.IsPublic)
                {
                    continue;                     //only check public non-generic GetEnumerator with no argument
                }
                if (!IsAssignableFrom(TypeSystemServices.IEnumeratorGenericType, m.ReturnType) &&
                    !IsAssignableFrom(TypeSystemServices.IEnumeratorType, m.ReturnType))
                {
                    continue;                     //GetEnumerator does not return an IEnumerator or IEnumerator[of T]
                }
                bestEnumeratorType = m.ReturnType;
                _bestGetEnumerator = m;
                break;
            }

            //2) type explicitly implements IEnumerable[of T]
            if (null == bestEnumeratorType)
            {
                if (IsAssignableFrom(TypeSystemServices.IEnumerableGenericType, CurrentEnumeratorType))
                {
                    bestEnumeratorType = TypeSystemServices.IEnumeratorGenericType;
                    _bestGetEnumerator = TypeSystemServices.Map(Types.IEnumerableGeneric.GetMethod("GetEnumerator"));
                }
            }

            //3) type explicitly implements IEnumerable
            if (null == bestEnumeratorType)
            {
                if (IsAssignableFrom(TypeSystemServices.IEnumerableType, CurrentEnumeratorType))
                {
                    bestEnumeratorType = TypeSystemServices.IEnumeratorType;
                    _bestGetEnumerator = TypeSystemServices.Map(Types.IEnumerable.GetMethod("GetEnumerator"));
                }
            }

            //4) error
            if (null == bestEnumeratorType)
            {
                Errors.Add(CompilerErrorFactory.InvalidIteratorType(_iteratorNode, CurrentEnumeratorType));
            }

            return(bestEnumeratorType);
        }
        public override void OnMethodInvocationExpression(MethodInvocationExpression node)
        {
            if (node.Target.Entity != null && node.Target.Entity == TypeSystemServices.ICallableType.GetMembers().Single(m => m.Name == "Call"))
            {
                var mreOriginal = (MemberReferenceExpression)node.Target;
                var newMethod   = TypeSystemServices.Map(typeof(Delegate).GetMethod("DynamicInvoke", BindingFlags.Instance | BindingFlags.Public));
                var newTarget   = new MemberReferenceExpression(mreOriginal.Target, newMethod.Name);
                newTarget.Entity = newMethod;

                node.Replace(node.Target, newTarget);
            }
            else if (node.Target.Entity != null && node.Target.Entity.EntityType == EntityType.Method)
            {
                var parameters = ((IMethodBase)node.Target.Entity).GetParameters();
                var args       = node.Arguments.ToArray();

                for (int i = 0; i < args.Length && i < parameters.Length; i++)
                {
                    if (args[i].ExpressionType != null && TypeSystemServices.IsCallable(args[i].ExpressionType) && !TypeSystemServices.IsCallable(parameters[i].Type))
                    {
                        node.Replace(args[i], InjectCast(args[i]));
                    }
                }
            }

            base.OnMethodInvocationExpression(node);
        }
        private void CreateEnumerator()
        {
            _enumerator = CodeBuilder.CreateClass("$Enumerator");
            _enumerator.AddAttribute(CodeBuilder.CreateAttribute(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute)));
            _enumerator.Modifiers  |= _enumerable.Modifiers;
            _enumerator.LexicalInfo = this.LexicalInfo;
            foreach (var param in _genericParams)
            {
                var replacement = _enumerator.AddGenericParameter(param.Name);
                _methodToEnumeratorMapper.Replace((IType)param.Entity, (IType)replacement.Entity);
            }
            var abstractEnumeratorType =
                TypeSystemServices.Map(typeof(GenericGeneratorEnumerator <>)).
                GenericInfo.ConstructType(_methodToEnumeratorMapper.MapType(_generatorItemType));

            _state        = NameResolutionService.ResolveField(abstractEnumeratorType, "_state");
            _yield        = NameResolutionService.ResolveMethod(abstractEnumeratorType, "Yield");
            _yieldDefault = NameResolutionService.ResolveMethod(abstractEnumeratorType, "YieldDefault");
            _enumerator.AddBaseType(abstractEnumeratorType);
            _enumerator.AddBaseType(TypeSystemServices.IEnumeratorType);

            CreateEnumeratorConstructor();
            CreateMoveNext();

            _enumerable.ClassDefinition.Members.Add(_enumerator.ClassDefinition);
        }
Beispiel #8
0
 protected override void InitializeMemberCache()
 {
     base.InitializeMemberCache();
     getParam      = TypeSystemServices.Map(typeof(BrailBase).GetMethod("GetParameter"));
     tryGetParam   = TypeSystemServices.Map(typeof(BrailBase).GetMethod("TryGetParameter"));
     wrapNullValue = TypeSystemServices.Map(typeof(BrailBase).GetMethod("WrapPossilbeNullValue"));
 }
Beispiel #9
0
        /// <summary>
        /// Perform the actual expansion of the macro
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        protected override Statement DoExpand(MacroStatement macro)
        {
            if (macro.Arguments.Count != 0)
            {
                Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "No arguments allowed for action statement"));
                return(null);
            }

            Method mergeRowsMethod = new Method("MergeRows");

            mergeRowsMethod.Modifiers = TypeMemberModifiers.Override;
            mergeRowsMethod.Parameters.Add(new ParameterDeclaration("left", new SimpleTypeReference(typeof(Row).FullName)));
            mergeRowsMethod.Parameters.Add(new ParameterDeclaration("right", new SimpleTypeReference(typeof(Row).FullName)));
            CodeBuilder.DeclareLocal(mergeRowsMethod, "row", TypeSystemServices.Map(typeof(Row)));
            mergeRowsMethod.Body.Add(
                new BinaryExpression(BinaryOperatorType.Assign,
                                     new ReferenceExpression("row"),
                                     new MethodInvocationExpression(
                                         AstUtil.CreateReferenceExpression(typeof(Row).FullName))
                                     )
                );
            mergeRowsMethod.Body.Add(macro.Body);
            mergeRowsMethod.Body.Add(new ReturnStatement(new ReferenceExpression("row")));

            ParentMethods.Add(mergeRowsMethod);
            return(null);
        }
Beispiel #10
0
        /// <summary>
        /// Gets the member of the specified type with the specified name, assuming there is only one.
        /// </summary>
        private IEntity GetMember(IType type, string name, EntityType entityType)
        {
            // For external types we can use GetMethod or GetProperty to optimize things a little
            ExternalType external = type as ExternalType;

            if (external != null)
            {
                if (entityType == EntityType.Property)
                {
                    return(TypeSystemServices.Map(
                               ((ExternalType)type).ActualType.GetProperty(name)));
                }

                else if (entityType == EntityType.Method)
                {
                    return(TypeSystemServices.Map(
                               ((ExternalType)type).ActualType.GetMethod(name)));
                }
            }

            // For constructed types which aren't external we can use the GenericMapping to
            // (maybe) optimize things a little
            if (type.ConstructedInfo != null)
            {
                return(((GenericConstructedType)type).GenericMapping.Map(
                           GetMember(type.ConstructedInfo.GenericDefinition, name, entityType)));
            }

            // For other cases we just scan through the members collection
            return(Array.Find <IEntity>(
                       type.GetMembers(),
                       delegate(IEntity e) {
                return entityType == e.EntityType && e.Name == name;
            }));
        }
Beispiel #11
0
        void Initialize()
        {
            Type type = typeof(AsyncResult);

            _asyncResultType = TypeSystemServices.Map(type);
            _asyncResultTypeAsyncDelegateGetter = TypeSystemServices.Map(Methods.GetterOf <AsyncResult, object>(r => r.AsyncDelegate));
            _adaptors = new Boo.Lang.List();
        }
Beispiel #12
0
        void Initialize()
        {
            Type type = typeof(System.Runtime.Remoting.Messaging.AsyncResult);

            _asyncResultType = TypeSystemServices.Map(type);
            _asyncResultTypeAsyncDelegateGetter = TypeSystemServices.Map(type.GetProperty("AsyncDelegate").GetGetMethod());
            _adaptors = new Boo.Lang.List();
        }
Beispiel #13
0
 private void InitializeDelegateMethods()
 {
     if (null != _delegate_Combine)
     {
         return;
     }
     _delegate_Combine = TypeSystemServices.Map(Methods.Of <Delegate, Delegate, Delegate>(Delegate.Combine));
     _delegate_Remove  = TypeSystemServices.Map(Methods.Of <Delegate, Delegate, Delegate>(Delegate.Remove));
 }
 public void ImplicitConversionFromNullableToValue()
 {
     RunInCompilerContextEnvironment(delegate
     {
         var nullableDouble     = TypeSystemServices.Map(typeof(double?));
         var doubleType         = TypeSystemServices.Map(typeof(double));
         var conversionOperator = TypeSystemServices.FindExplicitConversionOperator(nullableDouble, doubleType);
         Assert.IsNotNull(conversionOperator);
     });
 }
Beispiel #15
0
        void CreateReset()
        {
            BooMethodBuilder method = _enumerator.AddVirtualMethod("Reset", TypeSystemServices.VoidType);

            method.Body.Add(
                CodeBuilder.CreateAssignment(
                    CodeBuilder.CreateReference((InternalField)_enumeratorField.Entity),
                    CodeBuilder.CreateMethodInvocation(_generator.Iterator,
                                                       TypeSystemServices.Map(Types.IEnumerable.GetMethod("GetEnumerator")))));
        }
Beispiel #16
0
        public void TypeOfFirstArgumentRule()
        {
            RunInCompilerContextEnvironment(() =>
            {
                var type       = TypeSystemServices.Map(typeof(string));
                var method     = TypeSystemServices.Map(Methods.Of <object, object>(Instantiate));
                var invocation = CodeBuilder.CreateMethodInvocation(method, StringLiteral());

                Assert.AreSame(type, Subject.ApplyTo(invocation, method));
            });
        }
Beispiel #17
0
        public void TypeReferencedBySecondArgumentRule()
        {
            RunInCompilerContextEnvironment(() =>
            {
                var type       = TypeSystemServices.Map(typeof(string));
                var method     = TypeSystemServices.Map(Methods.Of <string, Type, object>(Load));
                var invocation = CodeBuilder.CreateMethodInvocation(method, StringLiteral(), TypeReference(type));

                Assert.AreSame(type, Subject.ApplyTo(invocation, method));
            });
        }
Beispiel #18
0
        void CreateAnonymousGeneratorType()
        {
            _enumerable = (BooClassBuilder)_generator["GeneratorClassBuilder"];

            _sourceItemType       = TypeSystemServices.ObjectType;
            _sourceEnumeratorType = TypeSystemServices.IEnumeratorType;
            _sourceEnumerableType = TypeSystemServices.IEnumerableType;

            _resultItemType       = (IType)_generator["GeneratorItemType"];
            _resultEnumeratorType = TypeSystemServices.IEnumeratorType;

            //_enumerator = _collector.CreateSkeletonClass(_enumerable.ClassDefinition.Name + "Enumerator");
            _enumerator = _collector.CreateSkeletonClass("Enumerator");

#if NET_2_0
            // If source item type isn't object, use a generic enumerator for the source type
            _sourceItemType = TypeSystemServices.GetGenericEnumerableItemType(_generator.Iterator.ExpressionType);

            if (_sourceItemType != null && _sourceItemType != TypeSystemServices.ObjectType)
            {
                _sourceEnumerableType = TypeSystemServices.IEnumerableGenericType.GenericTypeDefinitionInfo.MakeGenericType(_sourceItemType);
                _sourceEnumeratorType = TypeSystemServices.IEnumeratorGenericType.GenericTypeDefinitionInfo.MakeGenericType(_sourceItemType);
            }
            else
            {
                _sourceItemType = TypeSystemServices.ObjectType;
            }

            // Expose a generic enumerator
            _resultEnumeratorType = TypeSystemServices.IEnumeratorGenericType.GenericTypeDefinitionInfo.MakeGenericType(_resultItemType);
#endif

            _enumerator.AddBaseType(_resultEnumeratorType);
            _enumerator.AddBaseType(TypeSystemServices.Map(typeof(ICloneable)));
            _enumerator.AddBaseType(TypeSystemServices.Map(typeof(IDisposable)));

            _enumeratorField = _enumerator.AddField("____enumerator", _sourceEnumeratorType);
            _current         = _enumerator.AddField("____current", _resultItemType);

            CreateReset();
            CreateCurrent();
            CreateMoveNext();
            CreateClone();
            CreateDispose();
            EnumeratorConstructorMustCallReset();

            _collector.AdjustReferences();

            _collector.DeclareFieldsAndConstructor(_enumerable);

            CreateGetEnumerator();
            _enumerable.ClassDefinition.Members.Add(_enumerator.ClassDefinition);
            //TypeSystemServices.AddCompilerGeneratedType(_enumerator.ClassDefinition);
        }
Beispiel #19
0
        private void CreateDispose()
        {
            BooMethodBuilder dispose = _enumerator.AddVirtualMethod("Dispose", TypeSystemServices.VoidType);

            if (TypeSystemServices.Map(typeof(IDisposable)).IsAssignableFrom(_sourceEnumeratorType))
            {
                dispose.Body.Add(CodeBuilder.CreateMethodInvocation(
                                     CodeBuilder.CreateReference(_enumeratorField),
                                     typeof(IDisposable).GetMethod("Dispose")));
            }
        }
Beispiel #20
0
        protected override void InitializeDuckTypingServices()
        {
            base.InitializeDuckTypingServices();
            var duckTypingServices = TypeSystemServices.Map(GetType());

            RuntimeServices_Invoke      = GetResolvedMethod(duckTypingServices, "Invoke");
            RuntimeServices_SetProperty = GetResolvedMethod(duckTypingServices, "SetProperty");
            RuntimeServices_GetProperty = GetResolvedMethod(duckTypingServices, "GetProperty");
            RuntimeServices_SetSlice    = GetResolvedMethod(duckTypingServices, "SetSlice");
            RuntimeServices_GetSlice    = GetResolvedMethod(duckTypingServices, "GetSlice");
        }
 public override void Initialize(CompilerContext context)
 {
     base.Initialize(context);
     _runtimeServices                     = TypeSystemServices.Map(typeof(Boo.Lang.Runtime.RuntimeServices));
     RuntimeServices_Invoke               = ResolveMethod(_runtimeServices, "Invoke");
     RuntimeServices_InvokeCallable       = ResolveMethod(_runtimeServices, "InvokeCallable");
     RuntimeServices_InvokeBinaryOperator = ResolveMethod(_runtimeServices, "InvokeBinaryOperator");
     RuntimeServices_InvokeUnaryOperator  = ResolveMethod(_runtimeServices, "InvokeUnaryOperator");
     RuntimeServices_SetProperty          = ResolveMethod(_runtimeServices, "SetProperty");
     RuntimeServices_GetProperty          = ResolveMethod(_runtimeServices, "GetProperty");
     RuntimeServices_GetSlice             = ResolveMethod(_runtimeServices, "GetSlice");
 }
        IMethod GetMemberwiseCloneMethod()
        {
#if DNXCORE50
            return(TypeSystemServices.Map(
                       typeof(object).GetTypeInfo().GetMethod("MemberwiseClone",
                                                              System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)));
#else
            return(TypeSystemServices.Map(
                       typeof(object).GetMethod("MemberwiseClone",
                                                System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)));
#endif
        }
Beispiel #23
0
        public void DeclaringTypeOfConstructedMethod()
        {
            RunInCompilerContextEnvironment(() =>
            {
                var genericType  = TypeSystemServices.Map(typeof(IEnumerable <>));
                var internalType = BuildInternalClass("", "Bar").Entity;

                var constructedType = genericType.GenericInfo.ConstructType(internalType);
                var firstMethod     = constructedType.GetMembers().OfType <IMethod>().First();
                Assert.AreSame(constructedType, firstMethod.DeclaringType);
            });
        }
        void InitializeAsyncResultType()
        {
            if (_asyncResultType != null)
            {
                return;
            }

            var type = typeof(AsyncResult);

            _asyncResultType = TypeSystemServices.Map(type);
            _asyncResultTypeAsyncDelegateGetter = TypeSystemServices.Map(Methods.GetterOf <AsyncResult, object>(r => r.AsyncDelegate));
        }
Beispiel #25
0
        void InitializeDelegateMethods()
        {
            if (null != _delegate_Combine)
            {
                return;
            }
            Type delegateType = Types.Delegate;

            Type[] delegates = new Type[] { delegateType, delegateType };
            _delegate_Combine = TypeSystemServices.Map(delegateType.GetMethod("Combine", delegates));
            _delegate_Remove  = TypeSystemServices.Map(delegateType.GetMethod("Remove", delegates));
        }
        void ExpandComplexArraySlicing(SlicingExpression node)
        {
            if (node.Indices.Count > 1)
            {
                MethodInvocationExpression mie = null;
                var computeEnd = new ArrayLiteralExpression();
                var collapse   = new ArrayLiteralExpression();
                var ranges     = new ArrayLiteralExpression();
                for (int i = 0; i < node.Indices.Count; i++)
                {
                    ranges.Items.Add(node.Indices[i].Begin);
                    if (node.Indices[i].End == null)
                    {
                        var end = new BinaryExpression(BinaryOperatorType.Addition, node.Indices[i].Begin, new IntegerLiteralExpression(1));
                        ranges.Items.Add(end);
                        BindExpressionType(end, GetExpressionType(node.Indices[i].Begin));
                        computeEnd.Items.Add(new BoolLiteralExpression(false));
                        collapse.Items.Add(new BoolLiteralExpression(true));
                    }
                    else if (node.Indices[i].End == OmittedExpression.Default)
                    {
                        var end = new IntegerLiteralExpression(0);
                        ranges.Items.Add(end);
                        BindExpressionType(end, GetExpressionType(node.Indices[i].Begin));
                        computeEnd.Items.Add(new BoolLiteralExpression(true));
                        collapse.Items.Add(new BoolLiteralExpression(false));
                    }
                    else
                    {
                        ranges.Items.Add(node.Indices[i].End);
                        computeEnd.Items.Add(new BoolLiteralExpression(false));
                        collapse.Items.Add(new BoolLiteralExpression(false));
                    }
                }
                mie = CodeBuilder.CreateMethodInvocation(MethodCache.RuntimeServices_GetMultiDimensionalRange1, node.Target, ranges);
                mie.Arguments.Add(computeEnd);
                mie.Arguments.Add(collapse);

                BindExpressionType(ranges, TypeSystemServices.Map(typeof(int[])));
                BindExpressionType(computeEnd, TypeSystemServices.Map(typeof(bool[])));
                BindExpressionType(collapse, TypeSystemServices.Map(typeof(bool[])));
                node.ParentNode.Replace(node, mie);
            }
            else
            {
                var slice = node.Indices[0];
                var mie   = IsNullOrOmitted(slice.End)
                                        ? CodeBuilder.CreateMethodInvocation(MethodCache.RuntimeServices_GetRange1, node.Target, slice.Begin)
                                        : CodeBuilder.CreateMethodInvocation(MethodCache.RuntimeServices_GetRange2, node.Target, slice.Begin, slice.End);
                node.ParentNode.Replace(node, mie);
            }
        }
Beispiel #27
0
        protected override void SetupStateMachine()
        {
            _stateMachineClass.Modifiers |= _enumerable.Modifiers;
            var abstractEnumeratorType =
                TypeSystemServices.Map(typeof(GenericGeneratorEnumerator <>)).
                GenericInfo.ConstructType(_methodToStateMachineMapper.MapType(_generatorItemType));

            _state        = NameResolutionService.ResolveField(abstractEnumeratorType, "_state");
            _yield        = NameResolutionService.ResolveMethod(abstractEnumeratorType, "Yield");
            _yieldDefault = NameResolutionService.ResolveMethod(abstractEnumeratorType, "YieldDefault");
            _stateMachineClass.AddBaseType(abstractEnumeratorType);
            _stateMachineClass.AddBaseType(TypeSystemServices.IEnumeratorType);
        }
Beispiel #28
0
        Method CreateBeginInvokeMethod(ICallableType anonymousType)
        {
            Method method = CodeBuilder.CreateRuntimeMethod("BeginInvoke", TypeSystemServices.Map(typeof(IAsyncResult)),
                                                            anonymousType.GetSignature().Parameters, false);

            int delta = method.Parameters.Count;

            method.Parameters.Add(
                CodeBuilder.CreateParameterDeclaration(delta + 1, "callback", TypeSystemServices.Map(typeof(AsyncCallback))));
            method.Parameters.Add(
                CodeBuilder.CreateParameterDeclaration(delta + 1, "asyncState", TypeSystemServices.ObjectType));
            return(method);
        }
Beispiel #29
0
        override public void OnListLiteralExpression(ListLiteralExpression node)
        {
            bool generator = AstUtil.IsListGenerator(node);

            Visit(node.Items);
            if (generator)
            {
                ReplaceCurrentNode(
                    CodeBuilder.CreateConstructorInvocation(
                        TypeSystemServices.Map(List_IEnumerableConstructor),
                        node.Items[0]));
            }
        }
Beispiel #30
0
        public void CreateTypeofExpression()
        {
            RunInCompilerContextEnvironment(() =>
            {
                var type = TypeSystemServices.Map(typeof(string));

                var e = CodeBuilder.CreateTypeofExpression(type);
                Assert.IsNull(e.Entity);
                Assert.AreSame(TypeSystemServices.Map(typeof(Type)), e.ExpressionType);

                Assert.AreSame(type, e.Type.Entity);
            });
        }