Esempio n. 1
0
 internal static GreenNode TryGetNode(
     int kind,
     GreenNode child1,
     SyntaxFactoryContext context,
     out int hash
     )
 {
     return(SyntaxNodeCache.TryGetNode(kind, child1, GetNodeFlags(context), out hash));
 }
Esempio n. 2
0
        private static GreenNode.NodeFlags GetNodeFlags(SyntaxFactoryContext context)
        {
            var flags = SyntaxNodeCache.GetDefaultNodeFlags();

            if (context.IsInAsync)
            {
                flags |= GreenNode.NodeFlags.FactoryContextIsInAsync;
            }

            if (context.IsInQuery)
            {
                flags |= GreenNode.NodeFlags.FactoryContextIsInQuery;
            }

            return(flags);
        }
Esempio n. 3
0
        internal static WithTwoChildren List(CSharpSyntaxNode child0, CSharpSyntaxNode child1)
        {
            Debug.Assert(child0 != null);
            Debug.Assert(child1 != null);

            int       hash;
            GreenNode cached = SyntaxNodeCache.TryGetNode((short)SyntaxKind.List, child0, child1, out hash);

            if (cached != null)
            {
                return((WithTwoChildren)cached);
            }

            var result = new WithTwoChildren(child0, child1);

            if (hash >= 0)
            {
                SyntaxNodeCache.AddNode(result, hash);
            }

            return(result);
        }