Last active
January 9, 2017 19:58
-
-
Save cgewecke/d2bea9c00c3375845fd74d98b5879e61 to your computer and use it in GitHub Desktop.
DeclarativeExpression AST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Test contract | |
| contract DeclarativeExpressions { | |
| uint a; | |
| uint b = 7; | |
| uint b2=0; | |
| uint public c; | |
| uint constant public d; | |
| uint public constant e; | |
| uint private constant f = 7; | |
| struct S { uint q;} | |
| function ham(S storage s1, uint[] storage arr) internal { | |
| uint x; | |
| uint y = 7; | |
| S storage s2 = s1; | |
| uint[] memory stor; | |
| uint[] storage stor2 = arr; | |
| } | |
| } | |
| // AST | |
| { | |
| "type": "Program", | |
| "body": [ | |
| { | |
| "type": "ContractStatement", | |
| "name": "DeclarativeExpressions", | |
| "is": [], | |
| "body": [ | |
| { | |
| "type": "StateVariableDeclaration", | |
| "name": "a", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7667, | |
| "end": 7671 | |
| }, | |
| "visibility": null, | |
| "is_constant": false, | |
| "value": null, | |
| "start": 7667, | |
| "end": 7674 | |
| }, | |
| { | |
| "type": "StateVariableDeclaration", | |
| "name": "b", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7677, | |
| "end": 7681 | |
| }, | |
| "visibility": null, | |
| "is_constant": false, | |
| "value": { | |
| "type": "Literal", | |
| "value": 7, | |
| "start": 7686, | |
| "end": 7687 | |
| }, | |
| "start": 7677, | |
| "end": 7688 | |
| }, | |
| { | |
| "type": "StateVariableDeclaration", | |
| "name": "b2", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7691, | |
| "end": 7695 | |
| }, | |
| "visibility": null, | |
| "is_constant": false, | |
| "value": { | |
| "type": "Literal", | |
| "value": 0, | |
| "start": 7699, | |
| "end": 7700 | |
| }, | |
| "start": 7691, | |
| "end": 7701 | |
| }, | |
| { | |
| "type": "StateVariableDeclaration", | |
| "name": "c", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7704, | |
| "end": 7708 | |
| }, | |
| "visibility": "public", | |
| "is_constant": false, | |
| "value": null, | |
| "start": 7704, | |
| "end": 7718 | |
| }, | |
| { | |
| "type": "StateVariableDeclaration", | |
| "name": "d", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7721, | |
| "end": 7725 | |
| }, | |
| "visibility": "public", | |
| "is_constant": true, | |
| "value": null, | |
| "start": 7721, | |
| "end": 7744 | |
| }, | |
| { | |
| "type": "StateVariableDeclaration", | |
| "name": "e", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7747, | |
| "end": 7751 | |
| }, | |
| "visibility": "public", | |
| "is_constant": true, | |
| "value": null, | |
| "start": 7747, | |
| "end": 7770 | |
| }, | |
| { | |
| "type": "StateVariableDeclaration", | |
| "name": "f", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7773, | |
| "end": 7777 | |
| }, | |
| "visibility": "private", | |
| "is_constant": true, | |
| "value": { | |
| "type": "Literal", | |
| "value": 7, | |
| "start": 7799, | |
| "end": 7800 | |
| }, | |
| "start": 7773, | |
| "end": 7801 | |
| }, | |
| { | |
| "type": "StructDeclaration", | |
| "name": "S", | |
| "body": [ | |
| { | |
| "type": "DeclarativeExpression", | |
| "name": "q", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7815, | |
| "end": 7819 | |
| }, | |
| "storage_location": null, | |
| "start": 7815, | |
| "end": 7821 | |
| } | |
| ], | |
| "start": 7804, | |
| "end": 7823 | |
| }, | |
| { | |
| "type": "FunctionDeclaration", | |
| "name": "ham", | |
| "params": [ | |
| { | |
| "type": "InformalParameter", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "S", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7840, | |
| "end": 7841 | |
| }, | |
| "id": "s1", | |
| "is_indexed": false, | |
| "is_storage": true, | |
| "is_memory": false, | |
| "start": 7840, | |
| "end": 7852 | |
| }, | |
| { | |
| "type": "InformalParameter", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [ | |
| null | |
| ], | |
| "start": 7854, | |
| "end": 7860 | |
| }, | |
| "id": "arr", | |
| "is_indexed": false, | |
| "is_storage": true, | |
| "is_memory": false, | |
| "start": 7854, | |
| "end": 7872 | |
| } | |
| ], | |
| "modifiers": [ | |
| { | |
| "type": "ModifierArgument", | |
| "name": "internal", | |
| "params": [], | |
| "start": 7874, | |
| "end": 7883 | |
| } | |
| ], | |
| "body": { | |
| "type": "BlockStatement", | |
| "body": [ | |
| { | |
| "type": "ExpressionStatement", | |
| "expression": { | |
| "type": "DeclarativeExpression", | |
| "name": "x", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7889, | |
| "end": 7893 | |
| }, | |
| "storage_location": null, | |
| "start": 7889, | |
| "end": 7895 | |
| }, | |
| "start": 7889, | |
| "end": 7896 | |
| }, | |
| { | |
| "type": "ExpressionStatement", | |
| "expression": { | |
| "type": "AssignmentExpression", | |
| "operator": "=", | |
| "left": { | |
| "type": "DeclarativeExpression", | |
| "name": "y", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7901, | |
| "end": 7905 | |
| }, | |
| "storage_location": null, | |
| "start": 7901, | |
| "end": 7907 | |
| }, | |
| "right": { | |
| "type": "Literal", | |
| "value": 7, | |
| "start": 7910, | |
| "end": 7911 | |
| }, | |
| "start": 7901, | |
| "end": 7911 | |
| }, | |
| "start": 7901, | |
| "end": 7912 | |
| }, | |
| { | |
| "type": "ExpressionStatement", | |
| "expression": { | |
| "type": "AssignmentExpression", | |
| "operator": "=", | |
| "left": { | |
| "type": "DeclarativeExpression", | |
| "name": "s2", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "S", | |
| "members": [], | |
| "array_parts": [], | |
| "start": 7917, | |
| "end": 7918 | |
| }, | |
| "storage_location": "storage", | |
| "start": 7917, | |
| "end": 7929 | |
| }, | |
| "right": { | |
| "type": "Identifier", | |
| "name": "s1", | |
| "start": 7932, | |
| "end": 7934 | |
| }, | |
| "start": 7917, | |
| "end": 7934 | |
| }, | |
| "start": 7917, | |
| "end": 7935 | |
| }, | |
| { | |
| "type": "ExpressionStatement", | |
| "expression": { | |
| "type": "DeclarativeExpression", | |
| "name": "stor", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [ | |
| null | |
| ], | |
| "start": 7940, | |
| "end": 7946 | |
| }, | |
| "storage_location": "memory", | |
| "start": 7940, | |
| "end": 7958 | |
| }, | |
| "start": 7940, | |
| "end": 7959 | |
| }, | |
| { | |
| "type": "ExpressionStatement", | |
| "expression": { | |
| "type": "AssignmentExpression", | |
| "operator": "=", | |
| "left": { | |
| "type": "DeclarativeExpression", | |
| "name": "stor2", | |
| "literal": { | |
| "type": "Type", | |
| "literal": "uint", | |
| "members": [], | |
| "array_parts": [ | |
| null | |
| ], | |
| "start": 7964, | |
| "end": 7970 | |
| }, | |
| "storage_location": "storage", | |
| "start": 7964, | |
| "end": 7984 | |
| }, | |
| "right": { | |
| "type": "Identifier", | |
| "name": "arr", | |
| "start": 7987, | |
| "end": 7990 | |
| }, | |
| "start": 7964, | |
| "end": 7990 | |
| }, | |
| "start": 7964, | |
| "end": 7991 | |
| } | |
| ], | |
| "start": 7889, | |
| "end": 7991 | |
| }, | |
| "is_abstract": false, | |
| "start": 7827, | |
| "end": 7995 | |
| } | |
| ], | |
| "start": 7631, | |
| "end": 7997 | |
| } | |
| ], | |
| "start": 7631, | |
| "end": 7997 | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment