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

Function valueToExpr

compiler/semantic/sem/expr.go:477–503  ·  view source on GitHub ↗
(loc ast.Node, typ super.Type, bytes scode.Bytes)

Source from the content-addressed store, hash-verified

475}
476
477func valueToExpr(loc ast.Node, typ super.Type, bytes scode.Bytes) Expr {
478 if super.IsPrimitiveType(typ) {
479 return &PrimitiveExpr{
480 Node: loc,
481 Value: sup.FormatValue(super.NewValue(typ, bytes)),
482 }
483 }
484 switch typ := typ.(type) {
485 case *super.TypeNamed:
486 return NewCast(loc, valueToExpr(loc, typ.Type, bytes), typ)
487 case *super.TypeRecord:
488 return recordToExpr(loc, typ, bytes)
489 case *super.TypeArray:
490 return arrayToExpr(loc, typ, bytes)
491 case *super.TypeSet:
492 return setToExpr(loc, typ, bytes)
493 case *super.TypeUnion:
494 return unionToExpr(loc, typ, bytes)
495 case *super.TypeMap:
496 return mapToExpr(loc, typ, bytes)
497 case *super.TypeError:
498 args := []Expr{valueToExpr(loc, typ.Type, bytes)}
499 return NewCall(loc, "error", args)
500 default:
501 panic(typ)
502 }
503}
504
505func recordToExpr(loc ast.Node, typ *super.TypeRecord, bytes scode.Bytes) Expr {
506 var elems []RecordElem

Callers 6

NewLiteralFunction · 0.85
recordToExprFunction · 0.85
arrayToExprFunction · 0.85
setToExprFunction · 0.85
unionToExprFunction · 0.85
mapToExprFunction · 0.85

Calls 10

IsPrimitiveTypeFunction · 0.92
FormatValueFunction · 0.92
NewValueFunction · 0.92
NewCastFunction · 0.85
recordToExprFunction · 0.85
arrayToExprFunction · 0.85
setToExprFunction · 0.85
unionToExprFunction · 0.85
mapToExprFunction · 0.85
NewCallFunction · 0.70

Tested by

no test coverage detected