(loc ast.Node, typ super.Type, bytes scode.Bytes)
| 475 | } |
| 476 | |
| 477 | func 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 | |
| 505 | func recordToExpr(loc ast.Node, typ *super.TypeRecord, bytes scode.Bytes) Expr { |
| 506 | var elems []RecordElem |
no test coverage detected