UNPKG

arc_dx

Version:

A platform for building DAOs

858 lines (857 loc) 1.65 MB
{ "contractName": "OrderStatisticTree", "abi": [], "bytecode": "0x604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600080fd00a165627a7a723058203576940535a7b19961c0ce7c11d9d262f46ade1723f1f655aafe75d086c575a90029", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fd00a165627a7a723058203576940535a7b19961c0ce7c11d9d262f46ade1723f1f655aafe75d086c575a90029", "sourceMap": "27:10227:41:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24", "deployedSourceMap": "27:10227:41:-;;;;;;;;", "source": "pragma solidity ^0.4.25;\n\n\nlibrary OrderStatisticTree {\n\n struct Node {\n mapping (bool => uint) children; // a mapping of left(false) child and right(true) child nodes\n uint parent; // parent node\n bool side; // side of the node on the tree (left or right)\n uint height; //Height of this node\n uint count; //Number of tree nodes below this node (including this one)\n uint dupes; //Number of duplicates values for this node\n }\n\n struct Tree {\n // a mapping between node value(uint) to Node\n // the tree's root is always at node 0 ,which points to the \"real\" tree\n // as its right child.this is done to eliminate the need to update the tree\n // root in the case of rotation.(saving gas).\n mapping(uint => Node) nodes;\n }\n /**\n * @dev rank - find the rank of a value in the tree,\n * i.e. its index in the sorted list of elements of the tree\n * @param _tree the tree\n * @param _value the input value to find its rank.\n * @return smaller - the number of elements in the tree which their value is\n * less than the input value.\n */\n function rank(Tree storage _tree,uint _value) internal view returns (uint smaller) {\n if (_value != 0) {\n smaller = _tree.nodes[0].dupes;\n\n uint cur = _tree.nodes[0].children[true];\n Node storage currentNode = _tree.nodes[cur];\n\n while (true) {\n if (cur <= _value) {\n if (cur<_value) {\n smaller = smaller + 1+currentNode.dupes;\n }\n uint leftChild = currentNode.children[false];\n if (leftChild!=0) {\n smaller = smaller + _tree.nodes[leftChild].count;\n }\n }\n if (cur == _value) {\n break;\n }\n cur = currentNode.children[cur<_value];\n if (cur == 0) {\n break;\n }\n currentNode = _tree.nodes[cur];\n }\n }\n }\n\n function count(Tree storage _tree) internal view returns (uint) {\n Node storage root = _tree.nodes[0];\n Node memory child = _tree.nodes[root.children[true]];\n return root.dupes+child.count;\n }\n\n function updateCount(Tree storage _tree,uint _value) private {\n Node storage n = _tree.nodes[_value];\n n.count = 1+_tree.nodes[n.children[false]].count+_tree.nodes[n.children[true]].count+n.dupes;\n }\n\n function updateCounts(Tree storage _tree,uint _value) private {\n uint parent = _tree.nodes[_value].parent;\n while (parent!=0) {\n updateCount(_tree,parent);\n parent = _tree.nodes[parent].parent;\n }\n }\n\n function updateHeight(Tree storage _tree,uint _value) private {\n Node storage n = _tree.nodes[_value];\n uint heightLeft = _tree.nodes[n.children[false]].height;\n uint heightRight = _tree.nodes[n.children[true]].height;\n if (heightLeft > heightRight)\n n.height = heightLeft+1;\n else\n n.height = heightRight+1;\n }\n\n function balanceFactor(Tree storage _tree,uint _value) private view returns (int bf) {\n Node storage n = _tree.nodes[_value];\n return int(_tree.nodes[n.children[false]].height)-int(_tree.nodes[n.children[true]].height);\n }\n\n function rotate(Tree storage _tree,uint _value,bool dir) private {\n bool otherDir = !dir;\n Node storage n = _tree.nodes[_value];\n bool side = n.side;\n uint parent = n.parent;\n uint valueNew = n.children[otherDir];\n Node storage nNew = _tree.nodes[valueNew];\n uint orphan = nNew.children[dir];\n Node storage p = _tree.nodes[parent];\n Node storage o = _tree.nodes[orphan];\n p.children[side] = valueNew;\n nNew.side = side;\n nNew.parent = parent;\n nNew.children[dir] = _value;\n n.parent = valueNew;\n n.side = dir;\n n.children[otherDir] = orphan;\n o.parent = _value;\n o.side = otherDir;\n updateHeight(_tree,_value);\n updateHeight(_tree,valueNew);\n updateCount(_tree,_value);\n updateCount(_tree,valueNew);\n }\n\n function rebalanceInsert(Tree storage _tree,uint _nValue) private {\n updateHeight(_tree,_nValue);\n Node storage n = _tree.nodes[_nValue];\n uint pValue = n.parent;\n if (pValue!=0) {\n int pBf = balanceFactor(_tree,pValue);\n bool side = n.side;\n int sign;\n if (side)\n sign = -1;\n else\n sign = 1;\n if (pBf == sign*2) {\n if (balanceFactor(_tree,_nValue) == (-1 * sign)) {\n rotate(_tree,_nValue,side);\n }\n rotate(_tree,pValue,!side);\n } else if (pBf != 0) {\n rebalanceInsert(_tree,pValue);\n }\n }\n }\n\n function rebalanceDelete(Tree storage _tree,uint _pValue,bool side) private {\n if (_pValue!=0) {\n updateHeight(_tree,_pValue);\n int pBf = balanceFactor(_tree,_pValue);\n int sign;\n if (side)\n sign = 1;\n else\n sign = -1;\n int bf = balanceFactor(_tree,_pValue);\n if (bf==(2*sign)) {\n Node storage p = _tree.nodes[_pValue];\n uint sValue = p.children[!side];\n int sBf = balanceFactor(_tree,sValue);\n if (sBf == (-1 * sign)) {\n rotate(_tree,sValue,!side);\n }\n rotate(_tree,_pValue,side);\n if (sBf!=0) {\n p = _tree.nodes[_pValue];\n rebalanceDelete(_tree,p.parent,p.side);\n }\n } else if (pBf != sign) {\n p = _tree.nodes[_pValue];\n rebalanceDelete(_tree,p.parent,p.side);\n }\n }\n }\n\n function fixParents(Tree storage _tree,uint parent,bool side) private {\n if (parent!=0) {\n updateCount(_tree,parent);\n updateCounts(_tree,parent);\n rebalanceDelete(_tree,parent,side);\n }\n }\n\n function insertHelper(Tree storage _tree,uint _pValue,bool _side,uint _value) private {\n Node storage root = _tree.nodes[_pValue];\n uint cValue = root.children[_side];\n if (cValue==0) {\n root.children[_side] = _value;\n Node storage child = _tree.nodes[_value];\n child.parent = _pValue;\n child.side = _side;\n child.height = 1;\n child.count = 1;\n updateCounts(_tree,_value);\n rebalanceInsert(_tree,_value);\n } else if (cValue==_value) {\n _tree.nodes[cValue].dupes++;\n updateCount(_tree,_value);\n updateCounts(_tree,_value);\n } else {\n insertHelper(_tree,cValue,(_value >= cValue),_value);\n }\n }\n\n function insert(Tree storage _tree,uint _value) internal {\n if (_value==0) {\n _tree.nodes[_value].dupes++;\n } else {\n insertHelper(_tree,0,true,_value);\n }\n }\n\n function rightmostLeaf(Tree storage _tree,uint _value) private view returns (uint leaf) {\n uint child = _tree.nodes[_value].children[true];\n if (child!=0) {\n return rightmostLeaf(_tree,child);\n } else {\n return _value;\n }\n }\n\n function zeroOut(Tree storage _tree,uint _value) private {\n Node storage n = _tree.nodes[_value];\n n.parent = 0;\n n.side = false;\n n.children[false] = 0;\n n.children[true] = 0;\n n.count = 0;\n n.height = 0;\n n.dupes = 0;\n }\n\n function removeBranch(Tree storage _tree,uint _value,uint _left) private {\n uint ipn = rightmostLeaf(_tree,_left);\n Node storage i = _tree.nodes[ipn];\n uint dupes = i.dupes;\n removeHelper(_tree,ipn);\n Node storage n = _tree.nodes[_value];\n uint parent = n.parent;\n Node storage p = _tree.nodes[parent];\n uint height = n.height;\n bool side = n.side;\n uint ncount = n.count;\n uint right = n.children[true];\n uint left = n.children[false];\n p.children[side] = ipn;\n i.parent = parent;\n i.side = side;\n i.count = ncount+dupes-n.dupes;\n i.height = height;\n i.dupes = dupes;\n if (left!=0) {\n i.children[false] = left;\n _tree.nodes[left].parent = ipn;\n }\n if (right!=0) {\n i.children[true] = right;\n _tree.nodes[right].parent = ipn;\n }\n zeroOut(_tree,_value);\n updateCounts(_tree,ipn);\n }\n\n function removeHelper(Tree storage _tree,uint _value) private {\n Node storage n = _tree.nodes[_value];\n uint parent = n.parent;\n bool side = n.side;\n Node storage p = _tree.nodes[parent];\n uint left = n.children[false];\n uint right = n.children[true];\n if ((left == 0) && (right == 0)) {\n p.children[side] = 0;\n zeroOut(_tree,_value);\n fixParents(_tree,parent,side);\n } else if ((left != 0) && (right != 0)) {\n removeBranch(_tree,_value,left);\n } else {\n uint child = left+right;\n Node storage c = _tree.nodes[child];\n p.children[side] = child;\n c.parent = parent;\n c.side = side;\n zeroOut(_tree,_value);\n fixParents(_tree,parent,side);\n }\n }\n\n function remove(Tree storage _tree,uint _value) internal {\n Node storage n = _tree.nodes[_value];\n if (_value==0) {\n if (n.dupes==0) {\n return;\n }\n } else {\n if (n.count==0) {\n return;\n }\n }\n if (n.dupes>0) {\n n.dupes--;\n if (_value!=0) {\n n.count--;\n }\n fixParents(_tree,n.parent,n.side);\n } else {\n removeHelper(_tree,_value);\n }\n }\n\n}\n", "sourcePath": "@daostack/infra/contracts/libs/OrderStatisticTree.sol", "ast": { "absolutePath": "@daostack/infra/contracts/libs/OrderStatisticTree.sol", "exportedSymbols": { "OrderStatisticTree": [ 14785 ] }, "id": 14786, "nodeType": "SourceUnit", "nodes": [ { "id": 13409, "literals": [ "solidity", "^", "0.4", ".25" ], "nodeType": "PragmaDirective", "src": "0:24:41" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 14785, "linearizedBaseContracts": [ 14785 ], "name": "OrderStatisticTree", "nodeType": "ContractDefinition", "nodes": [ { "canonicalName": "OrderStatisticTree.Node", "id": 13424, "members": [ { "constant": false, "id": 13413, "name": "children", "nodeType": "VariableDeclaration", "scope": 13424, "src": "83:31:41", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_bool_$_t_uint256_$", "typeString": "mapping(bool => uint256)" }, "typeName": { "id": 13412, "keyType": { "id": 13410, "name": "bool", "nodeType": "ElementaryTypeName", "src": "92:4:41", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "nodeType": "Mapping", "src": "83:22:41", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_bool_$_t_uint256_$", "typeString": "mapping(bool => uint256)" }, "valueType": { "id": 13411, "name": "uint", "nodeType": "ElementaryTypeName", "src": "100:4:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 13415, "name": "parent", "nodeType": "VariableDeclaration", "scope": 13424, "src": "186:11:41", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 13414, "name": "uint", "nodeType": "ElementaryTypeName", "src": "186:4:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 13417, "name": "side", "nodeType": "VariableDeclaration", "scope": 13424, "src": "222:9:41", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 13416, "name": "bool", "nodeType": "ElementaryTypeName", "src": "222:4:41", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 13419, "name": "height", "nodeType": "VariableDeclaration", "scope": 13424, "src": "291:11:41", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 13418, "name": "uint", "nodeType": "ElementaryTypeName", "src": "291:4:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 13421, "name": "count", "nodeType": "VariableDeclaration", "scope": 13424, "src": "334:10:41", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 13420, "name": "uint", "nodeType": "ElementaryTypeName", "src": "334:4:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 13423, "name": "dupes", "nodeType": "VariableDeclaration", "scope": 13424, "src": "414:10:41", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 13422, "name": "uint", "nodeType": "ElementaryTypeName", "src": "414:4:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "name": "Node", "nodeType": "StructDefinition", "scope": 14785, "src": "61:414:41", "visibility": "public" }, { "canonicalName": "OrderStatisticTree.Tree", "id": 13429, "members": [ { "constant": false, "id": 13428, "name": "nodes", "nodeType": "VariableDeclaration", "scope": 13429, "src": "775:27:41", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Node_$13424_storage_$", "typeString": "mapping(uint256 => struct OrderStatisticTree.Node)" }, "typeName": { "id": 13427, "keyType": { "id": 13425, "name": "uint", "nodeType": "ElementaryTypeName", "src": "783:4:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Mapping", "src": "775:21:41", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Node_$13424_storage_$", "typeString": "mapping(uint256 => struct OrderStatisticTree.Node)" }, "valueType": { "contractScope": null, "id": 13426, "name": "Node", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 13424, "src": "791:4:41", "typeDescriptions": { "typeIdentifier": "t_struct$_Node_$13424_storage_ptr", "typeString": "struct OrderStatisticTree.Node" } } }, "value": null, "visibility": "internal" } ], "name": "Tree", "nodeType": "StructDefinition", "scope": 14785, "src": "481:328:41", "visibility": "public" }, { "body": { "id": 13540, "nodeType": "Block", "src": "1239:887:41", "statements": [ { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 13440, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 13438, "name": "_value", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13433, "src": "1253:6:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 13439, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1263:1:41", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1253:11:41", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 13539, "nodeType": "IfStatement", "src": "1249:871:41", "trueBody": { "id": 13538, "nodeType": "Block", "src": "1266:854:41", "statements": [ { "expression": { "argumentTypes": null, "id": 13447, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 13441, "name": "smaller", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13436, "src": "1280:7:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "expression": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 13442, "name": "_tree", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13431, "src": "1290:5:41", "typeDescriptions": { "typeIdentifier": "t_struct$_Tree_$13429_storage_ptr", "typeString": "struct OrderStatisticTree.Tree storage pointer" } }, "id": 13443, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "nodes", "nodeType": "MemberAccess", "referencedDeclaration": 13428, "src": "1290:11:41", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Node_$13424_storage_$", "typeString": "mapping(uint256 => struct OrderStatisticTree.Node storage ref)" } }, "id": 13445, "indexExpression": { "argumentTypes": null, "hexValue": "30", "id": 13444, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1302:1:41", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", "src": "1290:14:41", "typeDescriptions": { "typeIdentifier": "t_struct$_Node_$13424_storage", "typeString": "struct OrderStatisticTree.Node storage ref" } }, "id": 13446, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "dupes", "nodeType": "MemberAccess", "referencedDeclaration": 13423, "src": "1290:20:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1280:30:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 13448, "nodeType": "ExpressionStatement", "src": "1280:30:41" }, { "assignments": [ 13450 ], "declarations": [ { "constant": false, "id": 13450, "name": "cur", "nodeType": "VariableDeclaration", "scope": 13541, "src": "1325:8:41", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 13449, "name": "uint", "nodeType": "ElementaryTypeName", "src": "1325:4:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 13458, "initialValue": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 13451, "name": "_tree", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13431, "src": "1336:5:41", "typeDescriptions": { "typeIdentifier": "t_struct$_Tree_$13429_storage_ptr", "typeString": "struct OrderStatisticTree.Tree storage pointer" } }, "id": 13452, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "nodes", "nodeType": "MemberAccess", "referencedDeclaration": 13428, "src": "1336:11:41", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Node_$13424_storage_$", "typeString": "mapping(uint256 => struct OrderStatisticTree.Node storage ref)" } }, "id": 13454, "indexExpression": { "argumentTypes": null, "hexValue": "30", "id": 13453, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1348:1:41", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", "src": "1336:14:41", "typeDescriptions": { "typeIdentifier": "t_struct$_Node_$13424_storage", "typeString": "struct OrderStatisticTree.Node storage ref" } }, "id": 13455, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "children", "nodeType": "MemberAccess", "referencedDeclaration": 13413, "src": "1336:23:41", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_bool_$_t_uint256_$", "typeString": "mapping(bool => uint256)" } }, "id": 13457, "indexExpression": { "argumentTypes": null, "hexValue": "74727565", "id": 13456, "isConstant": false, "isLValue": false, "isPure": true, "kind": "bool", "lValueRequested": false, "nodeType": "Literal", "src": "1360:4:41", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "value": "true" }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", "src": "1336:29:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "1325:40:41" }, { "assignments": [ 13460 ], "declarations": [ { "constant": false, "id": 13460, "name": "currentNode", "nodeType": "VariableDeclaration", "scope": 13541, "src": "1379:24:41", "stateVariable": false, "storageLocation": "storage", "typeDescriptions": { "typeIdentifier": "t_struct$_Node_$13424_storage_ptr", "typeString": "struct OrderStatisticTree.Node" }, "typeName": { "contractScope": null, "id": 13459, "name": "Node", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 13424, "src": "1379:4:41", "typeDescriptions": { "typeIdentifier": "t_struct$_Node_$13424_storage_ptr", "typeString": "struct OrderStatisticTree.Node" } }, "value": null, "visibility": "internal" } ], "id": 13465, "initialValue": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 13461, "name": "_tree", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13431, "src": "1406:5:41", "typeDescriptions": { "typeIdentifier": "t_struct$_Tree_$13429_storage_ptr", "typeString": "struct OrderStatisticTree.Tree storage pointer" } }, "id": 13462, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "nodes", "nodeType": "MemberAccess", "referencedDeclaration": 13428, "src": "1406:11:41", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Node_$13424_storage_$", "typeString": "mapping(uint256 => struct OrderStatisticTree.Node storage ref)" } }, "id": 13464, "indexExpression": { "argumentTypes": null, "id": 13463, "name": "cur", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13450, "src": "1418:3:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", "src": "1406:16:41", "typeDescriptions": { "typeIdentifier": "t_struct$_Node_$13424_storage", "typeString": "struct OrderStatisticTree.Node storage ref" } }, "nodeType": "VariableDeclarationStatement", "src": "1379:43:41" }, { "body": { "id": 13536, "nodeType": "Block", "src": "1450:660:41", "statements": [ { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 13469, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 13467, "name": "cur", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13450, "src": "1472:3:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<=", "rightExpression": { "argumentTypes": null, "id": 13468, "name": "_value", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13433, "src": "1479:6:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1472:13:41", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 13507, "nodeType": "IfStatement", "src": "1468:365:41", "trueBody": { "id": 13506, "nodeType": "Block", "src": "1487:346:41", "statements": [ { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 13472, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 13470, "name": "cur", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13450, "src": "1513:3:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "argumentTypes": null, "id": 13471, "name": "_value", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13433, "src": "1517:6:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1513:10:41", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 13483, "nodeType": "IfStatement", "src": "1509:104:41", "trueBody": { "id": 13482, "nodeType": "Block", "src": "1525:88:41", "statements": [ { "expression": { "argumentTypes": null, "id": 13480, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 13473, "name": "smaller", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13436, "src": "1551:7:41", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 13479, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256"