| 54 | } |
| 55 | |
| 56 | func (r *Replace) Call(args []super.Value) super.Value { |
| 57 | args = underAll(args) |
| 58 | sVal := args[0] |
| 59 | oldVal := args[1] |
| 60 | newVal := args[2] |
| 61 | if sVal.IsNull() || oldVal.IsNull() || newVal.IsNull() { |
| 62 | return super.Null |
| 63 | } |
| 64 | for i := range args { |
| 65 | if !args[i].IsString() { |
| 66 | return r.sctx.WrapError("replace: string arg required", args[i]) |
| 67 | } |
| 68 | } |
| 69 | s := super.DecodeString(sVal.Bytes()) |
| 70 | old := super.DecodeString(oldVal.Bytes()) |
| 71 | new := super.DecodeString(newVal.Bytes()) |
| 72 | return super.NewString(strings.ReplaceAll(s, old, new)) |
| 73 | } |
| 74 | |
| 75 | type ToLower struct { |
| 76 | sctx *super.Context |