protected Schema.Node FindParent(Schema.Node node) { if (!node.IsValid() || node.id == 0) return default(Node); if (node.scopeId != 0 && node.scopeId != node.id) { var tmp = Lookup(node.scopeId); if (tmp.IsValid()) return tmp; } foreach (var pair in map) { var nested = pair.Value.nestedNodes; if (nested.IsValid()) { foreach (var x in nested) if (x.id == node.id) return pair.Value; } } return default(Node); }
public virtual CodeWriter WriteNode(Schema.Node node, Stack<UnionStub> union) { if (node.IsValid()) { switch (node.Union) { case Schema.Node.Unions.@struct: WriteStruct(node, union); break; case Schema.Node.Unions.@enum: WriteEnum(node); break; case Schema.Node.Unions.@const: WriteConst(node); break; case Schema.Node.Unions.annotation: default: WriteLine().WriteComment(string.Format("Not implemented: {0} ({1}))", node.displayName, node.Union)); break; } } return this; }