Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove runtime/expr.NewCast #4750

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions runtime/expr/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,34 +806,6 @@ func (c *Call) Eval(ectx Context, this *zed.Value) *zed.Value {
return c.fn.Call(ectx, c.args)
}

func NewCast(zctx *zed.Context, expr Evaluator, typ zed.Type) (Evaluator, error) {
// XXX should handle named type casts. need type context.
// compile is going to need a local type context to create literals
// of complex types?
c := LookupPrimitiveCaster(zctx, typ)
if c == nil {
// XXX See issue #1572. To implement named cast here.
return nil, fmt.Errorf("cast to %q not implemented", zson.FormatType(typ))
}
return &evalCast{expr, c, typ}, nil
}

type evalCast struct {
expr Evaluator
caster Evaluator
typ zed.Type
}

func (c *evalCast) Eval(ectx Context, this *zed.Value) *zed.Value {
val := c.expr.Eval(ectx, this)
if val.IsNull() || val.Type == c.typ {
// If value is null or the type won't change, just return a
// copy of the value.
return ectx.NewValue(c.typ, val.Bytes())
}
return c.caster.Eval(ectx, val)
}

type Assignment struct {
LHS field.Path
RHS Evaluator
Expand Down