private int FindStructsAndAttributes(ParseTreeNode parent, int level) { if (parent == null) { return 0; } if (parent.Term == mLanguage.SingleDeclaration) { var node = parent.ChildNodes[0]; if (node.Term == mLanguage.FullySpecifiedType) { var specifier = node.ChildNodes.Find (p => p.Term == mLanguage.StructSpecifier); var typeQualifier = node.ChildNodes.Find (p => p.Term == mLanguage.TypeQualifier); if (specifier != null) { var temp = new StructInfo (); temp.Layout = new LayoutInformation (); ExtractLayout (temp.Layout, typeQualifier); return ExtractStructMembers (temp, specifier); } var inDirection = typeQualifier.ChildNodes.Find (p => p.Term == mLanguage.InTerm); var outDirection = typeQualifier.ChildNodes.Find (p => p.Term == mLanguage.OutTerm); if (inDirection == null && outDirection == null) { return 0; } var attribute = new InputAttribute (); attribute.Direction = (inDirection != null) ? "in" : ((outDirection != null) ? "out" : null); attribute.Layout = new LayoutInformation (); ExtractLayout (attribute.Layout, typeQualifier); var secondNode = node.ChildNodes [1]; if (!mLanguage.TypesTerms.Contains (secondNode.Token.KeyTerm)) { return 0; } attribute.TypeString = secondNode.Token.ValueString; attribute.ClosestType = mTypeLookup.FindClosestType (attribute.TypeString); var nameSibiling = parent.ChildNodes [1]; attribute.Name = nameSibiling.Token.ValueString; // IGNORE if (!mAttributes.ContainsKey (attribute.Name)) { mAttributes.Add (attribute.Name, attribute); return 1; } else { return 0; } } else { return 0; } } else { int total = 0; foreach (ParseTreeNode child in parent.ChildNodes) { total += FindStructsAndAttributes (child, level + 1); } return total; } }
private int FindStructsAndAttributes(ParseTreeNode parent, int level) { if (parent == null) { return(0); } if (parent.Term == mLanguage.SingleDeclaration) { var node = parent.ChildNodes[0]; if (node.Term == mLanguage.FullySpecifiedType) { var specifier = node.ChildNodes.Find(p => p.Term == mLanguage.StructSpecifier); var typeQualifier = node.ChildNodes.Find(p => p.Term == mLanguage.TypeQualifier); if (specifier != null) { var temp = new StructInfo(); temp.Layout = new LayoutInformation(); ExtractLayout(temp.Layout, typeQualifier); return(ExtractStructMembers(temp, specifier)); } var inDirection = typeQualifier.ChildNodes.Find(p => p.Term == mLanguage.InTerm); var outDirection = typeQualifier.ChildNodes.Find(p => p.Term == mLanguage.OutTerm); if (inDirection == null && outDirection == null) { return(0); } var attribute = new InputAttribute(); attribute.Direction = (inDirection != null) ? "in" : ((outDirection != null) ? "out" : null); attribute.Layout = new LayoutInformation(); ExtractLayout(attribute.Layout, typeQualifier); var secondNode = node.ChildNodes [1]; if (!mLanguage.TypesTerms.Contains(secondNode.Token.KeyTerm)) { return(0); } attribute.TypeString = secondNode.Token.ValueString; attribute.ClosestType = mTypeLookup.FindClosestType(attribute.TypeString); var nameSibiling = parent.ChildNodes [1]; attribute.Name = nameSibiling.Token.ValueString; // IGNORE if (!mAttributes.ContainsKey(attribute.Name)) { mAttributes.Add(attribute.Name, attribute); return(1); } else { return(0); } } else { return(0); } } else { int total = 0; foreach (ParseTreeNode child in parent.ChildNodes) { total += FindStructsAndAttributes(child, level + 1); } return(total); } }