miller/pkg/bifs/cmp.go
John Kerl 12c96298b9
Add a first-class bytes type to the DSL, with b"..." literals and base64/hex codecs (#2122)
* Add MT_BYTES mlrval type: foundation and disposition tables

First step toward a first-class bytes type in the DSL (#1231).
Adds MT_BYTES (payload []byte, rendered as lowercase hex in all output
formats, JSON-encoded as a hex string), extends every disposition
matrix/vector with the new row/column -- real cells for comparison,
sorting, and dot-concat of bytes with bytes; type-error stubs
elsewhere -- and adds sweep tests asserting no table has nil cells,
since Go zero-fills short array literals when MT_DIM grows.

Bytes values are not yet constructible from the DSL; b"..." literals
and constructor/codec functions follow in subsequent commits.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Add b"..." bytes-literal syntax to the DSL

Adds a bytes_literal token to the grammar (regenerating the PGPG lexer
and parser) and a BytesLiteralNode in the CST which evaluates to an
MT_BYTES mlrval. Escape handling reuses UnbackslashStringLiteral,
which is already byte-oriented: b"\xff" is the single byte 0xff.
Unlike string literals, bytes literals never participate in
regex-capture replacement. A bare identifier b is unaffected.

Part of #1231.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Add bytes DSL functions: conversions, codecs, and bytes-aware built-ins

- bytes(x) converts strings to bytes; string(b) reinterprets raw bytes
  as UTF-8 text (the reverse)
- base64_decode now always returns bytes (superseding the interim
  string-or-hex behavior); base64_encode accepts string or bytes
- New hex_encode/hex_decode functions
- is_bytes and asserting_bytes predicates
- md5/sha1/sha256/sha512 accept bytes, hashing the raw payload
- strlen of bytes is the byte count; substr/substr0/substr1 on bytes
  slice by byte position and return bytes

The Cyrillic-LDAP scenario from #1231 now works without exec
workarounds: string(base64_decode($x)) recovers the text, and binary
payloads survive undamaged as bytes.

Closes #1231.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Add bytes-type docs and regression cases

Documents the bytes type on the data-types page, regenerates the
function-reference/man-page material, and adds regression coverage:
literal escape forms, operators (concat/compare/slice/sort and
type errors), conversions and codec round-trips, and CSV-to-JSON
output rendering of bytes fields.

Part of #1231.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Reposition MT_BYTES to sort adjacent to MT_STRING in the type enum

MT_BYTES was appended after MT_ABSENT for index stability; move it
right after MT_STRING instead, since that's where it conceptually
belongs and where it already sorts in the cmp disposition matrices.
Mechanically re-derive all ~40 disposition tables in pkg/bifs and
pkg/mlrval accordingly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix windows CI

* fix merge

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 11:58:44 -04:00

463 lines
23 KiB
Go

// Boolean expressions for ==, !=, >, >=, <, <=
package bifs
import (
"bytes"
"github.com/johnkerl/miller/v6/pkg/lib"
"github.com/johnkerl/miller/v6/pkg/mlrval"
)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// string_cmp implements the spaceship operator for strings.
func string_cmp(a, b string) int64 {
if a < b {
return -1
}
if a > b {
return 1
}
return 0
}
// int_cmp implements the spaceship operator for ints.
func int_cmp(a, b int64) int64 {
if a < b {
return -1
}
if a > b {
return 1
}
return 0
}
// float_cmp implements the spaceship operator for floats.
func float_cmp(a, b float64) int64 {
if a < b {
return -1
}
if a > b {
return 1
}
return 0
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_ss(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() == input2.AcquireStringValue())
}
func ne_b_ss(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() != input2.AcquireStringValue())
}
func gt_b_ss(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() > input2.AcquireStringValue())
}
func ge_b_ss(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() >= input2.AcquireStringValue())
}
func lt_b_ss(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() < input2.AcquireStringValue())
}
func le_b_ss(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() <= input2.AcquireStringValue())
}
func cmp_b_ss(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromInt(int64(string_cmp(input1.AcquireStringValue(), input2.AcquireStringValue())))
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_xs(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.String() == input2.AcquireStringValue())
}
func ne_b_xs(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.String() != input2.AcquireStringValue())
}
func gt_b_xs(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.String() > input2.AcquireStringValue())
}
func ge_b_xs(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.String() >= input2.AcquireStringValue())
}
func lt_b_xs(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.String() < input2.AcquireStringValue())
}
func le_b_xs(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.String() <= input2.AcquireStringValue())
}
func cmp_b_xs(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromInt(int64(string_cmp(input1.String(), input2.AcquireStringValue())))
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_sx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() == input2.String())
}
func ne_b_sx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() != input2.String())
}
func gt_b_sx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() > input2.String())
}
func ge_b_sx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() >= input2.String())
}
func lt_b_sx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() < input2.String())
}
func le_b_sx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireStringValue() <= input2.String())
}
func cmp_b_sx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromInt(string_cmp(input1.AcquireStringValue(), input2.String()))
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireIntValue() == input2.AcquireIntValue())
}
func ne_b_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireIntValue() != input2.AcquireIntValue())
}
func gt_b_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireIntValue() > input2.AcquireIntValue())
}
func ge_b_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireIntValue() >= input2.AcquireIntValue())
}
func lt_b_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireIntValue() < input2.AcquireIntValue())
}
func le_b_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireIntValue() <= input2.AcquireIntValue())
}
func cmp_b_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromInt(int_cmp(input1.AcquireIntValue(), input2.AcquireIntValue()))
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_if(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(float64(input1.AcquireIntValue()) == input2.AcquireFloatValue())
}
func ne_b_if(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(float64(input1.AcquireIntValue()) != input2.AcquireFloatValue())
}
func gt_b_if(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(float64(input1.AcquireIntValue()) > input2.AcquireFloatValue())
}
func ge_b_if(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(float64(input1.AcquireIntValue()) >= input2.AcquireFloatValue())
}
func lt_b_if(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(float64(input1.AcquireIntValue()) < input2.AcquireFloatValue())
}
func le_b_if(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(float64(input1.AcquireIntValue()) <= input2.AcquireFloatValue())
}
func cmp_b_if(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromInt(float_cmp(float64(input1.AcquireIntValue()), input2.AcquireFloatValue()))
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_fi(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() == float64(input2.AcquireIntValue()))
}
func ne_b_fi(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() != float64(input2.AcquireIntValue()))
}
func gt_b_fi(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() > float64(input2.AcquireIntValue()))
}
func ge_b_fi(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() >= float64(input2.AcquireIntValue()))
}
func lt_b_fi(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() < float64(input2.AcquireIntValue()))
}
func le_b_fi(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() <= float64(input2.AcquireIntValue()))
}
func cmp_b_fi(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromInt(float_cmp(input1.AcquireFloatValue(), float64(input2.AcquireIntValue())))
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_ff(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() == input2.AcquireFloatValue())
}
func ne_b_ff(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() != input2.AcquireFloatValue())
}
func gt_b_ff(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() > input2.AcquireFloatValue())
}
func ge_b_ff(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() >= input2.AcquireFloatValue())
}
func lt_b_ff(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() < input2.AcquireFloatValue())
}
func le_b_ff(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireFloatValue() <= input2.AcquireFloatValue())
}
func cmp_b_ff(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromInt(float_cmp(input1.AcquireFloatValue(), input2.AcquireFloatValue()))
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireBoolValue() == input2.AcquireBoolValue())
}
func ne_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireBoolValue() != input2.AcquireBoolValue())
}
// We could say ordering on bool is error, but, Miller allows
// sorting on bool so it should allow ordering on bool.
func gt_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(lib.BoolToInt(input1.AcquireBoolValue()) > lib.BoolToInt(input2.AcquireBoolValue()))
}
func ge_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(lib.BoolToInt(input1.AcquireBoolValue()) >= lib.BoolToInt(input2.AcquireBoolValue()))
}
func lt_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(lib.BoolToInt(input1.AcquireBoolValue()) < lib.BoolToInt(input2.AcquireBoolValue()))
}
func le_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(lib.BoolToInt(input1.AcquireBoolValue()) <= lib.BoolToInt(input2.AcquireBoolValue()))
}
func cmp_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromInt(int_cmp(lib.BoolToInt(input1.AcquireBoolValue()), lib.BoolToInt(input2.AcquireBoolValue())))
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_aa(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
a := input1.AcquireArrayValue()
b := input2.AcquireArrayValue()
// Different-length arrays are not equal
if len(a) != len(b) {
return mlrval.FALSE
}
// Same-length arrays: return false if any slot is not equal, else true.
for i := range a {
eq := BIF_equals(a[i], b[i])
// Treat invalid comparison as false
if eq.Type() == mlrval.MT_ABSENT {
return mlrval.FALSE
}
lib.InternalCodingErrorIf(eq.Type() != mlrval.MT_BOOL)
if !eq.AcquireBoolValue() {
return mlrval.FALSE
}
}
return mlrval.TRUE
}
func ne_b_aa(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
output := eq_b_aa(input1, input2)
return mlrval.FromBool(!output.AcquireBoolValue())
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// 'y' is for bytes ('b' is for boolean)
func eq_b_yy(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(bytes.Equal(input1.AcquireBytesValue(), input2.AcquireBytesValue()))
}
func ne_b_yy(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(!bytes.Equal(input1.AcquireBytesValue(), input2.AcquireBytesValue()))
}
func gt_b_yy(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(bytes.Compare(input1.AcquireBytesValue(), input2.AcquireBytesValue()) > 0)
}
func ge_b_yy(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(bytes.Compare(input1.AcquireBytesValue(), input2.AcquireBytesValue()) >= 0)
}
func lt_b_yy(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(bytes.Compare(input1.AcquireBytesValue(), input2.AcquireBytesValue()) < 0)
}
func le_b_yy(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(bytes.Compare(input1.AcquireBytesValue(), input2.AcquireBytesValue()) <= 0)
}
func cmp_b_yy(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromInt(int64(bytes.Compare(input1.AcquireBytesValue(), input2.AcquireBytesValue())))
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func eq_b_mm(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(input1.AcquireMapValue().Equals(input2.AcquireMapValue()))
}
func ne_b_mm(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromBool(!input1.AcquireMapValue().Equals(input2.AcquireMapValue()))
}
// We get a Golang "initialization loop" due to recursive depth computation
// if this is defined statically. So, we use a "package init" function.
var eq_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{}
func eqte(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromTypeErrorBinary("==", input1, input2)
}
func init() {
eq_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{
// . INT FLOAT BOOL VOID STRING BYTES ARRAY MAP FUNC ERROR NULL ABSENT
/*INT */ {eq_b_ii, eq_b_if, _fals, eq_b_xs, eq_b_xs, _fals, _fals, _fals, eqte, eqte, _fals, _absn},
/*FLOAT */ {eq_b_fi, eq_b_ff, _fals, eq_b_xs, eq_b_xs, _fals, _fals, _fals, eqte, eqte, _fals, _absn},
/*BOOL */ {_fals, _fals, eq_b_bb, _fals, _fals, _fals, _fals, _fals, eqte, eqte, _fals, _absn},
/*VOID */ {eq_b_sx, eq_b_sx, _fals, eq_b_ss, eq_b_ss, _fals, _fals, _fals, eqte, eqte, _fals, _absn},
/*STRING */ {eq_b_sx, eq_b_sx, _fals, eq_b_ss, eq_b_ss, _fals, _fals, _fals, eqte, eqte, _fals, _absn},
/*BYTES */ {_fals, _fals, _fals, _fals, _fals, eq_b_yy, _fals, _fals, eqte, eqte, _fals, _absn},
/*ARRAY */ {_fals, _fals, _fals, _fals, _fals, _fals, eq_b_aa, _fals, eqte, eqte, _fals, _absn},
/*MAP */ {_fals, _fals, _fals, _fals, _fals, _fals, _fals, eq_b_mm, eqte, eqte, _fals, _absn},
/*FUNC */ {eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte},
/*ERROR */ {eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte, eqte},
/*NULL */ {_fals, _fals, _fals, _fals, _fals, _fals, _fals, _fals, eqte, eqte, _true, _absn},
/*ABSENT */ {_absn, _absn, _absn, _absn, _absn, _absn, _absn, _absn, eqte, eqte, _absn, _absn},
}
}
func nete(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromTypeErrorBinary("!=", input1, input2)
}
var ne_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{
// . INT FLOAT BOOL VOID STRING BYTES ARRAY MAP FUNC ERROR NULL ABSENT
/*INT */ {ne_b_ii, ne_b_if, _true, ne_b_xs, ne_b_xs, _true, _true, _true, nete, nete, _true, _absn},
/*FLOAT */ {ne_b_fi, ne_b_ff, _true, ne_b_xs, ne_b_xs, _true, _true, _true, nete, nete, _true, _absn},
/*BOOL */ {_true, _true, ne_b_bb, _true, _true, _true, _true, _true, nete, nete, _true, _absn},
/*VOID */ {ne_b_sx, ne_b_sx, _true, ne_b_ss, ne_b_ss, _true, _true, _true, nete, nete, _true, _absn},
/*STRING */ {ne_b_sx, ne_b_sx, _true, ne_b_ss, ne_b_ss, _true, _true, _true, nete, nete, _true, _absn},
/*BYTES */ {_true, _true, _true, _true, _true, ne_b_yy, _true, _true, nete, nete, _true, _absn},
/*ARRAY */ {_true, _true, _true, _true, _true, _true, ne_b_aa, _true, nete, nete, _true, _absn},
/*MAP */ {_true, _true, _true, _true, _true, _true, _true, ne_b_mm, nete, nete, _true, _absn},
/*FUNC */ {nete, nete, nete, nete, nete, nete, nete, nete, nete, nete, nete, nete},
/*ERROR */ {nete, nete, nete, nete, nete, nete, nete, nete, nete, nete, nete, nete},
/*NULL */ {_true, _true, _true, _true, _true, _true, _true, _true, nete, nete, _fals, _absn},
/*ABSENT */ {_absn, _absn, _absn, _absn, _absn, _absn, _absn, _absn, nete, nete, _absn, _absn},
}
func gtte(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromTypeErrorBinary(">", input1, input2)
}
var gt_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{
// . INT FLOAT BOOL VOID STRING BYTES ARRAY MAP FUNC ERROR NULL ABSENT
/*INT */ {gt_b_ii, gt_b_if, _fals, gt_b_xs, gt_b_xs, _fals, _fals, _fals, gtte, gtte, _fals, _absn},
/*FLOAT */ {gt_b_fi, gt_b_ff, _fals, gt_b_xs, gt_b_xs, _fals, _fals, _fals, gtte, gtte, _fals, _absn},
/*BOOL */ {_fals, _fals, gt_b_bb, _fals, _fals, _fals, _fals, _fals, gtte, gtte, _fals, _absn},
/*VOID */ {gt_b_sx, gt_b_sx, _fals, gt_b_ss, gt_b_ss, _fals, _fals, _fals, gtte, gtte, _fals, _absn},
/*STRING */ {gt_b_sx, gt_b_sx, _fals, gt_b_ss, gt_b_ss, _fals, _fals, _fals, gtte, gtte, _fals, _absn},
/*BYTES */ {_fals, _fals, _fals, _fals, _fals, gt_b_yy, _fals, _fals, gtte, gtte, _fals, _absn},
/*ARRAY */ {_fals, _fals, _fals, _fals, _fals, _fals, gtte, _fals, gtte, gtte, _fals, _absn},
/*MAP */ {_fals, _fals, _fals, _fals, _fals, _fals, _fals, gtte, gtte, gtte, _fals, _absn},
/*FUNC */ {gtte, gtte, gtte, gtte, gtte, gtte, gtte, gtte, gtte, gtte, gtte, gtte},
/*ERROR */ {gtte, gtte, gtte, gtte, gtte, gtte, gtte, gtte, gtte, gtte, _fals, gtte},
/*NULL */ {_true, _true, _true, _true, _true, _true, _absn, _absn, gtte, _true, _fals, _fals},
/*ABSENT */ {_absn, _absn, _absn, _absn, _absn, _absn, _absn, _absn, gtte, gtte, _true, _absn},
}
func gete(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromTypeErrorBinary(">=", input1, input2)
}
var ge_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{
// . INT FLOAT BOOL VOID STRING BYTES ARRAY MAP FUNC ERROR NULL ABSENT
/*INT */ {ge_b_ii, ge_b_if, _fals, ge_b_xs, ge_b_xs, _fals, _fals, _fals, gete, gete, _fals, _absn},
/*FLOAT */ {ge_b_fi, ge_b_ff, _fals, ge_b_xs, ge_b_xs, _fals, _fals, _fals, gete, gete, _fals, _absn},
/*BOOL */ {_fals, _fals, ge_b_bb, _fals, _fals, _fals, _fals, _fals, gete, gete, _fals, _absn},
/*VOID */ {ge_b_sx, ge_b_sx, _fals, ge_b_ss, ge_b_ss, _fals, _fals, _fals, gete, gete, _fals, _absn},
/*STRING */ {ge_b_sx, ge_b_sx, _fals, ge_b_ss, ge_b_ss, _fals, _fals, _fals, gete, gete, _fals, _absn},
/*BYTES */ {_fals, _fals, _fals, _fals, _fals, ge_b_yy, _fals, _fals, gete, gete, _fals, _absn},
/*ARRAY */ {_fals, _fals, _fals, _fals, _fals, _fals, gete, _fals, gete, gete, _fals, _absn},
/*MAP */ {_fals, _fals, _fals, _fals, _fals, _fals, _fals, gete, gete, gete, _fals, _absn},
/*FUNC */ {gete, gete, gete, gete, gete, gete, gete, gete, gete, gete, gete, gete},
/*ERROR */ {gete, gete, gete, gete, gete, gete, gete, gete, gete, gete, _fals, gete},
/*NULL */ {_true, _true, _true, _true, _true, _true, _absn, _absn, gete, _true, _true, _fals},
/*ABSENT */ {_absn, _absn, _absn, _absn, _absn, _absn, _absn, _absn, gete, gete, _true, _absn},
}
func ltte(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromTypeErrorBinary("<", input1, input2)
}
var lt_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{
// . INT FLOAT BOOL VOID STRING BYTES ARRAY MAP FUNC ERROR NULL ABSENT
/*INT */ {lt_b_ii, lt_b_if, _fals, lt_b_xs, lt_b_xs, _fals, _fals, _fals, ltte, ltte, _true, _absn},
/*FLOAT */ {lt_b_fi, lt_b_ff, _fals, lt_b_xs, lt_b_xs, _fals, _fals, _fals, ltte, ltte, _true, _absn},
/*BOOL */ {_fals, _fals, lt_b_bb, _fals, _fals, _fals, _fals, _fals, ltte, ltte, _true, _absn},
/*VOID */ {lt_b_sx, lt_b_sx, _fals, lt_b_ss, lt_b_ss, _fals, _fals, _fals, ltte, ltte, _true, _absn},
/*STRING */ {lt_b_sx, lt_b_sx, _fals, lt_b_ss, lt_b_ss, _fals, _fals, _fals, ltte, ltte, _true, _absn},
/*BYTES */ {_fals, _fals, _fals, _fals, _fals, lt_b_yy, _fals, _fals, ltte, ltte, _fals, _absn},
/*ARRAY */ {_fals, _fals, _fals, _fals, _fals, _fals, ltte, _fals, ltte, ltte, _absn, _absn},
/*MAP */ {_fals, _fals, _fals, _fals, _fals, _fals, _fals, ltte, ltte, ltte, _absn, _absn},
/*FUNC */ {ltte, ltte, ltte, ltte, ltte, ltte, ltte, ltte, ltte, ltte, ltte, ltte},
/*ERROR */ {ltte, ltte, ltte, ltte, ltte, ltte, ltte, ltte, ltte, ltte, _true, ltte},
/*NULL */ {_fals, _fals, _fals, _fals, _fals, _fals, _absn, _absn, ltte, _fals, _fals, _true},
/*ABSENT */ {_absn, _absn, _absn, _absn, _absn, _absn, _absn, _absn, ltte, ltte, _fals, _absn},
}
func lete(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromTypeErrorBinary("<=", input1, input2)
}
var le_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{
// . INT FLOAT BOOL VOID STRING BYTES ARRAY MAP FUNC ERROR NULL ABSENT
/*INT */ {le_b_ii, le_b_if, _fals, le_b_xs, le_b_xs, _fals, _fals, _fals, lete, lete, _true, _absn},
/*FLOAT */ {le_b_fi, le_b_ff, _fals, le_b_xs, le_b_xs, _fals, _fals, _fals, lete, lete, _true, _absn},
/*BOOL */ {_fals, _fals, le_b_bb, _fals, _fals, _fals, _fals, _fals, lete, lete, _true, _absn},
/*VOID */ {le_b_sx, le_b_sx, _fals, le_b_ss, le_b_ss, _fals, _fals, _fals, lete, lete, _true, _absn},
/*STRING */ {le_b_sx, le_b_sx, _fals, le_b_ss, le_b_ss, _fals, _fals, _fals, lete, lete, _true, _absn},
/*BYTES */ {_fals, _fals, _fals, _fals, _fals, le_b_yy, _fals, _fals, lete, lete, _fals, _absn},
/*ARRAY */ {_fals, _fals, _fals, _fals, _fals, _fals, lete, _fals, lete, lete, _absn, _absn},
/*MAP */ {_fals, _fals, _fals, _fals, _fals, _fals, _fals, lete, lete, lete, _absn, _absn},
/*FUNC */ {lete, lete, lete, lete, lete, lete, lete, lete, lete, lete, lete, lete},
/*ERROR */ {lete, lete, lete, lete, lete, lete, lete, lete, lete, lete, _true, lete},
/*NULL */ {_fals, _fals, _fals, _fals, _fals, _fals, _absn, _absn, lete, _fals, _true, _true},
/*ABSENT */ {_absn, _absn, _absn, _absn, _absn, _absn, _absn, _absn, lete, lete, _fals, _absn},
}
func cmpte(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return mlrval.FromTypeErrorBinary("<=>", input1, input2)
}
var cmp_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{
// . INT FLOAT BOOL VOID STRING BYTES ARRAY MAP FUNC ERROR NULL ABSENT
/*INT */ {cmp_b_ii, cmp_b_if, _less, cmp_b_xs, cmp_b_xs, _less, _less, _less, cmpte, cmpte, _true, _absn},
/*FLOAT */ {cmp_b_fi, cmp_b_ff, _less, cmp_b_xs, cmp_b_xs, _less, _less, _less, cmpte, cmpte, _true, _absn},
/*BOOL */ {_more, _more, cmp_b_bb, _less, _less, _less, _less, _less, cmpte, cmpte, _true, _absn},
/*VOID */ {cmp_b_sx, cmp_b_sx, _more, cmp_b_ss, cmp_b_ss, _less, _less, _less, cmpte, cmpte, _true, _absn},
/*STRING */ {cmp_b_sx, cmp_b_sx, _more, cmp_b_ss, cmp_b_ss, _less, _less, _less, cmpte, cmpte, _true, _absn},
/*BYTES */ {_more, _more, _more, _more, _more, cmp_b_yy, _less, _less, cmpte, cmpte, _less, _absn},
/*ARRAY */ {_more, _more, _more, _more, _more, _more, cmpte, _less, cmpte, cmpte, _absn, _absn},
/*MAP */ {_more, _more, _more, _more, _more, _more, _more, cmpte, cmpte, cmpte, _absn, _absn},
/*FUNC */ {cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte},
/*ERROR */ {cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, cmpte, _true, cmpte},
/*NULL */ {_more, _more, _more, _more, _more, _more, _absn, _absn, cmpte, _more, _same, _true},
/*ABSENT */ {_absn, _absn, _absn, _absn, _absn, _absn, _absn, _absn, cmpte, cmpte, _more, _absn},
}
func BIF_equals(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return eq_dispositions[input1.Type()][input2.Type()](input1, input2)
}
func BIF_not_equals(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return ne_dispositions[input1.Type()][input2.Type()](input1, input2)
}
func BIF_greater_than(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return gt_dispositions[input1.Type()][input2.Type()](input1, input2)
}
func BIF_greater_than_or_equals(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return ge_dispositions[input1.Type()][input2.Type()](input1, input2)
}
func BIF_less_than(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return lt_dispositions[input1.Type()][input2.Type()](input1, input2)
}
func BIF_less_than_or_equals(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return le_dispositions[input1.Type()][input2.Type()](input1, input2)
}
func BIF_cmp(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval {
return cmp_dispositions[input1.Type()][input2.Type()](input1, input2)
}