(val super.Value, length uint32)
| 72 | } |
| 73 | |
| 74 | func NewConstFromValue(val super.Value, length uint32) *Const { |
| 75 | switch id := val.Type().ID(); { |
| 76 | case super.IsUnsigned(id): |
| 77 | return NewConstUint(val.Type(), val.Uint(), length) |
| 78 | case super.IsSigned(id): |
| 79 | return NewConstInt(val.Type(), val.Int(), length) |
| 80 | case super.IsFloat(id): |
| 81 | return NewConstFloat(val.Type(), val.Float(), length) |
| 82 | case id == super.IDBool: |
| 83 | return NewConstBool(val.Bool(), length) |
| 84 | case id == super.IDBytes: |
| 85 | return NewConstBytes(val.Bytes(), length) |
| 86 | case id == super.IDString: |
| 87 | return NewConstString(string(val.Bytes()), length) |
| 88 | case id == super.IDIP: |
| 89 | return NewConstIP(super.DecodeIP(val.Bytes()), length) |
| 90 | case id == super.IDNet: |
| 91 | return NewConstNet(super.DecodeNet(val.Bytes()), length) |
| 92 | case id == super.IDType: |
| 93 | return NewConstType(val.Bytes(), length) |
| 94 | } |
| 95 | panic(fmt.Sprintf("%#v\n", super.TypeUnder(val.Type()))) |
| 96 | } |
| 97 | |
| 98 | func (c *Const) Len() uint32 { |
| 99 | return c.len |
no test coverage detected