Esempio n. 1
0
 public ExpressionInfo(Context cx, AnnotatedType type, Extraction.Entities.Location location, ExprKind kind, IExpressionParentEntity parent, int child, bool isCompilerGenerated, string value)
 {
     Context             = cx;
     Type                = type;
     Location            = location;
     Kind                = kind;
     Parent              = parent;
     Child               = child;
     ExprValue           = value;
     IsCompilerGenerated = isCompilerGenerated;
 }
Esempio n. 2
0
        internal Expression(IExpressionInfo info)
            : base(info.Context)
        {
            Info     = info;
            Location = info.Location;
            Kind     = info.Kind;
            Type     = info.Type;
            if (Type.Type is null)
            {
                Type = NullType.Create(cx);
            }

            TryPopulate();
        }
Esempio n. 3
0
 public ExpressionNodeInfo SetType(AnnotatedType type)
 {
     Type = type;
     return(this);
 }
Esempio n. 4
0
        public override void Populate(TextWriter trapFile)
        {
            PopulateMetadataHandle(trapFile);
            PopulateAttributes();
            PopulateModifiers(trapFile);
            BindComments();
            PopulateNullability(trapFile, symbol.GetAnnotatedType());
            PopulateRefKind(trapFile, symbol.RefKind);

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

            trapFile.properties(this, symbol.GetName(), ContainingType, type.TypeRef, Create(Context, symbol.OriginalDefinition));

            var getter = symbol.GetMethod;
            var setter = symbol.SetMethod;

            if (!(getter is null))
            {
                Method.Create(Context, getter);
            }

            if (!(setter is null))
            {
                Method.Create(Context, setter);
            }

            var declSyntaxReferences = IsSourceDeclaration ?
                                       symbol.DeclaringSyntaxReferences.
                                       Select(d => d.GetSyntax()).OfType <PropertyDeclarationSyntax>().ToArray()
                : Enumerable.Empty <PropertyDeclarationSyntax>();

            foreach (var explicitInterface in symbol.ExplicitInterfaceImplementations.Select(impl => Type.Create(Context, impl.ContainingType)))
            {
                trapFile.explicitly_implements(this, explicitInterface.TypeRef);

                foreach (var syntax in declSyntaxReferences)
                {
                    TypeMention.Create(Context, syntax.ExplicitInterfaceSpecifier.Name, this, explicitInterface);
                }
            }

            foreach (var l in Locations)
            {
                trapFile.property_location(this, l);
            }

            if (IsSourceDeclaration && symbol.FromSource())
            {
                var expressionBody = ExpressionBody;
                if (expressionBody != null)
                {
                    Context.PopulateLater(() => Expression.Create(Context, expressionBody, this, 0));
                }

                int child = 1;
                foreach (var initializer in declSyntaxReferences.
                         Select(n => n.Initializer).
                         Where(i => i != null))
                {
                    Context.PopulateLater(() =>
                    {
                        var loc              = Context.Create(initializer.GetLocation());
                        var annotatedType    = new AnnotatedType(type, TypeAnnotation.None);
                        var simpleAssignExpr = new Expression(new ExpressionInfo(Context, annotatedType, loc, ExprKind.SIMPLE_ASSIGN, this, child++, false, null));
                        Expression.CreateFromNode(new ExpressionNodeInfo(Context, initializer.Value, simpleAssignExpr, 0));
                        var access = new Expression(new ExpressionInfo(Context, annotatedType, Location, ExprKind.PROPERTY_ACCESS, simpleAssignExpr, 1, false, null));
                        trapFile.expr_access(access, this);
                        if (!symbol.IsStatic)
                        {
                            This.CreateImplicit(Context, Type.Create(Context, symbol.ContainingType), Location, access, -1);
                        }
                    });
                }

                foreach (var syntax in declSyntaxReferences)
                {
                    TypeMention.Create(Context, syntax.Type, this, type);
                }
            }
        }
Esempio n. 5
0
 public static TypeMention Create(Context cx, TypeSyntax syntax, IEntity parent, AnnotatedType type, Microsoft.CodeAnalysis.Location loc = null) =>
 Create(cx, syntax, parent, type.Type, loc);