aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/sqlvm/ast
Commit message (Collapse)AuthorAgeFilesLines
* core: vm: sqlvm: ast: implement decimal to uint64Jhih-Ming Huang2019-05-062-8/+50
| | | | | 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-05-062-19/+58
| | | | 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-05-062-4/+10
| | | | | 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: make a common interface for statementsTing-Wei Lan2019-05-061-6/+34
| | | | | | | So Parse now returns a []ast.StmtNode instead of a generic []ast.Node, which should be clearer on what the return value looks like. This also adds a field recording the verb use to identify the statement in order to provide better error messages.
* core: vm: sqlvm: add shared variables (#228)Meng-Ying Yang2019-05-062-11/+8
|
* core: vm: sqlvm: add ESCAPE grammarwmin02019-05-061-0/+35
| | | | | Provide ESCAPE grammar for specifying escape character in like pattern matching.
* core: vm: sqlvm: limit the depth of AST to 1024Ting-Wei Lan2019-05-061-0/+5
| | | | | Since we traverse an AST by calling functions recursively, we have to protect the parser by limiting the depth of an AST.
* core: vm: sqlvm: ast: use non-empty interfaces in DataType{En,De}codeTing-Wei Lan2019-05-062-80/+34
| | | | | | | 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: ast: handle error in AST printerTing-Wei Lan2019-05-061-28/+52
| | | | Catch the error reported by fmt.Fprintf and report it to the caller.
* core: vm: sqlvm: fill source code position in AST nodesTing-Wei Lan2019-05-062-38/+111
| | | | | | | | | | | | | | | Now all AST nodes should have position information recorded during parsing. These fields are intended to be used to report errors and make debugging easier. However, precise location of each token is currently unavailable. It can be done in the future if it becomes necessary. To make it easier to traverse an AST, GetChildren is modified to skip nil nodes in the output. This means callers of GetChildren don't have to check for nil in returned slices. AST printer is modified to print the position and the corresponding source code token. A few special handling for interfaces are removed because reflection works better for structs.
* core: vm: sqlvm: ast: use pointer receiversTing-Wei Lan2019-05-061-89/+89
| | | | | | | Since all nodes must be declared as pointers to satisfy the interface, it is no longer meaningful to use value receivers. It should make the code look more consistent and reduce the amount of memory copying during function calls because these structs takes at least 8 bytes.
* core: vm: sqlvm: ast: remove pointer indicator in printer outputTing-Wei Lan2019-05-061-5/+4
| | | | | | Since our 'Node' interface includes methods which must be implemented with pointer receivers, all AST nodes are now referenced with pointers and the '*' pointer indicator is no longer useful.
* core: vm: sqlvm: check if a number is a valid addressTing-Wei Lan2019-05-062-23/+5
| | | | | | | | | | | | This commit implements isAddress function to allow a number literal to be considered as an address literal. Since Solidity only allows '0x' to be written in lower case, we remove the handling of upper case '0X' to keep the behavior in sync with Solidity. In addition to isAddress implementation, this commit also removes 'String' methods from AST nodes to prevent them from implementing the builtin 'Stringer' interface. Therefore, our AST printer is now able to print struct fields of value nodes instead of only one string.
* core: vm: sqlvm: introduce interfaces for AST nodesTing-Wei Lan2019-05-063-153/+992
| | | | | | | | | 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-05-062-0/+82
| | | | | 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-05-062-42/+44
| | | | Implement schema struct and handle its rlp serialization.
* core: vm: sqlvm: ast: add encoder/decoder for decimal to byteswmin02019-05-062-11/+196
| | | | | | | | Add encoder/decoder to convert between decimal and bytes. Also handle issues below. * Signed & Unsigned * Padding * Floating point of fixed
* core: vm: sqlvm: ast: data type encoder and decoderwmin02019-05-062-0/+244
| | | | | Implement encode & decode function to convert between type node and 2-bytes type described on spec.
* core: vm: sqlvm: ast: don't hardcode output and indent in PrintASTTing-Wei Lan2019-05-061-25/+33
| | | | | It is now possible to write AST dump to a writer other than stdout and use indent string other than 2 spaces.
* core: vm: sqlvm: process non-UTF-8 input and escape sequencesTing-Wei Lan2019-05-061-5/+31
| | | | | | | | | | | | | | | Our parser is able to process queries with invalid UTF-8, provided that it is compatible with ASCII. Since doing so requires encoding the input before passing to pigeon, Parse* functions generated by pigeon are unexported because they should not be used directly. Escape sequences in string literals and identifiers are now recognized. In addition to escape sequences supported by solidity, we support \U similar to the one supported by Go to allow users to specify non-BMP Unicode code point without using multiple \x escapes. AST printer is modified to quote non-printable characters in strings to prevent control characters from messing up the terminal.
* core: vm: sqlvm: remove optional interface and add print tag for detailwmin02019-05-062-96/+40
| | | | | | | There are some changes in print ast utility. 1. instead of using optional interface to get detail, use reflect 2. implement a `print` field tag for printer switching detail mode or not
* core: vm: sqlvm: move AST and parser to their own packagesTing-Wei Lan2019-05-062-0/+559
In order to avoid putting too many different things in single package and allow other projects to reuse the syntax tree and the parser, these two components are moved to different packages and all nodes used in AST are now exported. A lot of comments are added in this commit to pass golint checks.