private void BuildCode(EventSymbol eventSymbol)
        {
            if (eventSymbol.IsAbstract || eventSymbol.DefaultImplementation)
            {
                return;
            }

            ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler);

            eventSymbol.AddImplementation(implBuilder.BuildEventAdd(eventSymbol), /* adder */ true);
            eventSymbol.AddImplementation(implBuilder.BuildEventRemove(eventSymbol), /* adder */ false);

            _implementations.Add(eventSymbol.AdderImplementation);
            _implementations.Add(eventSymbol.RemoverImplementation);

            if (eventSymbol.AnonymousMethods != null)
            {
                foreach (AnonymousMethodSymbol anonymousMethod in eventSymbol.AnonymousMethods)
                {
                    Debug.Assert(anonymousMethod.Implementation != null);

                    _implementations.Add(anonymousMethod.Implementation);
                }
            }
        }
        private void BuildCode(PropertySymbol propertySymbol)
        {
            if (propertySymbol.IsAbstract)
            {
                return;
            }

            ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler);

            propertySymbol.AddImplementation(implBuilder.BuildPropertyGetter(propertySymbol), /* getter */ true);
            _implementations.Add(propertySymbol.GetterImplementation);

            if (propertySymbol.IsReadOnly == false)
            {
                propertySymbol.AddImplementation(implBuilder.BuildPropertySetter(propertySymbol), /* getter */ false);
                _implementations.Add(propertySymbol.SetterImplementation);
            }

            if (propertySymbol.AnonymousMethods != null)
            {
                foreach (AnonymousMethodSymbol anonymousMethod in propertySymbol.AnonymousMethods)
                {
                    Debug.Assert(anonymousMethod.Implementation != null);

                    _implementations.Add(anonymousMethod.Implementation);
                }
            }
        }
        private void BuildCode(FieldSymbol fieldSymbol)
        {
            ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler);

            fieldSymbol.AddImplementation(implBuilder.BuildField(fieldSymbol));

            _implementations.Add(fieldSymbol.Implementation);
        }
        private void BuildCode(MethodSymbol methodSymbol)
        {
            if (methodSymbol.IsAbstract)
            {
                return;
            }

            ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler);

            methodSymbol.AddImplementation(implBuilder.BuildMethod(methodSymbol));

            _implementations.Add(methodSymbol.Implementation);

            if (methodSymbol.AnonymousMethods != null)
            {
                foreach (AnonymousMethodSymbol anonymousMethod in methodSymbol.AnonymousMethods)
                {
                    Debug.Assert(anonymousMethod.Implementation != null);

                    _implementations.Add(anonymousMethod.Implementation);
                }
            }
        }
Exemple #5
0
        private void BuildCode(PropertySymbol propertySymbol)
        {
            if (propertySymbol.IsAbstract) {
                return;
            }

            ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler);

            propertySymbol.AddImplementation(implBuilder.BuildPropertyGetter(propertySymbol), /* getter */ true);
            _implementations.Add(propertySymbol.GetterImplementation);

            if (propertySymbol.IsReadOnly == false) {
                propertySymbol.AddImplementation(implBuilder.BuildPropertySetter(propertySymbol), /* getter */ false);
                _implementations.Add(propertySymbol.SetterImplementation);
            }

            if (propertySymbol.AnonymousMethods != null) {
                foreach (AnonymousMethodSymbol anonymousMethod in propertySymbol.AnonymousMethods) {
                    Debug.Assert(anonymousMethod.Implementation != null);

                    _implementations.Add(anonymousMethod.Implementation);
                }
            }
        }
Exemple #6
0
        private void BuildCode(MethodSymbol methodSymbol)
        {
            if (methodSymbol.IsAbstract) {
                return;
            }

            ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler);
            methodSymbol.AddImplementation(implBuilder.BuildMethod(methodSymbol));

            _implementations.Add(methodSymbol.Implementation);

            if (methodSymbol.AnonymousMethods != null) {
                foreach (AnonymousMethodSymbol anonymousMethod in methodSymbol.AnonymousMethods) {
                    Debug.Assert(anonymousMethod.Implementation != null);

                    _implementations.Add(anonymousMethod.Implementation);
                }
            }
        }
Exemple #7
0
        private void BuildCode(FieldSymbol fieldSymbol)
        {
            ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler);
            fieldSymbol.AddImplementation(implBuilder.BuildField(fieldSymbol));

            _implementations.Add(fieldSymbol.Implementation);
        }
Exemple #8
0
        private void BuildCode(EventSymbol eventSymbol)
        {
            if (eventSymbol.IsAbstract || eventSymbol.DefaultImplementation) {
                return;
            }

            ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler);

            eventSymbol.AddImplementation(implBuilder.BuildEventAdd(eventSymbol), /* adder */ true);
            eventSymbol.AddImplementation(implBuilder.BuildEventRemove(eventSymbol), /* adder */ false);

            _implementations.Add(eventSymbol.AdderImplementation);
            _implementations.Add(eventSymbol.RemoverImplementation);

            if (eventSymbol.AnonymousMethods != null) {
                foreach (AnonymousMethodSymbol anonymousMethod in eventSymbol.AnonymousMethods) {
                    Debug.Assert(anonymousMethod.Implementation != null);

                    _implementations.Add(anonymousMethod.Implementation);
                }
            }
        }
        private Expression ProcessAnonymousMethodNode(AnonymousMethodNode node) {
            TypeSymbol voidType = _symbolSet.ResolveIntrinsicType(IntrinsicType.Void);
            Debug.Assert(voidType != null);

            bool createStaticDelegate = (_memberContext.Visibility & MemberVisibility.Static) != 0;

            AnonymousMethodSymbol methodSymbol =
                new AnonymousMethodSymbol(_memberContext, _symbolTable, voidType, createStaticDelegate);
            methodSymbol.SetParseContext(node);

            if ((node.Parameters != null) && (node.Parameters.Count != 0)) {
                foreach (ParameterNode parameterNode in node.Parameters) {
                    TypeSymbol parameterType = _symbolSet.ResolveType(parameterNode.Type, _symbolTable, _symbolContext);
                    Debug.Assert(parameterType != null);

                    ParameterSymbol paramSymbol =
                        new ParameterSymbol(parameterNode.Name, methodSymbol, parameterType, ParameterMode.In);
                    if (paramSymbol != null) {
                        paramSymbol.SetParseContext(parameterNode);
                        methodSymbol.AddParameter(paramSymbol);
                    }
                }
            }

            ImplementationBuilder implBuilder = new ImplementationBuilder(_options, _errorHandler);
            SymbolImplementation implementation = implBuilder.BuildMethod(methodSymbol);

            methodSymbol.AddImplementation(implementation);

            if ((createStaticDelegate == false) && (implementation.RequiresThisContext == false)) {
                methodSymbol.SetVisibility(methodSymbol.Visibility | MemberVisibility.Static);
                createStaticDelegate = true;
            }

            Expression objectExpression;
            if (createStaticDelegate) {
                TypeSymbol objectType = _symbolSet.ResolveIntrinsicType(IntrinsicType.Object);
                Debug.Assert(objectType != null);

                objectExpression = new LiteralExpression(objectType, null);
            }
            else {
                objectExpression = new ThisExpression(_classContext, /* explicitReference */ true);
            }

            return new DelegateExpression(objectExpression, methodSymbol);
        }