needInit returns true if and only if the given type is or makes use of user types.
(dt expr.DataType)
| 3057 | // needInit returns true if and only if the given type is or makes use of user |
| 3058 | // types. |
| 3059 | func needInit(dt expr.DataType) bool { |
| 3060 | if dt == expr.Empty { |
| 3061 | return false |
| 3062 | } |
| 3063 | switch actual := dt.(type) { |
| 3064 | case expr.Primitive: |
| 3065 | return false |
| 3066 | case *expr.Array: |
| 3067 | return needInit(actual.ElemType.Type) |
| 3068 | case *expr.Map: |
| 3069 | return needInit(actual.KeyType.Type) || |
| 3070 | needInit(actual.ElemType.Type) |
| 3071 | case *expr.Object: |
| 3072 | for _, nat := range *actual { |
| 3073 | if needInit(nat.Attribute.Type) { |
| 3074 | return true |
| 3075 | } |
| 3076 | } |
| 3077 | return false |
| 3078 | case expr.UserType: |
| 3079 | return true |
| 3080 | default: |
| 3081 | panic(fmt.Sprintf("unknown data type %T", actual)) // bug |
| 3082 | } |
| 3083 | } |
| 3084 | |
| 3085 | // upgradeParams returns the data required to render the websocket_upgrade |
| 3086 | // template. |
no outgoing calls
no test coverage detected