diff options
Diffstat (limited to 'core/vm')
-rw-r--r-- | core/vm/sqlvm/runtime/instructions_op_test.go | 418 | ||||
-rw-r--r-- | core/vm/sqlvm/runtime/instructions_tmpl.go | 224 | ||||
-rw-r--r-- | core/vm/sqlvm/runtime/instructions_tmpl_data.go | 2704 |
3 files changed, 1375 insertions, 1971 deletions
diff --git a/core/vm/sqlvm/runtime/instructions_op_test.go b/core/vm/sqlvm/runtime/instructions_op_test.go index f18fb0181..a3f84037b 100644 --- a/core/vm/sqlvm/runtime/instructions_op_test.go +++ b/core/vm/sqlvm/runtime/instructions_op_test.go @@ -19,7 +19,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}, @@ -31,7 +31,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}, @@ -46,7 +46,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(4)}}, @@ -65,7 +65,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}, @@ -76,7 +76,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(-10)}}, @@ -88,7 +88,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(11)}, &Raw{Value: decimal.NewFromFloat(8)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -106,7 +106,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(-10)}}, @@ -115,7 +115,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}, @@ -129,7 +129,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(11)}, &Raw{Value: decimal.NewFromFloat(8)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -147,7 +147,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(127)}}, @@ -158,7 +158,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -182,7 +182,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(126)}}, @@ -192,7 +192,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -217,7 +217,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-128)}}, @@ -228,7 +228,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-1)}}, @@ -252,7 +252,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-127)}}, @@ -262,7 +262,7 @@ func (s *instructionSuite) TestOpAdd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-1)}}, @@ -294,7 +294,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}, @@ -306,7 +306,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}, @@ -321,7 +321,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -340,7 +340,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}, @@ -351,7 +351,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(-10)}}, @@ -363,7 +363,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(9)}, &Raw{Value: decimal.NewFromFloat(12)}, &Raw{Value: decimal.NewFromFloat(20)}}, @@ -381,7 +381,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(-10)}}, @@ -390,7 +390,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}, @@ -404,7 +404,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-9)}, &Raw{Value: decimal.NewFromFloat(-12)}, &Raw{Value: decimal.NewFromFloat(-20)}}, @@ -422,7 +422,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(127)}}, @@ -433,7 +433,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-1)}}, @@ -457,7 +457,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(126)}}, @@ -467,7 +467,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-1)}}, @@ -492,7 +492,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-128)}}, @@ -503,7 +503,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -527,7 +527,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-127)}}, @@ -537,7 +537,7 @@ func (s *instructionSuite) TestOpSub() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -569,7 +569,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -581,7 +581,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -596,7 +596,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -615,7 +615,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}, @@ -625,7 +625,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -637,7 +637,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(-20)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -654,7 +654,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -663,7 +663,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}, @@ -676,7 +676,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(-20)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -693,7 +693,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(127)}}, @@ -704,7 +704,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(2)}}, @@ -728,7 +728,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(126)}}, @@ -738,7 +738,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -763,7 +763,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-128)}}, @@ -774,7 +774,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(2)}}, @@ -798,7 +798,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-127)}}, @@ -808,7 +808,7 @@ func (s *instructionSuite) TestOpMul() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -840,7 +840,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -852,7 +852,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -867,7 +867,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -886,7 +886,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -899,7 +899,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-2)}}, @@ -911,7 +911,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -931,7 +931,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(50)}, &Raw{Value: decimal.NewFromFloat(-50)}}, @@ -940,7 +940,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}, @@ -955,7 +955,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(5)}, &Raw{Value: decimal.NewFromFloat(-5)}}, @@ -974,7 +974,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}}, @@ -985,7 +985,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}}, @@ -1009,7 +1009,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}}, @@ -1019,7 +1019,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -1044,7 +1044,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -1054,7 +1054,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1078,7 +1078,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-128)}}, @@ -1088,7 +1088,7 @@ func (s *instructionSuite) TestOpDiv() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1120,7 +1120,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -1132,7 +1132,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -1147,7 +1147,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -1166,7 +1166,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -1179,7 +1179,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(3)}, &Raw{Value: decimal.NewFromFloat(-3)}}, @@ -1191,7 +1191,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -1211,7 +1211,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(31)}, &Raw{Value: decimal.NewFromFloat(-31)}}, @@ -1220,7 +1220,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}, @@ -1235,7 +1235,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1254,7 +1254,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}}, @@ -1265,7 +1265,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}}, @@ -1289,7 +1289,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(10)}}, @@ -1299,7 +1299,7 @@ func (s *instructionSuite) TestOpMod() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -1331,7 +1331,7 @@ func (s *instructionSuite) TestOpLt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1342,7 +1342,7 @@ func (s *instructionSuite) TestOpLt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -1356,7 +1356,7 @@ func (s *instructionSuite) TestOpLt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawFalse, rawTrue, rawTrue}, @@ -1374,7 +1374,7 @@ func (s *instructionSuite) TestOpLt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1383,7 +1383,7 @@ func (s *instructionSuite) TestOpLt() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -1395,7 +1395,7 @@ func (s *instructionSuite) TestOpLt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawFalse, rawFalse, rawTrue}, @@ -1411,7 +1411,7 @@ func (s *instructionSuite) TestOpLt() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -1420,7 +1420,7 @@ func (s *instructionSuite) TestOpLt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1432,7 +1432,7 @@ func (s *instructionSuite) TestOpLt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawFalse, rawTrue, rawFalse}, @@ -1455,7 +1455,7 @@ func (s *instructionSuite) TestOpGt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1466,7 +1466,7 @@ func (s *instructionSuite) TestOpGt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -1480,7 +1480,7 @@ func (s *instructionSuite) TestOpGt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawFalse, rawFalse, rawFalse}, @@ -1498,7 +1498,7 @@ func (s *instructionSuite) TestOpGt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1507,7 +1507,7 @@ func (s *instructionSuite) TestOpGt() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -1519,7 +1519,7 @@ func (s *instructionSuite) TestOpGt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawFalse, rawTrue, rawFalse}, @@ -1535,7 +1535,7 @@ func (s *instructionSuite) TestOpGt() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -1544,7 +1544,7 @@ func (s *instructionSuite) TestOpGt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1556,7 +1556,7 @@ func (s *instructionSuite) TestOpGt() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawFalse, rawFalse, rawTrue}, @@ -1579,7 +1579,7 @@ func (s *instructionSuite) TestOpEq() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1589,7 +1589,7 @@ func (s *instructionSuite) TestOpEq() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}, @@ -1602,7 +1602,7 @@ func (s *instructionSuite) TestOpEq() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue, rawTrue}, @@ -1619,7 +1619,7 @@ func (s *instructionSuite) TestOpEq() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -1629,7 +1629,7 @@ func (s *instructionSuite) TestOpEq() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -1641,7 +1641,7 @@ func (s *instructionSuite) TestOpEq() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue, rawTrue}, @@ -1665,7 +1665,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1675,7 +1675,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -1688,7 +1688,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1705,7 +1705,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1715,7 +1715,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -1727,7 +1727,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1744,7 +1744,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -1753,7 +1753,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1766,7 +1766,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1783,7 +1783,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -1792,7 +1792,7 @@ func (s *instructionSuite) TestOpAnd() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -1823,7 +1823,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1833,7 +1833,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -1846,7 +1846,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -1863,7 +1863,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1873,7 +1873,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -1885,7 +1885,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -1902,7 +1902,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -1911,7 +1911,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1924,7 +1924,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -1941,7 +1941,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -1950,7 +1950,7 @@ func (s *instructionSuite) TestOpOr() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -1981,7 +1981,7 @@ func (s *instructionSuite) TestOpNot() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -1994,7 +1994,7 @@ func (s *instructionSuite) TestOpNot() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawFalse, rawTrue}, @@ -2011,7 +2011,7 @@ func (s *instructionSuite) TestOpNot() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}}, @@ -2042,7 +2042,7 @@ func (s *instructionSuite) TestOpUnion() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -2052,7 +2052,7 @@ func (s *instructionSuite) TestOpUnion() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -2065,7 +2065,7 @@ func (s *instructionSuite) TestOpUnion() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawFalse, rawFalse}, @@ -2091,7 +2091,7 @@ func (s *instructionSuite) TestOpIntxn() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -2103,7 +2103,7 @@ func (s *instructionSuite) TestOpIntxn() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -2116,7 +2116,7 @@ func (s *instructionSuite) TestOpIntxn() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawFalse, rawFalse}, @@ -2140,7 +2140,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte("a%bcdefg")}, &Raw{Bytes: []byte("gfedcba")}}, @@ -2149,7 +2149,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte("%\\%b%")}}, @@ -2158,7 +2158,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte("\\")}}, @@ -2170,7 +2170,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -2186,7 +2186,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte("a%bcdefg")}}, @@ -2196,7 +2196,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte("%\\%b%")}}, @@ -2206,7 +2206,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte("\\")}}, @@ -2219,7 +2219,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue}, @@ -2236,7 +2236,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte{226, 40, 161, 228, 189, 160, 229, 165, 189}}, &Raw{Bytes: []byte("gfedcba")}}, @@ -2245,7 +2245,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte{37, 228, 189, 160, 37}}}, @@ -2257,7 +2257,7 @@ func (s *instructionSuite) TestOpLike() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -2280,7 +2280,7 @@ func (s *instructionSuite) TestOpZip() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}}, @@ -2290,7 +2290,7 @@ func (s *instructionSuite) TestOpZip() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, rawTrue}, @@ -2303,7 +2303,7 @@ func (s *instructionSuite) TestOpZip() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}, @@ -2320,7 +2320,7 @@ func (s *instructionSuite) TestOpZip() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{ {&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}}, @@ -2329,7 +2329,7 @@ func (s *instructionSuite) TestOpZip() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, rawTrue}, @@ -2342,7 +2342,7 @@ func (s *instructionSuite) TestOpZip() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}, @@ -2366,7 +2366,7 @@ func (s *instructionSuite) TestOpField() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}, @@ -2376,7 +2376,7 @@ func (s *instructionSuite) TestOpField() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}, @@ -2388,7 +2388,7 @@ func (s *instructionSuite) TestOpField() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -2412,7 +2412,7 @@ func (s *instructionSuite) TestOpPrune() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}, rawFalse, rawTrue}, @@ -2422,7 +2422,7 @@ func (s *instructionSuite) TestOpPrune() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(3)}, &Raw{Value: decimal.NewFromFloat(4)}}, @@ -2434,7 +2434,7 @@ func (s *instructionSuite) TestOpPrune() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), }, []Tuple{ {&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -2458,7 +2458,7 @@ func (s *instructionSuite) TestOpFilter() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -2470,7 +2470,7 @@ func (s *instructionSuite) TestOpFilter() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue}, @@ -2485,7 +2485,7 @@ func (s *instructionSuite) TestOpFilter() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -2509,7 +2509,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 1), ast.ComposeDataType(4, 1), + ast.ComposeDataType(ast.DataTypeMajorInt, 1), ast.ComposeDataType(ast.DataTypeMajorInt, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(127)}, &Raw{Value: decimal.NewFromFloat(127)}}, @@ -2519,7 +2519,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 2), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 2), }, []Tuple{}, ), @@ -2529,7 +2529,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 0), ast.ComposeDataType(4, 2), + ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 2), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(127)}, &Raw{Value: decimal.NewFromFloat(127)}}, @@ -2546,7 +2546,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 1), ast.ComposeDataType(4, 1), + ast.ComposeDataType(ast.DataTypeMajorInt, 1), ast.ComposeDataType(ast.DataTypeMajorInt, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(-32768)}}, @@ -2555,7 +2555,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(5, 1), ast.ComposeDataType(5, 1), + ast.ComposeDataType(ast.DataTypeMajorUint, 1), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{}, ), @@ -2565,7 +2565,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(5, 1), ast.ComposeDataType(5, 1), + ast.ComposeDataType(ast.DataTypeMajorUint, 1), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(32768)}}, @@ -2581,7 +2581,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 1), ast.ComposeDataType(4, 1), + ast.ComposeDataType(ast.DataTypeMajorInt, 1), ast.ComposeDataType(ast.DataTypeMajorInt, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(-32768)}}, @@ -2591,7 +2591,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{}, ), @@ -2601,7 +2601,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawTrue}, @@ -2618,7 +2618,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 1), ast.ComposeDataType(4, 1), + ast.ComposeDataType(ast.DataTypeMajorInt, 1), ast.ComposeDataType(ast.DataTypeMajorInt, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(-32768)}}, @@ -2627,7 +2627,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(6, 1), ast.ComposeDataType(3, 0), + ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), ast.ComposeDataType(ast.DataTypeMajorAddress, 0), }, []Tuple{}, ), @@ -2637,7 +2637,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(6, 1), ast.ComposeDataType(3, 0), + ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), ast.ComposeDataType(ast.DataTypeMajorAddress, 0), }, []Tuple{ {&Raw{Bytes: []byte{0x7f, 0xff}}, &Raw{Bytes: []byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0x80, 0x00}}}, @@ -2653,7 +2653,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(5, 1), ast.ComposeDataType(5, 1), + ast.ComposeDataType(ast.DataTypeMajorUint, 1), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(128)}, &Raw{Value: decimal.NewFromFloat(128)}}, @@ -2662,7 +2662,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(5, 0), ast.ComposeDataType(5, 2), + ast.ComposeDataType(ast.DataTypeMajorUint, 0), ast.ComposeDataType(ast.DataTypeMajorUint, 2), }, []Tuple{}, ), @@ -2672,7 +2672,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(5, 0), ast.ComposeDataType(5, 2), + ast.ComposeDataType(ast.DataTypeMajorUint, 0), ast.ComposeDataType(ast.DataTypeMajorUint, 2), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(128)}, &Raw{Value: decimal.NewFromFloat(128)}}, @@ -2688,7 +2688,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(5, 1), ast.ComposeDataType(5, 1), + ast.ComposeDataType(ast.DataTypeMajorUint, 1), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(32768)}}, @@ -2697,7 +2697,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 1), ast.ComposeDataType(6, 1), + ast.ComposeDataType(ast.DataTypeMajorInt, 1), ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), }, []Tuple{}, ), @@ -2707,7 +2707,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 1), ast.ComposeDataType(6, 1), + ast.ComposeDataType(ast.DataTypeMajorInt, 1), ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Bytes: []byte{0x80, 0x00}}}, @@ -2723,7 +2723,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(5, 1), ast.ComposeDataType(5, 1), + ast.ComposeDataType(ast.DataTypeMajorUint, 1), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -2732,7 +2732,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{}, ), @@ -2742,7 +2742,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue, rawFalse}, @@ -2758,7 +2758,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(5, 1), ast.ComposeDataType(5, 1), + ast.ComposeDataType(ast.DataTypeMajorUint, 1), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -2767,7 +2767,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(6, 1), ast.ComposeDataType(6, 1), + ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), }, []Tuple{}, ), @@ -2777,7 +2777,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(6, 1), ast.ComposeDataType(6, 1), + ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), }, []Tuple{ {&Raw{Bytes: []byte{0x7f, 0xff}}, &Raw{Bytes: []byte{0x00, 0x00}}}, @@ -2793,7 +2793,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(5, 1), + ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}}, @@ -2802,7 +2802,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(3, 1), + ast.ComposeDataType(ast.DataTypeMajorAddress, 1), }, []Tuple{}, ), @@ -2812,7 +2812,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(3, 1), + ast.ComposeDataType(ast.DataTypeMajorAddress, 1), }, []Tuple{ {&Raw{Bytes: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x7f, 0xff}}}, @@ -2828,7 +2828,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(6, 1), ast.ComposeDataType(6, 1), + ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), }, []Tuple{ {&Raw{Bytes: []byte{0xff, 0xff}}, &Raw{Bytes: []byte{0xff, 0xff}}}, @@ -2837,7 +2837,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(6, 0), ast.ComposeDataType(6, 2), + ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 0), ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 2), }, []Tuple{}, ), @@ -2847,7 +2847,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(6, 0), ast.ComposeDataType(6, 2), + ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 0), ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 2), }, []Tuple{ {&Raw{Bytes: []byte{0xff}}, &Raw{Bytes: []byte{0xff, 0xff, 0x00}}}, @@ -2863,7 +2863,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(6, 1), ast.ComposeDataType(6, 1), + ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), }, []Tuple{ {&Raw{Bytes: []byte{0x7f, 0xff}}, &Raw{Bytes: []byte{0x80, 0x00}}}, @@ -2872,7 +2872,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(4, 1), ast.ComposeDataType(5, 1), + ast.ComposeDataType(ast.DataTypeMajorInt, 1), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{}, ), @@ -2882,7 +2882,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 1), ast.ComposeDataType(5, 1), + ast.ComposeDataType(ast.DataTypeMajorInt, 1), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(32768)}}, @@ -2898,7 +2898,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(6, 1), + ast.ComposeDataType(ast.DataTypeMajorFixedBytes, 1), }, []Tuple{ {&Raw{Bytes: []byte{0x7f, 0xff}}}, @@ -2907,7 +2907,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(7, 1), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 1), }, []Tuple{}, ), @@ -2917,7 +2917,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 1), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 1), }, []Tuple{ {&Raw{Bytes: []byte{0x7f, 0xff}}}, @@ -2933,7 +2933,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue}, @@ -2942,7 +2942,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{}, ), @@ -2952,7 +2952,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {rawTrue}, @@ -2968,7 +2968,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(4, 2), + ast.ComposeDataType(ast.DataTypeMajorInt, 2), }, []Tuple{ {&Raw{Value: decimal.NewFromFloat(-32768)}}, @@ -2977,7 +2977,7 @@ func (s *instructionSuite) TestOpCast() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(7, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), }, []Tuple{}, ), @@ -3006,7 +3006,7 @@ func (s *instructionSuite) TestOpSort() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}, @@ -3022,7 +3022,7 @@ func (s *instructionSuite) TestOpSort() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{ {rawFalse, &Raw{Value: decimal.NewFromFloat(1)}}, @@ -3036,7 +3036,7 @@ func (s *instructionSuite) TestOpSort() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}, @@ -3059,7 +3059,7 @@ func (s *instructionSuite) TestOpSort() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}, @@ -3075,7 +3075,7 @@ func (s *instructionSuite) TestOpSort() { makeOperand( true, []ast.DataType{ - ast.ComposeDataType(2, 0), ast.ComposeDataType(4, 0), + ast.ComposeDataType(ast.DataTypeMajorBool, 0), ast.ComposeDataType(ast.DataTypeMajorUint, 1), }, []Tuple{ {rawTrue, &Raw{Value: decimal.NewFromFloat(0)}}, @@ -3089,7 +3089,7 @@ func (s *instructionSuite) TestOpSort() { makeOperand( false, []ast.DataType{ - ast.ComposeDataType(7, 0), ast.ComposeDataType(4, 0), ast.ComposeDataType(2, 0), + ast.ComposeDataType(ast.DataTypeMajorDynamicBytes, 0), ast.ComposeDataType(ast.DataTypeMajorInt, 0), ast.ComposeDataType(ast.DataTypeMajorBool, 0), }, []Tuple{ {&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(1)}, rawFalse}, diff --git a/core/vm/sqlvm/runtime/instructions_tmpl.go b/core/vm/sqlvm/runtime/instructions_tmpl.go index 22c6bef88..7c9df3d80 100644 --- a/core/vm/sqlvm/runtime/instructions_tmpl.go +++ b/core/vm/sqlvm/runtime/instructions_tmpl.go @@ -1,36 +1,242 @@ package runtime -import "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" +import ( + "bytes" + "fmt" + "go/format" + "os" + "strings" + "text/template" + + "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" +) type tmplData struct { - BinOpCollections []tmplTestCollection + BinOpCollections []*tmplTestCollection +} + +func (d *tmplData) process() (err error) { + for _, c := range d.BinOpCollections { + err = c.process() + if err != nil { + return + } + } + return } type tmplTestCollection struct { TestName string - Cases []tmplTestCase + Cases []*tmplTestCase OpFunc string } +func (c *tmplTestCollection) process() (err error) { + for _, c := range c.Cases { + err = c.process() + if err != nil { + return + } + } + return +} + type tmplTestCase struct { Name string OpCode string - Inputs []tmplOp - Output tmplOp + Inputs []*tmplOp + Output *tmplOp Error string } +func (c *tmplTestCase) process() (err error) { + for _, ic := range c.Inputs { + err = ic.process() + if err != nil { + return + } + } + + err = c.Output.process() + return +} + type tmplOp struct { Im bool - Metas []tmplOpMeta + Metas []*tmplOpMeta Data []string } +func (o *tmplOp) process() (err error) { + for i, r := range o.Data { + o.Data[i] = processRaw(r) + } + return +} + type tmplOpMeta struct { - Major ast.DataTypeMajor + Major string Minor ast.DataTypeMinor } +// RenderOpTest render op test to test file. +func RenderOpTest(output string) (err error) { + binOpT, err := template.New("binOp").Parse(binOpTmplStr) + if err != nil { + return + } + + b := new(bytes.Buffer) + + err = testData.process() + if err != nil { + fmt.Printf("data process error: %v\n", err) + return + } + + err = binOpT.Execute(b, testData) + if err != nil { + fmt.Printf("template render error: %v\n", err) + return + } + + src, err := format.Source(b.Bytes()) + if err != nil { + fmt.Printf( + `!!!!! +format source error: %v +note: render source for debugging +!!!!!`, err) + src = b.Bytes() + } + + f, err := os.Create(output) + if err != nil { + return + } + defer f.Close() + + _, err = f.Write(src) + return +} + +func processRaw(raw string) (dsRaw string) { + var ( + b = &strings.Builder{} + size = 1 + + err error + ) + + for i := 0; i < len(raw); i += size { + switch raw[i] { + case 'V': + size, err = writeV(b, raw, i) + case 'B': + size, err = writeB(b, raw, i) + case 'T': + _, err = b.WriteString("rawTrue") + size = 1 + case 'F': + _, err = b.WriteString("rawFalse") + size = 1 + default: + err = b.WriteByte(raw[i]) + size = 1 + } + + if err != nil { + panic(err) + } + } + dsRaw = b.String() + return +} + +func trim(raw string, i int) (size, j int) { + j = i + t := true + for t { + switch raw[j] { + case ' ', '\t', '\n': + case ':': + t = false + default: + panic(fmt.Errorf("trim '%v' fail. char: '%c'", raw, raw[j])) + } + j++ + size++ + } + return + +} + +func writeV(b *strings.Builder, raw string, i int) (size int, err error) { + _, err = b.WriteString("&Raw{Value: decimal.NewFromFloat(") + if err != nil { + return + } + + size, i = trim(raw, i+1) + +VLOOP: + for j := i; j < len(raw); j++ { + size++ + switch raw[j] { + case ',', '}': + break VLOOP + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '.', ' ': + b.WriteByte(raw[j]) + } + } + + _, err = b.WriteString(")}") + return +} + +func writeB(b *strings.Builder, raw string, i int) (size int, err error) { + _, err = b.WriteString("&Raw{Bytes: []byte") + if err != nil { + return + } + + size, i = trim(raw, i+1) + + str := false + level := 0 + +BLOOP: + for j := i; j < len(raw); j++ { + size++ + switch raw[j] { + case ',': + if level <= 0 { + break BLOOP + } + case '{': + level++ + case '}': + level-- + if level <= 0 { + break BLOOP + } + case '"': + if !str { + b.WriteByte(byte('(')) + str = true + } + } + b.WriteByte(raw[j]) + } + + if str { + b.WriteByte(byte(')')) + } + + err = b.WriteByte(byte('}')) + return +} + const binOpTmplStr = ` // Code generated - DO NOT EDIT. @@ -54,7 +260,7 @@ func (s *instructionSuite) Test{{.TestName}}() { makeOperand( {{.Im}}, []ast.DataType{ - {{range .Metas}}ast.ComposeDataType({{.Major}}, {{.Minor}}),{{end}} + {{range .Metas}}ast.ComposeDataType(ast.DataTypeMajor{{.Major}}, {{.Minor}}),{{end}} }, []Tuple{ {{range .Data}} {{.}},{{end}} @@ -66,7 +272,7 @@ func (s *instructionSuite) Test{{.TestName}}() { makeOperand( {{.Output.Im}}, []ast.DataType{ - {{range .Output.Metas}}ast.ComposeDataType({{.Major}}, {{.Minor}}),{{end}} + {{range .Output.Metas}}ast.ComposeDataType(ast.DataTypeMajor{{.Major}}, {{.Minor}}),{{end}} }, []Tuple{ {{range .Output.Data}} {{.}},{{end}} diff --git a/core/vm/sqlvm/runtime/instructions_tmpl_data.go b/core/vm/sqlvm/runtime/instructions_tmpl_data.go index 345d200ec..210adafed 100644 --- a/core/vm/sqlvm/runtime/instructions_tmpl_data.go +++ b/core/vm/sqlvm/runtime/instructions_tmpl_data.go @@ -1,1334 +1,858 @@ package runtime -import ( - "bytes" - "go/format" - "os" - "text/template" - - "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" -) - -// RenderOpTest render op test to test file. -func RenderOpTest(output string) (err error) { - binOpT, err := template.New("binOp").Parse(binOpTmplStr) - if err != nil { - return - } - - b := new(bytes.Buffer) - - err = binOpT.Execute(b, testData) - if err != nil { - return - } - - src, err := format.Source(b.Bytes()) - if err != nil { - return - } - - f, err := os.Create(output) - if err != nil { - return - } - defer f.Close() - - _, err = f.Write(src) - return -} - -var testData = tmplData{ - BinOpCollections: []tmplTestCollection{ +var testData = &tmplData{ + BinOpCollections: []*tmplTestCollection{ { TestName: "OpAdd", OpFunc: "opAdd", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "ADD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-2)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(10)}}", + "{V: 1, V: 2}", "{V: -1, V: -2}", "{V: 10, V: 10}", "{V: -10, V: 10}", }, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(3)}}", + "{V: 1, V: 2}", "{V: 1, V: 2}", "{V: -10, V: 10}", "{V: -10, V: 3}", }, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(4)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(20)}}", - "{&Raw{Value: decimal.NewFromFloat(-20)}, &Raw{Value: decimal.NewFromFloat(13)}}", + "{V: 2, V: 4}", "{V: 0, V: 0}", "{V: 0, V: 20}", "{V: -20, V: 13}", }, }, }, { Name: "Immediate", Error: "nil", OpCode: "ADD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 10, V: 10, V: 10}", "{V: -10, V: -10, V: -10}", "{V: -1, V: 2, V: 0}", }, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(-10)}}", + "{V: 1, V: -2, V: -10}", }, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(11)}, &Raw{Value: decimal.NewFromFloat(8)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(-9)}, &Raw{Value: decimal.NewFromFloat(-12)}, &Raw{Value: decimal.NewFromFloat(-20)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-10)}}", + "{V: 11, V: 8, V: 0}", "{V: -9, V: -12, V: -20}", "{V: 0, V: 0, V: -10}", }, }, }, { Name: "Immediate 2", Error: "nil", OpCode: "ADD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(-10)}}", + "{V: 1, V: -2, V: -10}", }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 10, V: 10, V: 10}", + "{V: -10, V: -10, V: -10}", + "{V: -1, V: 2, V: 0}", }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(11)}, &Raw{Value: decimal.NewFromFloat(8)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(-9)}, &Raw{Value: decimal.NewFromFloat(-12)}, &Raw{Value: decimal.NewFromFloat(-20)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-10)}}", + "{V: 11, V: 8, V: 0}", + "{V: -9, V: -12, V: -20}", + "{V: 0, V: 0, V: -10}", }, }, }, { Name: "Overflow - Immediate", Error: "errors.ErrorCodeOverflow", OpCode: "ADD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(127)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 127}", "{V: 1}", "{V: 1}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Overflow None Immediate", Error: "errors.ErrorCodeOverflow", OpCode: "ADD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(126)}}", - "{&Raw{Value: decimal.NewFromFloat(126)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 126}", "{V: 126}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}", "{V: 2}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Underflow - Immediate", Error: "errors.ErrorCodeUnderflow", OpCode: "ADD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-128)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -128}", "{V: -1}", "{V: -1}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -1}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Underflow None Immediate", Error: "errors.ErrorCodeUnderflow", OpCode: "ADD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-127)}}", - "{&Raw{Value: decimal.NewFromFloat(-127)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -127}", "{V: -127}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-2)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -1}", "{V: -2}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, }, }, // -- end of ADD { TestName: "OpSub", OpFunc: "opSub", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "SUB", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-2)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 2}", "{V: -1, V: -2}", "{V: 10, V: 10}", "{V: -10, V: 10}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(3)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 2}", "{V: 1, V: 2}", "{V: -10, V: 10}", "{V: 10, V: 3}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(-4)}}", - "{&Raw{Value: decimal.NewFromFloat(20)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(-20)}, &Raw{Value: decimal.NewFromFloat(7)}}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0}", "{V: -2, V: -4}", "{V: 20, V: 0}", "{V: -20, V: 7}"}, }, }, { Name: "Immediate", Error: "nil", OpCode: "SUB", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(0)}}", - }, + "{V: 10, V: 10, V: 10}", "{V: -10, V: -10, V: -10}", "{V: -1, V: 2, V: 0}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: -2, V: -10}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(9)}, &Raw{Value: decimal.NewFromFloat(12)}, &Raw{Value: decimal.NewFromFloat(20)}}", - "{&Raw{Value: decimal.NewFromFloat(-11)}, &Raw{Value: decimal.NewFromFloat(-8)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(4)}, &Raw{Value: decimal.NewFromFloat(10)}}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 9, V: 12, V: 20}", "{V: -11, V: -8, V: 0}", "{V: -2, V: 4, V: 10}"}, }, }, { Name: "Immediate 2", Error: "nil", OpCode: "SUB", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(-10)}}", + "{V: 1, V: -2, V: -10}", }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 10, V: 10, V: 10}", + "{V: -10, V: -10, V: -10}", + "{V: -1, V: 2, V: 0}", }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-9)}, &Raw{Value: decimal.NewFromFloat(-12)}, &Raw{Value: decimal.NewFromFloat(-20)}}", - "{&Raw{Value: decimal.NewFromFloat(11)}, &Raw{Value: decimal.NewFromFloat(8)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-4)}, &Raw{Value: decimal.NewFromFloat(-10)}}", + "{V: -9, V: -12, V: -20}", + "{V: 11, V: 8, V: 0}", + "{V: 2, V: -4, V: -10}", }, }, }, { Name: "Overflow - Immediate", Error: "errors.ErrorCodeOverflow", OpCode: "SUB", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(127)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 127}", "{V: 1}", "{V: 1}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -1}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Overflow None Immediate", Error: "errors.ErrorCodeOverflow", OpCode: "SUB", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(126)}}", - "{&Raw{Value: decimal.NewFromFloat(126)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 126}", "{V: 126}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-2)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -1}", "{V: -2}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Underflow - Immediate", Error: "errors.ErrorCodeUnderflow", OpCode: "SUB", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-128)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -128}", "{V: -1}", "{V: -1}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Underflow None Immediate", Error: "errors.ErrorCodeUnderflow", OpCode: "SUB", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-127)}}", - "{&Raw{Value: decimal.NewFromFloat(-127)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -127}", "{V: -127}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}", "{V: 2}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, }, }, // -- end of SUB { TestName: "OpMul", OpFunc: "opMul", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "MUL", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 1}", "{V: 2, V: -1}", "{V: -2, V: 10}", "{V: 10, V: -10}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 1}", "{V: 2, V: 1}", "{V: 2, V: -10}", "{V: 10, V: -10}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(4)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-4)}, &Raw{Value: decimal.NewFromFloat(-100)}}", - "{&Raw{Value: decimal.NewFromFloat(100)}, &Raw{Value: decimal.NewFromFloat(100)}}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 1}", "{V: 4, V: -1}", "{V: -4, V: -100}", "{V: 100, V: 100}"}, }, }, { Name: "Immediate", Error: "nil", OpCode: "MUL", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 10, V: 10, V: 10}", "{V: -10, V: -10, V: -10}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(0)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: -2, V: 0}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(-20)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(20)}, &Raw{Value: decimal.NewFromFloat(0)}}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 10, V: -20, V: 0}", "{V: -10, V: 20, V: 0}"}, }, }, { Name: "Immediate - 2", Error: "nil", OpCode: "MUL", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 1, V: -2, V: 0}", }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", + "{V: 10, V: 10, V: 10}", + "{V: -10, V: -10, V: -10}", }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(-20)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(20)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 10, V: -20, V: 0}", + "{V: -10, V: 20, V: 0}", }, }, }, { Name: "Overflow - Immediate", Error: "errors.ErrorCodeOverflow", OpCode: "MUL", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(127)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 127}", "{V: 1}", "{V: 1}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(2)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 2}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Overflow None Immediate", Error: "errors.ErrorCodeOverflow", OpCode: "MUL", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(126)}}", - "{&Raw{Value: decimal.NewFromFloat(126)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 126}", "{V: 126}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}", "{V: 2}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Underflow - Immediate", Error: "errors.ErrorCodeUnderflow", OpCode: "MUL", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-128)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -128}", "{V: -1}", "{V: -1}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(2)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 2}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Underflow None Immediate", Error: "errors.ErrorCodeUnderflow", OpCode: "MUL", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-127)}}", - "{&Raw{Value: decimal.NewFromFloat(-127)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -127}", "{V: -127}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}", "{V: 2}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, }, }, // -- end of MUL { TestName: "OpDiv", OpFunc: "opDiv", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "DIV", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-2)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 1}", "{V: 2, V: -1}", "{V: -2, V: 10}", "{V: 10, V: -10}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 1}", "{V: 2, V: 1}", "{V: 2, V: -10}", "{V: 10, V: -10}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 1}", "{V: 1, V: -1}", "{V: -1, V: -1}", "{V: 1, V: 1}"}, }, }, { Name: "Immediate", Error: "nil", OpCode: "DIV", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(13)}, &Raw{Value: decimal.NewFromFloat(13)}}", - "{&Raw{Value: decimal.NewFromFloat(-13)}, &Raw{Value: decimal.NewFromFloat(-13)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0}", "{V: 10, V: 10}", "{V: -10, V: -10}", "{V: 13, V: 13}", "{V: -13, V: -13}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-2)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 2, V: -2}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(5)}, &Raw{Value: decimal.NewFromFloat(-5)}}", - "{&Raw{Value: decimal.NewFromFloat(-5)}, &Raw{Value: decimal.NewFromFloat(5)}}", - "{&Raw{Value: decimal.NewFromFloat(6)}, &Raw{Value: decimal.NewFromFloat(-6)}}", - "{&Raw{Value: decimal.NewFromFloat(-6)}, &Raw{Value: decimal.NewFromFloat(6)}}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0}", "{V: 5, V: -5}", "{V: -5, V: 5}", "{V: 6, V: -6}", "{V: -6, V: 6}"}, }, }, { Name: "Immediate 2", Error: "nil", OpCode: "DIV", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(50)}, &Raw{Value: decimal.NewFromFloat(-50)}}", + "{V: 50, V: -50}", }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(9)}, &Raw{Value: decimal.NewFromFloat(9)}}", - "{&Raw{Value: decimal.NewFromFloat(-9)}, &Raw{Value: decimal.NewFromFloat(-9)}}", + "{V: 10, V: 10}", + "{V: -10, V: -10}", + "{V: 9, V: 9}", + "{V: -9, V: -9}", }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(5)}, &Raw{Value: decimal.NewFromFloat(-5)}}", - "{&Raw{Value: decimal.NewFromFloat(-5)}, &Raw{Value: decimal.NewFromFloat(5)}}", - "{&Raw{Value: decimal.NewFromFloat(5)}, &Raw{Value: decimal.NewFromFloat(-5)}}", - "{&Raw{Value: decimal.NewFromFloat(-5)}, &Raw{Value: decimal.NewFromFloat(5)}}", + "{V: 5, V: -5}", + "{V: -5, V: 5}", + "{V: 5, V: -5}", + "{V: -5, V: 5}", }, }, }, { Name: "DivideByZero Immediate", Error: "errors.ErrorCodeDividedByZero", OpCode: "DIV", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 10}", "{V: 10}", "{V: 10}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 0}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "DivideByZero None Immediate", Error: "errors.ErrorCodeDividedByZero", OpCode: "DIV", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 10}", "{V: 10}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}", "{V: 0}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Overflow - Immediate", Error: "errors.ErrorCodeOverflow", OpCode: "DIV", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(-128)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}", "{V: -128}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -1}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "Overflow None Immediate", Error: "errors.ErrorCodeOverflow", OpCode: "DIV", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-128)}}", - "{&Raw{Value: decimal.NewFromFloat(-128)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -128}", "{V: -128}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(-2)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: -1}", "{V: -2}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, }, }, // -- end of DIV { TestName: "OpMod", OpFunc: "opMod", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "MOD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-2)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-2)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 1}", "{V: 0, V: -1}", "{V: 2, V: -2}", "{V: 2, V: -2}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(3)}, &Raw{Value: decimal.NewFromFloat(3)}}", - "{&Raw{Value: decimal.NewFromFloat(-3)}, &Raw{Value: decimal.NewFromFloat(-3)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 1}", "{V: -1, V: -1}", "{V: 3, V: 3}", "{V: -3, V: -3}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-2)}}", - "{&Raw{Value: decimal.NewFromFloat(2)}, &Raw{Value: decimal.NewFromFloat(-2)}}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0}", "{V: 0, V: 0}", "{V: 2, V: -2}", "{V: 2, V: -2}"}, }, }, { Name: "Immediate", Error: "nil", OpCode: "MOD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(13)}, &Raw{Value: decimal.NewFromFloat(13)}}", - "{&Raw{Value: decimal.NewFromFloat(-13)}, &Raw{Value: decimal.NewFromFloat(-13)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0}", "{V: 10, V: 10}", "{V: -10, V: -10}", "{V: 13, V: 13}", "{V: -13, V: -13}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(3)}, &Raw{Value: decimal.NewFromFloat(-3)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 3, V: -3}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0}", "{V: 1, V: 1}", "{V: -1, V: -1}", "{V: 1, V: 1}", "{V: -1, V: -1}"}, }, }, { Name: "Immediate - 2", Error: "nil", OpCode: "MOD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(31)}, &Raw{Value: decimal.NewFromFloat(-31)}}", + "{V: 31, V: -31}", }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}, &Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(-10)}, &Raw{Value: decimal.NewFromFloat(-10)}}", - "{&Raw{Value: decimal.NewFromFloat(13)}, &Raw{Value: decimal.NewFromFloat(13)}}", - "{&Raw{Value: decimal.NewFromFloat(-13)}, &Raw{Value: decimal.NewFromFloat(-13)}}", + "{V: 10, V: 10}", + "{V: -10, V: -10}", + "{V: 13, V: 13}", + "{V: -13, V: -13}", }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(5)}, &Raw{Value: decimal.NewFromFloat(-5)}}", - "{&Raw{Value: decimal.NewFromFloat(5)}, &Raw{Value: decimal.NewFromFloat(-5)}}", + "{V: 1, V: -1}", + "{V: 1, V: -1}", + "{V: 5, V: -5}", + "{V: 5, V: -5}", }, }, }, { Name: "ModideByZero Immediate", Error: "errors.ErrorCodeDividedByZero", OpCode: "MOD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 10}", "{V: 10}", "{V: 10}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 0}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, { Name: "ModideByZero None Immediate", Error: "errors.ErrorCodeDividedByZero", OpCode: "MOD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(10)}}", - "{&Raw{Value: decimal.NewFromFloat(10)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 10}", "{V: 10}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}", "{V: 0}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, }, }, // -- end of MOD { TestName: "OpLt", OpFunc: "opLt", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "LT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 0, V: -1}", "{V: 1, V: 0, V: -1}", "{V: 1, V: 0, V: -1}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 1, V: 1}", "{V: 0, V: 0, V: 0}", "{V: -1, V: -1, V: -1}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawFalse, rawTrue, rawTrue}", - "{rawFalse, rawFalse, rawTrue}", - "{rawFalse, rawFalse, rawFalse}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{F, T, T}", "{F, F, T}", "{F, F, F}"}, }, }, { Name: "Immediate", Error: "nil", OpCode: "LT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 1, V: -1}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0, V: 0}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawFalse, rawFalse, rawTrue}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{F, F, T}"}, }, }, { Name: "Immediate - 2", Error: "nil", OpCode: "LT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 0, V: 0, V: 0}", }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", + "{V: 0, V: 1, V: -1}", }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawFalse, rawTrue, rawFalse}", + "{F, T, F}", }, }, }, @@ -1337,127 +861,85 @@ var testData = tmplData{ // -- end of LT { TestName: "OpGt", OpFunc: "opGt", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "GT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 0, V: -1}", "{V: 1, V: 0, V: -1}", "{V: 1, V: 0, V: -1}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 1, V: 1}", "{V: 0, V: 0, V: 0}", "{V: -1, V: -1, V: -1}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawFalse, rawFalse, rawFalse}", - "{rawTrue, rawFalse, rawFalse}", - "{rawTrue, rawTrue, rawFalse}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{F, F, F}", "{T, F, F}", "{T, T, F}"}, }, }, { Name: "Immediate", Error: "nil", OpCode: "GT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 1, V: -1}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0, V: 0}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawFalse, rawTrue, rawFalse}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{F, T, F}"}, }, }, { Name: "Immediate - 2", Error: "nil", OpCode: "GT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 0, V: 0, V: 0}", }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 0}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", + "{V: 0, V: 1, V: -1}", }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawFalse, rawFalse, rawTrue}", + "{F, F, T}", }, }, }, @@ -1466,88 +948,47 @@ var testData = tmplData{ // -- end of GT { TestName: "OpEq", OpFunc: "opEq", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "EQ", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 0, V: -1}", "{V: 1, V: 0, V: -1}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 0, V: -1}", "{V: 1, V: 1, V: 1}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue, rawTrue}", - "{rawTrue, rawFalse, rawFalse}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T, T}", "{T, F, F}"}, }, }, { Name: "Immediate", Error: "nil", OpCode: "EQ", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(-1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0, V: 0}", "{V: 0, V: 1, V: -1}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 0, V: 0, V: 0}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue, rawTrue}", - "{rawTrue, rawFalse, rawFalse}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T, T}", "{T, F, F}"}, }, }, }, @@ -1555,388 +996,266 @@ var testData = tmplData{ // -- end of EQ { TestName: "OpAnd", OpFunc: "opAnd", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "AND", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue}", - "{rawFalse, rawFalse}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T}", "{F, F}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawFalse}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, F}"}, }, }, { Name: "Immediate", Error: "nil", OpCode: "AND", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}"}, }, }, { Name: "Immediate - 2", Error: "nil", OpCode: "AND", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue, rawTrue}", + "{T, T}", }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", + "{T, F}", + "{F, T}", }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", + "{T, F}", + "{F, T}", }, }, }, { Name: "Invalid Data Type", Error: "errors.ErrorCodeInvalidDataType", OpCode: "AND", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, }, }, // -- end of AND { TestName: "OpOr", OpFunc: "opOr", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "OR", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue}", - "{rawFalse, rawFalse}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T}", "{F, F}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue}", - "{rawFalse, rawTrue}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T}", "{F, T}"}, }, }, { Name: "Immediate", Error: "nil", OpCode: "OR", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue}", - "{rawTrue, rawTrue}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T}", "{T, T}"}, }, }, { Name: "Immediate - 2", Error: "nil", OpCode: "OR", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue, rawTrue}", + "{T, T}", }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", + "{T, F}", + "{F, T}", }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue, rawTrue}", - "{rawTrue, rawTrue}", + "{T, T}", + "{T, T}", }, }, }, { Name: "Invalid Data Type", Error: "errors.ErrorCodeInvalidDataType", OpCode: "OR", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, }, }, // -- end of OR { TestName: "OpNot", OpFunc: "opNot", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "NOT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawFalse, rawTrue}", - "{rawTrue, rawFalse}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{F, T}", "{T, F}"}, }, }, { Name: "Errors Invalid Data Type", Error: "errors.ErrorCodeInvalidDataType", OpCode: "NOT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}}, + Data: []string{"{V: 1}"}, }, }, - Output: tmplOp{}, + Output: &tmplOp{}, }, }, }, // -- end of NOT { TestName: "OpUnion", OpFunc: "opUnion", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "UNION", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue}", - "{rawFalse, rawFalse}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T}", "{F, F}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawFalse, rawFalse}", - "{rawFalse, rawTrue}", - "{rawTrue, rawFalse}", - "{rawTrue, rawTrue}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{F, F}", "{F, T}", "{T, F}", "{T, T}"}, }, }, }, @@ -1944,46 +1263,26 @@ var testData = tmplData{ // -- end of UNION { TestName: "OpIntxn", OpFunc: "opIntxn", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate", Error: "nil", OpCode: "INTXN", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - "{rawTrue, rawTrue}", - "{rawFalse, rawFalse}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}", "{T, T}", "{F, F}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawTrue}", - "{rawFalse, rawFalse}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, T}", "{F, F}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawFalse, rawFalse}", - "{rawTrue, rawTrue}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{F, F}", "{T, T}"}, }, }, }, @@ -1991,128 +1290,118 @@ var testData = tmplData{ // -- end of INTXN { TestName: "OpLike", OpFunc: "opLike", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: `Like %\\%b% escape \\`, // \\ is raw string escape for \ Error: "nil", OpCode: "LIKE", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "DynamicBytes", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("a%bcdefg")}, &Raw{Bytes: []byte("gfedcba")}}`, + `{B: "a%bcdefg", B: "gfedcba"}`, }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, }, - Data: []string{`{&Raw{Bytes: []byte("%\\%b%")}}`}, + Data: []string{`{B: "%\\%b%"}`}, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, }, - Data: []string{`{&Raw{Bytes: []byte("\\")}}`}, + Data: []string{`{B: "\\"}`}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}"}, }, }, { Name: `Like t1 escape t2`, Error: "nil", OpCode: "LIKE", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("a%bcdefg")}}`, - `{&Raw{Bytes: []byte("gfedcba")}}`, + `{B: "a%bcdefg"}`, + `{B: "gfedcba"}`, }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("%\\%b%")}}`, - `{&Raw{Bytes: []byte("_fed%")}}`, + `{B: "%\\%b%"}`, + `{B: "_fed%"}`, }, }, { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("\\")}}`, - `{&Raw{Bytes: []byte("")}}`, + `{B: "\\"}`, + `{B: ""}`, }, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue}", - "{rawTrue}", + "{T}", + "{T}", }, }, }, { Name: `Like with valid and invalid UTF8`, Error: "nil", OpCode: "LIKE", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "DynamicBytes", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte{226, 40, 161, 228, 189, 160, 229, 165, 189}}, &Raw{Bytes: []byte("gfedcba")}}`, + `{B: {226, 40, 161, 228, 189, 160, 229, 165, 189}, B: "gfedcba"}`, // "\xe2(\xa1你好" }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte{37, 228, 189, 160, 37}}}`, + `{B: {37, 228, 189, 160, 37}}`, // "%你%" }, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}"}, }, }, }, @@ -2120,85 +1409,62 @@ var testData = tmplData{ // -- end of LIKE { TestName: "OpZip", OpFunc: "opZip", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "Zip two array", Error: "nil", OpCode: "ZIP", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - }, - Data: []string{ - `{&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}}`, - `{&Raw{Bytes: []byte("abcdefg-2")}, &Raw{Bytes: []byte("gfedcba-2")}}`, - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "DynamicBytes", Minor: 0}, {Major: "DynamicBytes", Minor: 0}}, + Data: []string{`{B: "abcdefg-1", B: "gfedcba-1"}`, `{B: "abcdefg-2", B: "gfedcba-2"}`}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, rawTrue}", - "{&Raw{Value: decimal.NewFromFloat(2)}, rawFalse}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{V: 1, T}", "{V: 2, F}"}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "DynamicBytes", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}`, - `{&Raw{Bytes: []byte("abcdefg-2")}, &Raw{Bytes: []byte("gfedcba-2")}, &Raw{Value: decimal.NewFromFloat(2)}, rawFalse}`, + `{B: "abcdefg-1", B: "gfedcba-1", V: 1, T}`, + `{B: "abcdefg-2", B: "gfedcba-2", V: 2, F}`, }, }, }, { Name: "Zip immediate", Error: "nil", OpCode: "ZIP", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - }, - Data: []string{ - `{&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}}`, - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "DynamicBytes", Minor: 0}, {Major: "DynamicBytes", Minor: 0}}, + Data: []string{`{B: "abcdefg-1", B: "gfedcba-1"}`}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, rawTrue}", - "{&Raw{Value: decimal.NewFromFloat(2)}, rawFalse}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{V: 1, T}", "{V: 2, F}"}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "DynamicBytes", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}`, - `{&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(2)}, rawFalse}`, + `{B: "abcdefg-1", B: "gfedcba-1", V: 1, T}`, + `{B: "abcdefg-1", B: "gfedcba-1", V: 2, F}`, }, }, }, @@ -2207,45 +1473,34 @@ var testData = tmplData{ // -- end of ZIP { TestName: "OpField", OpFunc: "opField", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "Retrieve 2nd,3rd column", Error: "nil", OpCode: "FIELD", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "DynamicBytes", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}`, - `{&Raw{Bytes: []byte("abcdefg-2")}, &Raw{Bytes: []byte("gfedcba-2")}, &Raw{Value: decimal.NewFromFloat(2)}, rawFalse}`, + `{B: "abcdefg-1", B: "gfedcba-1", V: 1, T}`, + `{B: "abcdefg-2", B: "gfedcba-2", V: 2, F}`, }, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(2)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 2}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - `{&Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}}`, - `{&Raw{Bytes: []byte("gfedcba-2")}, &Raw{Value: decimal.NewFromFloat(2)}}`, - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "DynamicBytes", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{`{B: "gfedcba-1", V: 1}`, `{B: "gfedcba-2", V: 2}`}, }, }, }, @@ -2253,47 +1508,35 @@ var testData = tmplData{ // -- end of FIELD { TestName: "OpPrune", OpFunc: "opPrune", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "Prune 2nd,4th,5th column", Error: "nil", OpCode: "PRUNE", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "DynamicBytes", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Bytes: []byte("gfedcba-1")}, &Raw{Value: decimal.NewFromFloat(1)}, rawFalse, rawTrue}`, - `{&Raw{Bytes: []byte("abcdefg-2")}, &Raw{Bytes: []byte("gfedcba-2")}, &Raw{Value: decimal.NewFromFloat(2)}, rawTrue, rawFalse}`, + `{B: "abcdefg-1", B: "gfedcba-1", V: 1, F, T}`, + `{B: "abcdefg-2", B: "gfedcba-2", V: 2, T, F}`, }, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(1)}, &Raw{Value: decimal.NewFromFloat(3)}, &Raw{Value: decimal.NewFromFloat(4)}}", - }, + Im: true, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{"{V: 1, V: 3, V: 4}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - `{&Raw{Bytes: []byte("abcdefg-1")}, &Raw{Value: decimal.NewFromFloat(1)}}`, - `{&Raw{Bytes: []byte("abcdefg-2")}, &Raw{Value: decimal.NewFromFloat(2)}}`, - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "DynamicBytes", Minor: 0}, {Major: "Int", Minor: 0}}, + Data: []string{`{B: "abcdefg-1", V: 1}`, `{B: "abcdefg-2", V: 2}`}, }, }, }, @@ -2301,47 +1544,26 @@ var testData = tmplData{ // -- end of PRUNE { TestName: "OpFilter", OpFunc: "opFilter", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "Filter first 2 rows", Error: "nil", OpCode: "FILTER", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - "{rawTrue, rawTrue}", - "{rawFalse, rawFalse}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}", "{T, T}", "{F, F}"}, }, { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue}", - "{rawTrue}", - "{rawFalse}", - "{rawFalse}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}}, + Data: []string{"{T}", "{T}", "{F}", "{F}"}, }, }, - Output: tmplOp{ - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, - }, - Data: []string{ - "{rawTrue, rawFalse}", - "{rawFalse, rawTrue}", - }, + Output: &tmplOp{ + Im: false, + Metas: []*tmplOpMeta{{Major: "Bool", Minor: 0}, {Major: "Bool", Minor: 0}}, + Data: []string{"{T, F}", "{F, T}"}, }, }, }, @@ -2349,467 +1571,451 @@ var testData = tmplData{ // -- end of FILTER { TestName: "OpCast", OpFunc: "opCast", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "None Immediate - int", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 1}, // int16 -> int8 - {Major: ast.DataTypeMajorInt, Minor: 1}, // int16 -> int24 - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(127)}, &Raw{Value: decimal.NewFromFloat(127)}}", - "{&Raw{Value: decimal.NewFromFloat(-128)}, &Raw{Value: decimal.NewFromFloat(-128)}}", + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 1}, // int16 -> int8 + {Major: "Int", Minor: 1}, // int16 -> int24 }, + Data: []string{"{V: 127, V: 127}", "{V: -128, V: -128}"}, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 2}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 2}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 2}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(127)}, &Raw{Value: decimal.NewFromFloat(127)}}", - "{&Raw{Value: decimal.NewFromFloat(-128)}, &Raw{Value: decimal.NewFromFloat(-128)}}", + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 0}, + {Major: "Int", Minor: 2}, }, + Data: []string{"{V: 127, V: 127}", "{V: -128, V: -128}"}, }, }, { Name: "None Immediate - int2", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 1}, // int16 -> uint16 - {Major: ast.DataTypeMajorInt, Minor: 1}, // int16 -> uint16 + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 1}, // int16 -> uint16 + {Major: "Int", Minor: 1}, // int16 -> uint16 }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(-32768)}}", + "{V: 32767, V: -32768}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorUint, Minor: 1}, - {Major: ast.DataTypeMajorUint, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "Uint", Minor: 1}, + {Major: "Uint", Minor: 1}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorUint, Minor: 1}, - {Major: ast.DataTypeMajorUint, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "Uint", Minor: 1}, + {Major: "Uint", Minor: 1}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(32768)}}", + "{V: 32767, V: 32768}", }, }, }, { Name: "None Immediate - int3", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 1}, // int16 -> bool - {Major: ast.DataTypeMajorInt, Minor: 1}, // int16 -> bool + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 1}, // int16 -> bool + {Major: "Int", Minor: 1}, // int16 -> bool }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(-32768)}}", - "{&Raw{Value: decimal.NewFromFloat(0)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 32767, V: -32768}", + "{V: 0, V: 0}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue, rawTrue}", "{rawFalse, rawFalse}", + "{T, T}", "{F, F}", }, }, }, { Name: "None Immediate - int4", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 1}, // int16 -> bytes16 - {Major: ast.DataTypeMajorInt, Minor: 1}, // int16 -> address + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 1}, // int16 -> bytes16 + {Major: "Int", Minor: 1}, // int16 -> address }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(-32768)}}", + "{V: 32767, V: -32768}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, - {Major: ast.DataTypeMajorAddress, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "FixedBytes", Minor: 1}, + {Major: "Address", Minor: 0}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, - {Major: ast.DataTypeMajorAddress, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "FixedBytes", Minor: 1}, + {Major: "Address", Minor: 0}, }, Data: []string{ - "{&Raw{Bytes: []byte{0x7f, 0xff}}, &Raw{Bytes: []byte{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0x80,0x00}}}", + "{B: {0x7f, 0xff}, B: {255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0x80,0x00}}", }, }, }, { Name: "None Immediate - uint", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorUint, Minor: 1}, // uint16 -> uint8 - {Major: ast.DataTypeMajorUint, Minor: 1}, // uint16 -> uint24 - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(128)}, &Raw{Value: decimal.NewFromFloat(128)}}", + Metas: []*tmplOpMeta{ + {Major: "Uint", Minor: 1}, // uint16 -> uint8 + {Major: "Uint", Minor: 1}, // uint16 -> uint24 }, + Data: []string{"{V: 128, V: 128}"}, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorUint, Minor: 0}, - {Major: ast.DataTypeMajorUint, Minor: 2}, + Metas: []*tmplOpMeta{ + {Major: "Uint", Minor: 0}, + {Major: "Uint", Minor: 2}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorUint, Minor: 0}, - {Major: ast.DataTypeMajorUint, Minor: 2}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(128)}, &Raw{Value: decimal.NewFromFloat(128)}}", + Metas: []*tmplOpMeta{ + {Major: "Uint", Minor: 0}, + {Major: "Uint", Minor: 2}, }, + Data: []string{"{V: 128, V: 128}"}, }, }, { Name: "None Immediate - uint2", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorUint, Minor: 1}, // uint16 -> int16 - {Major: ast.DataTypeMajorUint, Minor: 1}, // uint16 -> byte16 + Metas: []*tmplOpMeta{ + {Major: "Uint", Minor: 1}, // uint16 -> int16 + {Major: "Uint", Minor: 1}, // uint16 -> byte16 }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(32768)}}", + "{V: 32767, V: 32768}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 1}, - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 1}, + {Major: "FixedBytes", Minor: 1}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 1}, - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 1}, + {Major: "FixedBytes", Minor: 1}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Bytes: []byte{0x80,0x00}}}", + "{V: 32767, B: {0x80, 0x00}}", }, }, }, { Name: "None Immediate - uint3", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorUint, Minor: 1}, // uint16 -> bool - {Major: ast.DataTypeMajorUint, Minor: 1}, // uint16 -> bool + Metas: []*tmplOpMeta{ + {Major: "Uint", Minor: 1}, // uint16 -> bool + {Major: "Uint", Minor: 1}, // uint16 -> bool }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 32767, V: 0}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue, rawFalse}", + "{T, F}", }, }, }, { Name: "None Immediate - uint4", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorUint, Minor: 1}, // uint16 -> bytes - {Major: ast.DataTypeMajorUint, Minor: 1}, // uint16 -> bytes + Metas: []*tmplOpMeta{ + {Major: "Uint", Minor: 1}, // uint16 -> bytes + {Major: "Uint", Minor: 1}, // uint16 -> bytes }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(0)}}", + "{V: 32767, V: 0}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "FixedBytes", Minor: 1}, + {Major: "FixedBytes", Minor: 1}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "FixedBytes", Minor: 1}, + {Major: "FixedBytes", Minor: 1}, }, Data: []string{ - "{&Raw{Bytes: []byte{0x7f, 0xff}}, &Raw{Bytes: []byte{0x00, 0x00}}}", + "{B: {0x7f, 0xff}, B: {0x00, 0x00}}", }, }, }, { Name: "None Immediate - uint5", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorUint, Minor: 1}, // uint16 -> address + Metas: []*tmplOpMeta{ + {Major: "Uint", Minor: 1}, // uint16 -> address }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}}", + "{V: 32767}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorAddress, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "Address", Minor: 1}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorAddress, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "Address", Minor: 1}, }, Data: []string{ - "{&Raw{Bytes: []byte{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x7f,0xff}}}", + "{B: {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x7f,0xff}}", }, }, }, { Name: "None Immediate - bytes", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, // byte16 -> byte8 - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, // byte16 -> byte24 + Metas: []*tmplOpMeta{ + {Major: "FixedBytes", Minor: 1}, // byte16 -> byte8 + {Major: "FixedBytes", Minor: 1}, // byte16 -> byte24 }, Data: []string{ - "{&Raw{Bytes: []byte{0xff, 0xff}}, &Raw{Bytes: []byte{0xff, 0xff}}}", + "{B: {0xff, 0xff}, B: {0xff, 0xff}}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorFixedBytes, Minor: 0}, - {Major: ast.DataTypeMajorFixedBytes, Minor: 2}, + Metas: []*tmplOpMeta{ + {Major: "FixedBytes", Minor: 0}, + {Major: "FixedBytes", Minor: 2}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorFixedBytes, Minor: 0}, - {Major: ast.DataTypeMajorFixedBytes, Minor: 2}, + Metas: []*tmplOpMeta{ + {Major: "FixedBytes", Minor: 0}, + {Major: "FixedBytes", Minor: 2}, }, Data: []string{ - "{&Raw{Bytes: []byte{0xff}}, &Raw{Bytes: []byte{0xff, 0xff, 0x00}}}", + "{B: {0xff}, B: {0xff, 0xff, 0x00}}", }, }, }, { Name: "None Immediate - bytes2", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, // byte16 -> int16 - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, // byte16 -> uint16 + Metas: []*tmplOpMeta{ + {Major: "FixedBytes", Minor: 1}, // byte16 -> int16 + {Major: "FixedBytes", Minor: 1}, // byte16 -> uint16 }, Data: []string{ - "{&Raw{Bytes: []byte{0x7f, 0xff}}, &Raw{Bytes: []byte{0x80, 0x00}}}", + "{B: {0x7f, 0xff}, B: {0x80, 0x00}}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 1}, - {Major: ast.DataTypeMajorUint, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 1}, + {Major: "Uint", Minor: 1}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 1}, - {Major: ast.DataTypeMajorUint, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "Int", Minor: 1}, + {Major: "Uint", Minor: 1}, }, Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(32767)}, &Raw{Value: decimal.NewFromFloat(32768)}}", + "{V: 32767, V: 32768}", }, }, }, { Name: "None Immediate - bytes3", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorFixedBytes, Minor: 1}, // byte16 -> dyn + Metas: []*tmplOpMeta{ + {Major: "FixedBytes", Minor: 1}, // byte16 -> dyn }, Data: []string{ - "{&Raw{Bytes: []byte{0x7f, 0xff}}}", + "{B: {0x7f, 0xff}}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 1}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 1}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 1}, }, Data: []string{ - "{&Raw{Bytes: []byte{0x7f, 0xff}}}", + "{B: {0x7f, 0xff}}", }, }, }, { Name: "Same type", Error: "nil", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue}", + "{T}", }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, }, Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, }, Data: []string{ - "{rawTrue}", + "{T}", }, }, }, { Name: "Error Invalid Type", Error: "errors.ErrorCodeInvalidCastType", OpCode: "CAST", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { - Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorInt, Minor: 2}, - }, - Data: []string{ - "{&Raw{Value: decimal.NewFromFloat(-32768)}}", - }, + Im: false, + Metas: []*tmplOpMeta{{Major: "Int", Minor: 2}}, + Data: []string{"{V: -32768}"}, }, { - Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - }, - Data: []string{}, + Im: true, + Metas: []*tmplOpMeta{{Major: "DynamicBytes", Minor: 0}}, + Data: []string{}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{}, + Metas: []*tmplOpMeta{}, Data: []string{}, }, }, @@ -2818,112 +2024,104 @@ var testData = tmplData{ // -- end of CAST { TestName: "OpSort", OpFunc: "opSort", - Cases: []tmplTestCase{ + Cases: []*tmplTestCase{ { Name: "Multi-column sorting", Error: "nil", OpCode: "SORT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(2)}, rawTrue}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(3)}, rawTrue}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(1)}, rawFalse}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(2)}, rawFalse}`, - `{&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, + `{B: "c", V: 1, T}`, + `{B: "b", V: 2, T}`, + `{B: "a", V: 3, T}`, + `{B: "a", V: 1, F}`, + `{B: "b", V: 2, F}`, + `{B: "c", V: 3, F}`, + `{B: "b", V: 3, F}`, + `{B: "a", V: 3, F}`, }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{rawFalse, &Raw{Value: decimal.NewFromFloat(1)}}", - "{rawTrue, &Raw{Value: decimal.NewFromFloat(2)}}", - "{rawFalse, &Raw{Value: decimal.NewFromFloat(0)}}", + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Uint", Minor: 1}, }, + Data: []string{"{F, V: 1}", "{T, V: 2}", "{F, V: 0}"}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(3)}, rawTrue}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(2)}, rawFalse}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(2)}, rawTrue}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(1)}, rawFalse}`, - `{&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}`, + `{B: "c", V: 3, F}`, + `{B: "b", V: 3, F}`, + `{B: "a", V: 3, F}`, + `{B: "a", V: 3, T}`, + `{B: "b", V: 2, F}`, + `{B: "b", V: 2, T}`, + `{B: "a", V: 1, F}`, + `{B: "c", V: 1, T}`, }, }, }, { Name: "Multi-column sorting - 2", Error: "nil", OpCode: "SORT", - Inputs: []tmplOp{ + Inputs: []*tmplOp{ { Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(2)}, rawTrue}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(3)}, rawTrue}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(1)}, rawFalse}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(2)}, rawFalse}`, - `{&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, + `{B: "c", V: 1, T}`, + `{B: "b", V: 2, T}`, + `{B: "a", V: 3, T}`, + `{B: "a", V: 1, F}`, + `{B: "b", V: 2, F}`, + `{B: "c", V: 3, F}`, + `{B: "b", V: 3, F}`, + `{B: "a", V: 3, F}`, }, }, { Im: true, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorBool, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - }, - Data: []string{ - "{rawTrue, &Raw{Value: decimal.NewFromFloat(0)}}", - "{rawTrue, &Raw{Value: decimal.NewFromFloat(1)}}", - "{rawFalse, &Raw{Value: decimal.NewFromFloat(2)}}", + Metas: []*tmplOpMeta{ + {Major: "Bool", Minor: 0}, + {Major: "Uint", Minor: 1}, }, + Data: []string{"{T, V: 0}", "{T, V: 1}", "{F, V: 2}"}, }, }, - Output: tmplOp{ + Output: &tmplOp{ Im: false, - Metas: []tmplOpMeta{ - {Major: ast.DataTypeMajorDynamicBytes, Minor: 0}, - {Major: ast.DataTypeMajorInt, Minor: 0}, - {Major: ast.DataTypeMajorBool, Minor: 0}, + Metas: []*tmplOpMeta{ + {Major: "DynamicBytes", Minor: 0}, + {Major: "Int", Minor: 0}, + {Major: "Bool", Minor: 0}, }, Data: []string{ - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(1)}, rawFalse}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(3)}, rawTrue}`, - `{&Raw{Bytes: []byte("a")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(2)}, rawTrue}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(2)}, rawFalse}`, - `{&Raw{Bytes: []byte("b")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, - `{&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(1)}, rawTrue}`, - `{&Raw{Bytes: []byte("c")}, &Raw{Value: decimal.NewFromFloat(3)}, rawFalse}`, + `{B: "a", V: 1, F}`, + `{B: "a", V: 3, T}`, + `{B: "a", V: 3, F}`, + `{B: "b", V: 2, T}`, + `{B: "b", V: 2, F}`, + `{B: "b", V: 3, F}`, + `{B: "c", V: 1, T}`, + `{B: "c", V: 3, F}`, }, }, }, |