diff options
author | Meng-Ying Yang <garfield@dexon.org> | 2019-03-07 10:35:59 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-03-26 17:48:22 +0800 |
commit | 422626ae1dc0e46c6a209d90b0c895c9d4e4957d (patch) | |
tree | 0f774270a20048a395988c501cdecbbd75839d8c /core/vm/sqlvm/ast/types.go | |
parent | 677a283a21caa9e545663fcaa00c5f6a4df4b5ca (diff) | |
download | dexon-422626ae1dc0e46c6a209d90b0c895c9d4e4957d.tar dexon-422626ae1dc0e46c6a209d90b0c895c9d4e4957d.tar.gz dexon-422626ae1dc0e46c6a209d90b0c895c9d4e4957d.tar.bz2 dexon-422626ae1dc0e46c6a209d90b0c895c9d4e4957d.tar.lz dexon-422626ae1dc0e46c6a209d90b0c895c9d4e4957d.tar.xz dexon-422626ae1dc0e46c6a209d90b0c895c9d4e4957d.tar.zst dexon-422626ae1dc0e46c6a209d90b0c895c9d4e4957d.zip |
core: vm: sqlvm: add shared variables (#228)
Diffstat (limited to 'core/vm/sqlvm/ast/types.go')
-rw-r--r-- | core/vm/sqlvm/ast/types.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/core/vm/sqlvm/ast/types.go b/core/vm/sqlvm/ast/types.go index 19bcf6314..1928d2338 100644 --- a/core/vm/sqlvm/ast/types.go +++ b/core/vm/sqlvm/ast/types.go @@ -7,6 +7,7 @@ import ( "github.com/shopspring/decimal" "github.com/dexon-foundation/dexon/common" + dec "github.com/dexon-foundation/dexon/core/vm/sqlvm/common/decimal" se "github.com/dexon-foundation/dexon/core/vm/sqlvm/errors" ) @@ -20,11 +21,6 @@ type decPair struct { } var ( - decOne = decimal.New(1, 0) - - decFalse = decimal.Zero - decTrue = decimal.New(1, 0) - decPairMap = make(map[DataType]decPair) ) @@ -260,18 +256,18 @@ func GetMinMax(dt DataType) (min, max decimal.Decimal, err error) { major, minor := DecomposeDataType(dt) switch major { case DataTypeMajorBool: - min, max = decFalse, decTrue + min, max = dec.False, dec.True case DataTypeMajorAddress: bigUMax := new(big.Int).Lsh(bigIntOne, common.AddressLength*8) - max = decimal.NewFromBigInt(bigUMax, 0).Sub(decOne) + max = decimal.NewFromBigInt(bigUMax, 0).Sub(dec.One) case DataTypeMajorInt: bigMax := new(big.Int).Lsh(bigIntOne, (uint(minor)+1)*8-1) decMax := decimal.NewFromBigInt(bigMax, 0) - min, max = decMax.Neg(), decMax.Sub(decOne) + min, max = decMax.Neg(), decMax.Sub(dec.One) case DataTypeMajorUint, DataTypeMajorFixedBytes: bigUMax := new(big.Int).Lsh(bigIntOne, (uint(minor)+1)*8) - max = decimal.NewFromBigInt(bigUMax, 0).Sub(decOne) + max = decimal.NewFromBigInt(bigUMax, 0).Sub(dec.One) default: err = ErrGetMinMax return |