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

Method fstringExpr

compiler/semantic/expr.go:1252–1275  ·  view source on GitHub ↗
(f *ast.FStringExpr, inType super.Type)

Source from the content-addressed store, hash-verified

1250}
1251
1252func (t *translator) fstringExpr(f *ast.FStringExpr, inType super.Type) (sem.Expr, super.Type) {
1253 if len(f.Elems) == 0 {
1254 return sem.NewLiteral(f, super.NewString("")), super.TypeString
1255 }
1256 var out sem.Expr
1257 for _, elem := range f.Elems {
1258 var e sem.Expr
1259 switch elem := elem.(type) {
1260 case *ast.FStringExprElem:
1261 e, _ = t.expr(elem.Expr, inType)
1262 e = sem.NewCast(f, e, super.TypeString)
1263 case *ast.FStringTextElem:
1264 e = sem.NewLiteral(elem, super.NewString(elem.Text))
1265 default:
1266 panic(elem)
1267 }
1268 if out == nil {
1269 out = e
1270 continue
1271 }
1272 out = sem.NewCall(f, "concat", []sem.Expr{out, e})
1273 }
1274 return out, super.TypeString
1275}
1276
1277func (t *translator) arraySubquery(elems []sem.ArrayElem) *sem.SubqueryExpr {
1278 if len(elems) == 1 {

Callers 2

fromFStringMethod · 0.95
exprMethod · 0.95

Calls 5

exprMethod · 0.95
NewLiteralFunction · 0.92
NewStringFunction · 0.92
NewCastFunction · 0.92
NewCallFunction · 0.92

Tested by

no test coverage detected