aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/sqlvm/ast/types.go
Commit message (Collapse)AuthorAgeFilesLines
* core: vm: sqlvm: runtime: opLoad load fixed bytes and address in bytesJhih-Ming Huang2019-04-031-7/+2
| | | | | To satisfy the latest spec, the data of type of address and fixed bytes will be stored in bytes instead of decimal value.
* vm: sqlvm: refine after updating dexon-foundation/decimalyenlin.lai2019-04-031-10/+3
| | | | | | Refine behaviors: 1. Check decimal.NewFromString by type instead of string compare. 2. Use Rescale in DecimalEncode.
* misc: replace shopspring/decimal with our forkyenlin.lai2019-04-031-1/+1
|
* core: vm: sqlvm: support SQL three-valued logic on ASTTing-Wei Lan2019-03-291-0/+95
| | | | | | We make the zero value invalid by design. Users must be aware of the difference between SQL boolean and Go boolean and initialize it explicitly.
* core: vm: sqlvm: ast: rename DataTypeUnknown to DataTypePendingTing-Wei Lan2019-03-291-3/+7
| | | | | | | | SQL uses three-valued logic which includes an unknown state. To prevent the reader of the code from confusing the unknown value with the unknown data type defined here, we rename 'unknown' data type to 'pending' because it is intended to be used by nodes whose type has not been determined.
* core: vm: sqlvm: ast: don't calculate min and max values on demandTing-Wei Lan2019-03-291-40/+61
| | | | | | It is unsafe to write a map concurrently. Even if it is unlikely for us to call it from multiple threads, it is better to avoid providing an thread-unsafe API when it is possible.
* core: vm: sqlvm: ast: make DataTypeDecode a method of DataTypeTing-Wei Lan2019-03-291-21/+16
| | | | | | | | Since we have dropped DataTypeEncode in favor of GetType method of TypeNode, rename DataTypeDecode to GetNode and make it a method. Drop unnecessary zero checks because we don't care minor bytes when there is only one type belong to a category.
* core: vm: sqlvm: ast: return error messages from GetTypeTing-Wei Lan2019-03-291-12/+0
| | | | | | | | To allow callers to provide precise error messages, return an error message in addition to an error code from GetType of TypeNode. Drop DataTypeEncode because it is never used by any code and it has become a simple wrapper of GetType.
* core: vm: sqlvm: schema: move methods of DataTypeMajorTing-Wei Lan2019-03-291-10/+10
| | | | We will add more methods to DataType.
* core: vm: sqlvm: ast: implement decimal to uint64Jhih-Ming Huang2019-03-261-8/+25
| | | | | deciaml.IntPart() returns int64, so we have to implement a function to convert deciaml to uint64 for reading primary id from Raw.
* core: vm: sqlvm: ast: add size func and move error code to errors.goJhih-Ming Huang2019-03-261-16/+32
| | | | Move error code to errors.go, and implement Size method for column field.
* core: vm: sqlvm: types: fix encode bug when exponent is negative (#270)yenlinlai2019-03-261-2/+8
| | | | | It is possible that the number to encode is produced by arithmetic operations and has negative exponent even when it is an integer. Properly handle this case and modify test cases to check it.
* core: vm: sqlvm: add shared variables (#228)Meng-Ying Yang2019-03-261-9/+5
|
* core: vm: sqlvm: ast: use non-empty interfaces in DataType{En,De}codeTing-Wei Lan2019-03-261-62/+16
| | | | | | | In addition to changes required to move DataTypeEncode and DataTypeDecode to use TypeNode interface, this commit also unifies the meaning of 'Size' field in 'FixedBytesTypeNode'. It always counts the length in bytes now.
* core: vm: sqlvm: introduce interfaces for AST nodesTing-Wei Lan2019-03-261-0/+8
| | | | | | | | | In order to make our AST easier and safer to use, all declarations with empty interface type are now removed. This changes also makes it possible to traverse the AST without using reflection or understanding what each type means because all AST nodes have at least one common interface.
* core: vm: sqlvm: types support data rangeMeng-Ying Yang2019-03-261-0/+46
| | | | | The data range is deterministic for specific type, `GetMinMax` is helper function to generate min, max value for clients.
* core: vm: sqlvm: add schema define and implement rlp serializationwmin02019-03-261-13/+15
| | | | Implement schema struct and handle its rlp serialization.
* core: vm: sqlvm: ast: add encoder/decoder for decimal to byteswmin02019-03-261-0/+272
Add encoder/decoder to convert between decimal and bytes. Also handle issues below. * Signed & Unsigned * Padding * Floating point of fixed