(indent int, tv scode.Bytes, isComponentType bool)
| 191 | } |
| 192 | |
| 193 | func (f *Formatter) formatTypeValue(indent int, tv scode.Bytes, isComponentType bool) scode.Bytes { |
| 194 | n, tv := super.DecodeLength(tv) |
| 195 | if tv == nil { |
| 196 | f.truncTypeValueErr() |
| 197 | return nil |
| 198 | } |
| 199 | switch n { |
| 200 | default: |
| 201 | typ, err := super.LookupPrimitiveByID(n) |
| 202 | if err != nil { |
| 203 | f.buildf("<ERR bad type ID in type value: %s>", err) |
| 204 | return nil |
| 205 | } |
| 206 | |
| 207 | f.startColor(color.Gray(160)) |
| 208 | f.build(super.PrimitiveName(typ)) |
| 209 | f.endColor() |
| 210 | case super.TypeValueNameDef: |
| 211 | var name string |
| 212 | name, tv = super.DecodeName(tv) |
| 213 | if tv == nil { |
| 214 | f.truncTypeValueErr() |
| 215 | return nil |
| 216 | } |
| 217 | if isComponentType { |
| 218 | f.build("(") |
| 219 | } |
| 220 | f.build(QuotedName(name)) |
| 221 | f.build("=") |
| 222 | tv = f.formatTypeValue(indent, tv, false) |
| 223 | if isComponentType { |
| 224 | f.build(")") |
| 225 | } |
| 226 | case super.TypeValueNameRef: |
| 227 | var name string |
| 228 | name, tv = super.DecodeName(tv) |
| 229 | if tv == nil { |
| 230 | f.truncTypeValueErr() |
| 231 | return nil |
| 232 | } |
| 233 | f.build(QuotedName(name)) |
| 234 | case super.TypeValueRecord: |
| 235 | f.build("{") |
| 236 | var n int |
| 237 | n, tv = super.DecodeLength(tv) |
| 238 | if tv == nil { |
| 239 | f.truncTypeValueErr() |
| 240 | return nil |
| 241 | } |
| 242 | if n == 0 { |
| 243 | f.build("}") |
| 244 | return tv |
| 245 | } |
| 246 | sep := f.newline |
| 247 | indent += f.tab |
| 248 | optlen := (n + 7) >> 3 |
| 249 | if optlen > len(tv) { |
| 250 | f.truncTypeValueErr() |
no test coverage detected