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

Function recordToExpr

compiler/semantic/sem/expr.go:505–524  ·  view source on GitHub ↗
(loc ast.Node, typ *super.TypeRecord, bytes scode.Bytes)

Source from the content-addressed store, hash-verified

503}
504
505func recordToExpr(loc ast.Node, typ *super.TypeRecord, bytes scode.Bytes) Expr {
506 var elems []RecordElem
507 it := scode.NewRecordIter(bytes, typ.Opts)
508 for _, f := range typ.Fields {
509 if it.Done() {
510 panic(it)
511 }
512 var elem RecordElem
513 if val, none := it.Next(f.Opt); none {
514 elem = &NoneElem{Node: loc, Name: f.Name, Type: NewLiteral(loc, super.NewTypeValue(typ))}
515 } else {
516 elem = &FieldElem{Node: loc, Name: f.Name, Value: valueToExpr(loc, f.Type, val), Opt: f.Opt}
517 }
518 elems = append(elems, elem)
519 }
520 return &RecordExpr{
521 Node: loc,
522 Elems: elems,
523 }
524}
525
526func arrayToExpr(loc ast.Node, typ *super.TypeArray, bytes scode.Bytes) Expr {
527 var elems []ArrayElem

Callers 1

valueToExprFunction · 0.85

Calls 6

DoneMethod · 0.95
NextMethod · 0.95
NewRecordIterFunction · 0.92
NewTypeValueFunction · 0.92
valueToExprFunction · 0.85
NewLiteralFunction · 0.70

Tested by

no test coverage detected