| 127 | } |
| 128 | |
| 129 | func (f *FieldNameIter) Next() []byte { |
| 130 | // Step into non-empty records. |
| 131 | for { |
| 132 | info := &f.stack[len(f.stack)-1] |
| 133 | field := info.fields[info.offset] |
| 134 | f.buf = append(f.buf, "."+field.Name...) |
| 135 | t, ok := super.TypeUnder(field.Type).(*super.TypeRecord) |
| 136 | if !ok || len(t.Fields) == 0 { |
| 137 | break |
| 138 | } |
| 139 | f.stack = append(f.stack, fieldNameIterInfo{t.Fields, 0}) |
| 140 | } |
| 141 | // Skip leading dot. |
| 142 | name := f.buf[1:] |
| 143 | // Advance our position and step out of records. |
| 144 | for len(f.stack) > 0 { |
| 145 | info := &f.stack[len(f.stack)-1] |
| 146 | field := info.fields[info.offset] |
| 147 | f.buf = f.buf[:len(f.buf)-len(field.Name)-1] |
| 148 | info.offset++ |
| 149 | if info.offset < len(info.fields) { |
| 150 | break |
| 151 | } |
| 152 | f.stack = f.stack[:len(f.stack)-1] |
| 153 | } |
| 154 | return name |
| 155 | } |