예제 #1
0
        public override void Populate(TextWriter trapFile)
        {
            var typeKey = Type.Create(Context, ConstructedType);

            trapFile.@params(this, Original.symbol.Name, typeKey.TypeRef, 0, Kind.This, Parent, Original);
            trapFile.param_location(this, Original.Location);
        }
예제 #2
0
        public override void Populate(TextWriter trapFile)
        {
            var typeKey = VarargsType.Create(Context);

            // !! Maybe originaldefinition is wrong
            trapFile.@params(this, "", typeKey, Ordinal, Kind.None, Parent, this);
            trapFile.param_location(this, GeneratedLocation.Create(Context));
        }
예제 #3
0
        public override void Populate(TextWriter trapFile)
        {
            PopulateAttributes();
            PopulateNullability(trapFile, Symbol.GetAnnotatedType());
            PopulateRefKind(trapFile, Symbol.RefKind);

            if (Symbol.Name != Original.Symbol.Name)
            {
                Context.ModelError(Symbol, "Inconsistent parameter declaration");
            }

            var type = Type.Create(Context, Symbol.Type);

            trapFile.@params(this, Name, type.TypeRef, Ordinal, ParamKind, Parent !, Original);

            foreach (var l in Symbol.Locations)
            {
                trapFile.param_location(this, Context.CreateLocation(l));
            }

            if (!Symbol.Locations.Any() &&
                Symbol.ContainingSymbol is IMethodSymbol ms &&
                ms.Name == WellKnownMemberNames.TopLevelStatementsEntryPointMethodName &&
                ms.ContainingType.Name == WellKnownMemberNames.TopLevelStatementsEntryPointTypeName)
            {
                trapFile.param_location(this, Context.CreateLocation());
            }

            if (Symbol.HasExplicitDefaultValue && Context.Defines(Symbol))
            {
                var defaultValueSyntax = GetDefaultValueFromSyntax(Symbol);

                Action defaultValueExpressionCreation = defaultValueSyntax is not null
                    ? () => Expression.Create(Context, defaultValueSyntax.Value, this, 0)
                    : () => Expression.CreateGenerated(Context, Symbol, this, 0, Location);

                Context.PopulateLater(defaultValueExpressionCreation);
            }

            if (!IsSourceDeclaration || !Symbol.FromSource())
            {
                return;
            }

            BindComments();

            if (IsSourceDeclaration)
            {
                foreach (var syntax in Symbol.DeclaringSyntaxReferences
                         .Select(d => d.GetSyntax())
                         .OfType <ParameterSyntax>()
                         .Where(s => s.Type is not null))
                {
                    TypeMention.Create(Context, syntax.Type !, this, type);
                }
            }
        }
예제 #4
0
        public override void Populate(TextWriter trapFile)
        {
            PopulateAttributes();
            PopulateNullability(trapFile, symbol.GetAnnotatedType());
            PopulateRefKind(trapFile, symbol.RefKind);

            if (symbol.Name != Original.symbol.Name)
            {
                Context.ModelError(symbol, "Inconsistent parameter declaration");
            }

            var type = Type.Create(Context, symbol.Type);

            trapFile.@params(this, Name, type.TypeRef, Ordinal, ParamKind, Parent, Original);

            foreach (var l in symbol.Locations)
            {
                trapFile.param_location(this, Context.Create(l));
            }

            if (!IsSourceDeclaration || !symbol.FromSource())
            {
                return;
            }

            BindComments();

            if (IsSourceDeclaration)
            {
                foreach (var syntax in symbol.DeclaringSyntaxReferences.
                         Select(d => d.GetSyntax()).
                         OfType <ParameterSyntax>().
                         Where(s => s.Type != null))
                {
                    TypeMention.Create(Context, syntax.Type, this, type);
                }
            }

            if (symbol.HasExplicitDefaultValue && Context.Defines(symbol))
            {
                // This is a slight bug in the dbscheme
                // We should really define param_default(param, string)
                // And use parameter child #0 to encode the default expression.
                var defaultValue = GetParameterDefaultValue(symbol);
                if (defaultValue == null)
                {
                    // In case this parameter belongs to an accessor of an indexer, we need
                    // to get the default value from the corresponding parameter belonging
                    // to the indexer itself
                    var method = (IMethodSymbol)symbol.ContainingSymbol;
                    if (method != null)
                    {
                        var i       = method.Parameters.IndexOf(symbol);
                        var indexer = (IPropertySymbol)method.AssociatedSymbol;
                        if (indexer != null)
                        {
                            defaultValue = GetParameterDefaultValue(indexer.Parameters[i]);
                        }
                    }
                }

                if (defaultValue != null)
                {
                    Context.PopulateLater(() =>
                    {
                        Expression.Create(Context, defaultValue.Value, this, 0);
                    });
                }
            }
        }