(v reflect.Value, expr *unstable.Node, value *unstable.Node)
| 2046 | } |
| 2047 | |
| 2048 | func (d *decoder) assignInlineTable(v reflect.Value, expr *unstable.Node, value *unstable.Node) (reflect.Value, error) { |
| 2049 | switch v.Kind() { |
| 2050 | case reflect.Map: |
| 2051 | // Inline tables are self-contained: they fully replace the target. |
| 2052 | v = reflect.MakeMap(v.Type()) |
| 2053 | case reflect.Struct: |
| 2054 | // fields are set in place |
| 2055 | case reflect.Interface: |
| 2056 | elem := reflect.ValueOf(map[string]interface{}{}) |
| 2057 | nv, err := d.assignInlineTable(elem, expr, value) |
| 2058 | if err != nil { |
| 2059 | return reflect.Value{}, err |
| 2060 | } |
| 2061 | return boxInto(v, nv) |
| 2062 | default: |
| 2063 | return reflect.Value{}, d.typeMismatchError("inline table", v.Type(), d.rawValue(expr, value)) |
| 2064 | } |
| 2065 | |
| 2066 | it := value.Children() |
| 2067 | for it.Next() { |
| 2068 | kv := it.Node() |
| 2069 | // Build the path from the key of this key-value. Keys of inline |
| 2070 | // tables rarely have more than a few parts. |
| 2071 | var pathBuf [4]pathPart |
| 2072 | path := pathBuf[:0] |
| 2073 | kit := kv.Key() |
| 2074 | for kit.Next() { |
| 2075 | path = append(path, pathPart{node: kit.Node()}) |
| 2076 | } |
| 2077 | nv, err := d.descend(v, path, 0, kv, kv.Value()) |
| 2078 | if err != nil { |
| 2079 | return reflect.Value{}, err |
| 2080 | } |
| 2081 | if nv.IsValid() { |
| 2082 | v = nv |
| 2083 | } |
| 2084 | } |
| 2085 | return v, nil |
| 2086 | } |
| 2087 | |
| 2088 | // boxInto returns the value to store in place of the interface value v. The |
| 2089 | // caller stores the result in the slot v was found in, which performs the |
no test coverage detected