BoundDagTemp.cs 1.4 KB
Newer Older
N
Neal Gafter 已提交
1 2
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

N
Neal Gafter 已提交
3
using Microsoft.CodeAnalysis.CSharp.Symbols;
N
Neal Gafter 已提交
4 5 6 7 8 9
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CSharp
{
    partial class BoundDagTemp
    {
10 11 12
        /// <summary>
        /// Does this dag temp represent the original input of the pattern-matching operation?
        /// </summary>
N
Neal Gafter 已提交
13
        public bool IsOriginalInput => this.Source is null;
14

N
Neal Gafter 已提交
15 16
        public static BoundDagTemp ForOriginalInput(SyntaxNode syntax, TypeSymbol type) => new BoundDagTemp(syntax, type, null, 0);

N
Neal Gafter 已提交
17 18 19 20 21 22 23
        public override bool Equals(object obj) => obj is BoundDagTemp other && this.Equals(other);
        public bool Equals(BoundDagTemp other)
        {
            return other != (object)null && this.Type == other.Type && object.Equals(this.Source, other.Source) && this.Index == other.Index;
        }
        public override int GetHashCode()
        {
N
Neal Gafter 已提交
24
            return Hash.Combine(this.Type.GetHashCode(), Hash.Combine(this.Source?.GetHashCode() ?? 0, this.Index));
N
Neal Gafter 已提交
25 26 27 28 29 30 31 32 33 34 35
        }
        public static bool operator ==(BoundDagTemp left, BoundDagTemp right)
        {
            return left.Equals(right);
        }
        public static bool operator !=(BoundDagTemp left, BoundDagTemp right)
        {
            return !left.Equals(right);
        }
    }
}