Exemplo n.º 1
0
 public virtual ImmutableArray <UsingDirective> GetUsingDirectives(LanguageSyntaxNode declarationSyntax)
 {
     return(ImmutableArray <UsingDirective> .Empty);
 }
 protected virtual BoundNode CreateBoundProperty(BoundTree boundTree, ImmutableArray <object> childBoundNodes, string name, LanguageSyntaxNode syntax = null, bool hasErrors = false)
 {
     return(this.CreateBoundPropertyCore(boundTree, childBoundNodes, name, default, SymbolPropertyOwner.CurrentSymbol, null, syntax, hasErrors));
Exemplo n.º 3
0
 public CustomBinder(Binder next, LanguageSyntaxNode syntax)
     : base(next)
 {
     _syntax = syntax;
 }
Exemplo n.º 4
0
 public BoundRoot(BoundKind kind, BoundTree boundTree, ImmutableArray <object> childBoundNodes, LanguageSyntaxNode syntax, bool hasErrors = false)
     : base(kind, boundTree, childBoundNodes, syntax, hasErrors)
 {
 }
 protected virtual BoundNode CreateBoundSymbolUseCore(BoundTree boundTree, ImmutableArray <object> childBoundNodes, ImmutableArray <Type> types, ImmutableArray <Type> nestingTypes, LanguageSyntaxNode syntax, bool hasErrors)
 {
     return(new BoundSymbolUse(BoundKind.SymbolUse, boundTree, childBoundNodes, types, nestingTypes, syntax, hasErrors));
 }
Exemplo n.º 6
0
 protected BoundStatement(BoundKind kind, BoundTree boundTree, ImmutableArray <object> childBoundNodes, IOperation statement, LanguageSyntaxNode syntax, bool hasErrors = false)
     : base(kind, boundTree, childBoundNodes, syntax, hasErrors)
 {
     _statement = statement;
 }
Exemplo n.º 7
0
 public BoundAttribute(BoundKind kind, BoundTree boundTree, ImmutableArray <object> childBoundNodes, ImmutableArray <Type> types, ImmutableArray <Type> nestingTypes, LanguageSyntaxNode syntax, bool hasErrors = false)
     : base(kind, boundTree, childBoundNodes, types, nestingTypes, syntax, hasErrors)
 {
 }
 protected virtual BoundNode CreateBoundSymbolDef(BoundTree boundTree, ImmutableArray <object> childBoundNodes, Type type, string nestingProperty = null, bool merge = false, LanguageSyntaxNode syntax = null, bool hasErrors = false)
 {
     return(this.CreateBoundSymbolDefCore(boundTree, childBoundNodes, type, syntax, hasErrors));
 }
Exemplo n.º 9
0
 public MemberBoundTree(LanguageCompilation compilation, LanguageSyntaxNode root, Binder rootBinder, DiagnosticBag diagnostics)
     : base(compilation, (LanguageSyntaxTree)root.SyntaxTree, rootBinder, diagnostics)
 {
     _parent = null;
     _root   = root;
 }
Exemplo n.º 10
0
        public override bool TryGetBinder(LanguageSyntaxNode node, object usage, out Binder binder)
        {
            var key = new BinderCacheKey(node, usage);

            return(_binderCache.TryGetValue(key, out binder));
        }
Exemplo n.º 11
0
 public MemberBoundTree(BoundTree parent, LanguageSyntaxNode root, Binder rootBinder)
     : base(parent.Compilation, parent.SyntaxTree, rootBinder, parent.DiagnosticBag)
 {
     _parent = parent;
     _root   = root;
 }
Exemplo n.º 12
0
 public AttributeBinder(Binder next, LanguageSyntaxNode syntax, ImmutableArray <Type> types, ImmutableArray <Type> nestingTypes)
     : base(next, syntax, types, nestingTypes)
 {
 }
Exemplo n.º 13
0
 public BoundOpposite(MetaBoundKind kind, BoundTree boundTree, ImmutableArray <object> childBoundNodes, LanguageSyntaxNode syntax, bool hasErrors)
     : base(kind, boundTree, childBoundNodes, syntax, hasErrors)
 {
 }
 protected virtual BoundNode CreateBoundRoot(BoundTree boundTree, ImmutableArray <object> childBoundNodes, LanguageSyntaxNode syntax, bool hasErrors)
 {
     return(this.CreateBoundRootCore(boundTree, childBoundNodes, syntax, hasErrors));
 }
Exemplo n.º 15
0
        private ImmutableArray <BoundNode> GetBoundNodesFromMap(LanguageSyntaxNode node)
        {
            ImmutableArray <BoundNode> result;

            return(_map.TryGetValue(node, out result) ? result : default(ImmutableArray <BoundNode>));
        }
 protected virtual BoundNode CreateBoundScopeCore(BoundTree boundTree, ImmutableArray <object> childBoundNodes, LanguageSyntaxNode syntax, bool hasErrors)
 {
     return(new BoundScope(BoundKind.Scope, boundTree, childBoundNodes, syntax, hasErrors));
 }
Exemplo n.º 17
0
 /// <summary>
 /// This overload exists for callers who already have a node in hand
 /// and don't want to search through the tree.
 /// </summary>
 internal Binder GetEnclosingBinderInternal(LanguageSyntaxNode node, int position)
 {
     AssertPositionAdjusted(position);
     return(GetEnclosingBinderWithinRoot(node, position));
 }
 protected virtual BoundNode CreateBoundSymbolDefCore(BoundTree boundTree, ImmutableArray <object> childBoundNodes, Type type, LanguageSyntaxNode syntax, bool hasErrors)
 {
     return(new BoundSymbolDef(BoundKind.SymbolDef, boundTree, childBoundNodes, type, syntax, hasErrors));
 }
Exemplo n.º 19
0
        /// <summary>
        /// Get all bounds nodes associated with a node, ordered from highest to lowest in the bound tree.
        /// Strictly speaking, the order is that of a pre-order traversal of the bound tree.
        /// </summary>
        public ImmutableArray <BoundNode> GetBoundNodes(LanguageSyntaxNode node)
        {
            // If this method is called with a null parameter, that implies that the Root should be
            // bound, but make sure that the Root is bindable.
            if (node == null)
            {
                node = GetBindableSyntaxNode(Root);
            }
            //Debug.Assert(node == GetBindableSyntaxNode(node));

            // We have one SemanticModel for each method.
            //
            // The SemanticModel contains a lazily-built immutable map from scope-introducing
            // syntactic statements (such as blocks) to binders, but not from lambdas to binders.
            //
            // The SemanticModel also contains a mutable map from syntax to bound nodes; that is
            // declared here. Since the map is not thread-safe we ensure that it is guarded with a
            // reader-writer lock.
            //
            // Have we already got the desired bound node in the mutable map? If so, return it.
            ImmutableArray <BoundNode> results = GetBoundNodesFromMap(node);

            if (!results.IsDefaultOrEmpty)
            {
                return(results);
            }

            // We might not actually have been given an expression or statement even though we were
            // allegedly given something that is "bindable".

            // If we didn't find in the cached bound nodes, find a binding root and bind it.
            // This will cache bound nodes under the binding root.
            LanguageSyntaxNode nodeToBind = GetBindingRoot(node);
            var nodeBinder = GetEnclosingBinder(GetAdjustedNodePosition(nodeToBind));

            BoundNode boundNode = nodeBinder.CreateBoundNodeForBoundTree(nodeToBind, this);

            results = AddBoundTreeAndGetBoundNodeFromMap(node, boundNode);

            if (!results.IsDefaultOrEmpty)
            {
                return(results);
            }

            // If we still didn't find it, its still possible we could bind it directly.
            // For example, types are usually not represented by bound nodes, and some error conditions and
            // not yet implemented features do not create bound nodes for everything underneath them.
            //
            // In this case, however, we only add the single bound node we found to the map, not any child bound nodes,
            // to avoid duplicates in the map if a parent of this node comes through this code path also.

            var binder = GetEnclosingBinder(GetAdjustedNodePosition(node));

            results = GetBoundNodesFromMap(node);

            if (!results.IsDefaultOrEmpty)
            {
                return(results);
            }

            /*else
             * {
             *  var directlyBoundNode = binder.CreateBoundNodeForBoundTree(node, this);
             *  AddBoundTreeForStandaloneSyntax(node, directlyBoundNode);
             *  results = GetBoundNodesFromMap(node);
             *
             *  if (!results.IsDefaultOrEmpty)
             *  {
             *      return results;
             *  }
             * }*/

            return(ImmutableArray <BoundNode> .Empty);
        }
 protected virtual BoundNode CreateBoundAttribute(BoundTree boundTree, ImmutableArray <object> childBoundNodes, ImmutableArray <Type> types, LanguageSyntaxNode syntax, bool hasErrors)
 {
     return(this.CreateBoundAttributeCore(boundTree, childBoundNodes, types, ImmutableArray <Type> .Empty, syntax, hasErrors));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Gets the containing expression that is actually a language expression (or something that
 /// GetSymbolInfo can be applied to) and not just typed
 /// as an ExpressionSyntax for convenience. For example, NameSyntax nodes on the right side
 /// of qualified names and member access expressions are not language expressions, yet the
 /// containing qualified names or member access expressions are indeed expressions.
 /// Similarly, if the input node is a cref part that is not independently meaningful, then
 /// the result will be the full cref. Besides an expression, an input that is a NameSyntax
 /// of a SubpatternSyntax, e.g. in `name: 3` may cause this method to return the enclosing
 /// SubpatternSyntax.
 /// </summary>
 public virtual LanguageSyntaxNode GetStandaloneNode(LanguageSyntaxNode node)
 {
     return(node);
 }
Exemplo n.º 22
0
 public BoundSelectedEndPoint(BoundKind kind, BoundTree boundTree, ImmutableArray <object> childBoundNodes, LanguageSyntaxNode syntax, bool hasErrors)
     : base(kind, boundTree, childBoundNodes, syntax, hasErrors)
 {
 }
Exemplo n.º 23
0
 public BoundProperty(BoundKind kind, BoundTree boundTree, ImmutableArray <object> childBoundNodes, string name, Optional <object> valueOpt, SymbolPropertyOwner owner, Type ownerType, LanguageSyntaxNode syntax, bool hasErrors = false)
     : base(kind, boundTree, childBoundNodes, syntax, hasErrors)
 {
     _name          = name;
     _hasFixedValue = valueOpt.HasValue;
     _value         = valueOpt.HasValue ? valueOpt.Value : default;
     _owner         = owner;
     _ownerType     = ownerType;
 }
Exemplo n.º 24
0
 protected BoundExpression(BoundKind kind, BoundTree boundTree, ImmutableArray <object> childBoundNodes, IOperation expression, LanguageSyntaxNode syntax, bool hasErrors = false)
     : base(kind, boundTree, childBoundNodes, syntax, hasErrors)
 {
     _expression = expression;
 }
Exemplo n.º 25
0
 // WARNING: Only use this if the node is obtainable without allocating it (even if cached later). E.g., only
 // if the node is stored in the constructor of the symbol. In particular, do not call this on the result of a GetSyntax()
 // call on a SyntaxReference.
 public LexicalSortKey(LanguageSyntaxNode node, LanguageCompilation compilation)
     : this((LanguageSyntaxTree)node.SyntaxTree, node.SpanStart, compilation)
 {
 }
Exemplo n.º 26
0
 public SelectedEndPointBinder(Binder next, LanguageSyntaxNode syntax)
     : base(next)
 {
 }
Exemplo n.º 27
0
 public virtual ImmutableArray <ExternAliasDirective> GetExternAliasDirectives(LanguageSyntaxNode declarationSyntax)
 {
     return(ImmutableArray <ExternAliasDirective> .Empty);
 }