示例#1
0
        public bool NodeMatch(CType aPatternNode, CType aTreeNode)
        {
            if (aPatternNode == null && aTreeNode == null)
            {
                return(true);
            }
            if (aPatternNode == null || aTreeNode == null)
            {
                return(false);
            }
            VariableCType variableType = aPatternNode as VariableCType;

            if (variableType != null)
            {
                if (variableType.CType == null)
                {
                    return(true);
                }
                return(NodeMatch(variableType.CType, aTreeNode));
            }
            if (aPatternNode.GetType() != aTreeNode.GetType())
            {
                return(false);
            }
            NamedCType namedPatternType = aPatternNode as NamedCType;
            NamedCType namedTreeType    = aTreeNode as NamedCType;

            if (namedPatternType != null)
            {
                Debug.Assert(namedTreeType != null); // Cannot be null as we already checked they have the same type.
                if (namedPatternType.Name != namedTreeType.Name)
                {
                    return(false);
                }
            }
            ArrayCType arrayPatternType = aPatternNode as ArrayCType;
            ArrayCType arrayTreeType    = aTreeNode as ArrayCType;

            if (arrayPatternType != null)
            {
                Debug.Assert(arrayTreeType != null);
                if (arrayPatternType.Dimension != arrayTreeType.Dimension)
                {
                    return(false);
                }
            }
            if (!aPatternNode.Qualifiers.SetEquals(aTreeNode.Qualifiers))
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        public string Variable(CType aNode)
        {
            VariableCType variableType = aNode as VariableCType;

            return(variableType != null ? variableType.Name : null);
        }