MCPcopy Create free account
hub / github.com/brimdata/super / Call

Method Call

runtime/sam/expr/function/under.go:20–52  ·  view source on GitHub ↗
(args []super.Value)

Source from the content-addressed store, hash-verified

18}
19
20func (u *Under) Call(args []super.Value) super.Value {
21 val := args[0]
22 switch typ := args[0].Type().(type) {
23 case *super.TypeNamed:
24 return super.NewValue(typ.Type, val.Bytes())
25 case *super.TypeError:
26 return super.NewValue(typ.Type, val.Bytes())
27 case *super.TypeFusion:
28 it := val.Bytes().Iter()
29 bytes := it.Next()
30 subType, err := u.sctx.LookupByValue(it.Next())
31 if err != nil {
32 panic(err)
33 }
34 out, ok := u.downcast.Cast(super.NewValue(typ.Type, bytes), subType)
35 if !ok {
36 // The runtime should never allow creation of a super value that
37 // doesn't follow the subtype invariant.
38 panic(sup.FormatValue(val))
39 }
40 return out
41 case *super.TypeUnion:
42 return super.NewValue(typ.Untag(val.Bytes()))
43 case *super.TypeOfType:
44 t, err := u.sctx.LookupByValue(val.Bytes())
45 if err != nil {
46 return u.sctx.NewError(err)
47 }
48 return u.sctx.LookupTypeValue(super.TypeUnder(t))
49 default:
50 return val
51 }
52}

Callers

nothing calls this directly

Calls 12

NewValueFunction · 0.92
FormatValueFunction · 0.92
TypeUnderFunction · 0.92
IterMethod · 0.80
LookupByValueMethod · 0.80
UntagMethod · 0.80
NewErrorMethod · 0.80
LookupTypeValueMethod · 0.80
TypeMethod · 0.65
CastMethod · 0.65
BytesMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected