{"action":"created","comment":{"url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/29835874","id":29835874,"diff_hunk":"@@ -0,0 +1,108 @@\n+/*\n+\tThis file is part of cpp-ethereum.\n+\n+\tcpp-ethereum is free software: you can redistribute it and/or modify\n+\tit under the terms of the GNU General Public License as published by\n+\tthe Free Software Foundation, either version 3 of the License, or\n+\t(at your option) any later version.\n+\n+\tcpp-ethereum is distributed in the hope that it will be useful,\n+\tbut WITHOUT ANY WARRANTY; without even the implied warranty of\n+\tMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+\tGNU General Public License for more details.\n+\n+\tYou should have received a copy of the GNU General Public License\n+\talong with cpp-ethereum.  If not, see <http://www.gnu.org/licenses/>.\n+*/\n+/**\n+ * @author Christian <c@ethdev.com>\n+ * @date 2015\n+ * Gas consumption estimator working alongside the AST.\n+ */\n+\n+#include \"StructuralGasEstimator.h\"\n+#include <map>\n+#include <functional>\n+#include <libsolidity/AST.h>\n+#include <libsolidity/ASTVisitor.h>\n+\n+using namespace std;\n+using namespace dev;\n+using namespace dev::eth;\n+using namespace dev::solidity;\n+\n+StructuralGasEstimator::ASTGasConsumptionSelfAccumulated StructuralGasEstimator::performEstimation(\n+\tAssemblyItems const& _items,\n+\tvector<ASTNode const*> const& _ast\n+)\n+{\n+\tmap<SourceLocation, GasMeter::GasConsumption> particularCosts;\n+\tGasMeter meter;\n+\n+\tfor (auto const& item: _items)\n+\t\tparticularCosts[item.getLocation()] += meter.estimateMax(item);\n+\n+\tASTGasConsumptionSelfAccumulated gasCosts;\n+\tauto onNode = [&](ASTNode const& _node)\n+\t{\n+\t\tgasCosts[&_node][0] = gasCosts[&_node][1] = particularCosts[_node.getLocation()];\n+\t\treturn true;\n+\t};\n+\tauto onEdge = [&](ASTNode const& _parent, ASTNode const& _child)\n+\t{\n+\t\tgasCosts[&_parent][1] += gasCosts[&_child][1];\n+\t};\n+\tASTReduce folder(onNode, onEdge);\n+\tfor (ASTNode const* ast: _ast)\n+\t\tast->accept(folder);","path":"libsolidity/StructuralGasEstimator.cpp","position":58,"original_position":57,"commit_id":"7c8de3f0ea14f47babd037947ec7235f9a9c1023","original_commit_id":"c57305025fcd89ba7f569debb91b277f423d8cae","user":{"login":"chriseth","id":9073706,"avatar_url":"https://avatars.githubusercontent.com/u/9073706?v=3","gravatar_id":"","url":"https://api.github.com/users/chriseth","html_url":"https://github.com/chriseth","followers_url":"https://api.github.com/users/chriseth/followers","following_url":"https://api.github.com/users/chriseth/following{/other_user}","gists_url":"https://api.github.com/users/chriseth/gists{/gist_id}","starred_url":"https://api.github.com/users/chriseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriseth/subscriptions","organizations_url":"https://api.github.com/users/chriseth/orgs","repos_url":"https://api.github.com/users/chriseth/repos","events_url":"https://api.github.com/users/chriseth/events{/privacy}","received_events_url":"https://api.github.com/users/chriseth/received_events","type":"User","site_admin":false},"body":"Added assertions.","created_at":"2015-05-07T09:15:01Z","updated_at":"2015-05-07T09:15:01Z","html_url":"https://github.com/ethereum/cpp-ethereum/pull/1810#discussion_r29835874","pull_request_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/1810","_links":{"self":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/29835874"},"html":{"href":"https://github.com/ethereum/cpp-ethereum/pull/1810#discussion_r29835874"},"pull_request":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/1810"}}},"pull_request":{"url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/1810","id":34798441,"html_url":"https://github.com/ethereum/cpp-ethereum/pull/1810","diff_url":"https://github.com/ethereum/cpp-ethereum/pull/1810.diff","patch_url":"https://github.com/ethereum/cpp-ethereum/pull/1810.patch","issue_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/1810","number":1810,"state":"open","locked":false,"title":"Structural gas estimator.","user":{"login":"chriseth","id":9073706,"avatar_url":"https://avatars.githubusercontent.com/u/9073706?v=3","gravatar_id":"","url":"https://api.github.com/users/chriseth","html_url":"https://github.com/chriseth","followers_url":"https://api.github.com/users/chriseth/followers","following_url":"https://api.github.com/users/chriseth/following{/other_user}","gists_url":"https://api.github.com/users/chriseth/gists{/gist_id}","starred_url":"https://api.github.com/users/chriseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriseth/subscriptions","organizations_url":"https://api.github.com/users/chriseth/orgs","repos_url":"https://api.github.com/users/chriseth/repos","events_url":"https://api.github.com/users/chriseth/events{/privacy}","received_events_url":"https://api.github.com/users/chriseth/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-05-06T08:53:35Z","updated_at":"2015-05-07T09:15:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abcfa961fecf65fe87541f28eb7727fd128fc214","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/1810/commits","review_comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/1810/comments","review_comment_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/1810/comments","statuses_url":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/7c8de3f0ea14f47babd037947ec7235f9a9c1023","head":{"label":"chriseth:sol_gasEstimator","ref":"sol_gasEstimator","sha":"7c8de3f0ea14f47babd037947ec7235f9a9c1023","user":{"login":"chriseth","id":9073706,"avatar_url":"https://avatars.githubusercontent.com/u/9073706?v=3","gravatar_id":"","url":"https://api.github.com/users/chriseth","html_url":"https://github.com/chriseth","followers_url":"https://api.github.com/users/chriseth/followers","following_url":"https://api.github.com/users/chriseth/following{/other_user}","gists_url":"https://api.github.com/users/chriseth/gists{/gist_id}","starred_url":"https://api.github.com/users/chriseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriseth/subscriptions","organizations_url":"https://api.github.com/users/chriseth/orgs","repos_url":"https://api.github.com/users/chriseth/repos","events_url":"https://api.github.com/users/chriseth/events{/privacy}","received_events_url":"https://api.github.com/users/chriseth/received_events","type":"User","site_admin":false},"repo":{"id":24932538,"name":"cpp-ethereum","full_name":"chriseth/cpp-ethereum","owner":{"login":"chriseth","id":9073706,"avatar_url":"https://avatars.githubusercontent.com/u/9073706?v=3","gravatar_id":"","url":"https://api.github.com/users/chriseth","html_url":"https://github.com/chriseth","followers_url":"https://api.github.com/users/chriseth/followers","following_url":"https://api.github.com/users/chriseth/following{/other_user}","gists_url":"https://api.github.com/users/chriseth/gists{/gist_id}","starred_url":"https://api.github.com/users/chriseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriseth/subscriptions","organizations_url":"https://api.github.com/users/chriseth/orgs","repos_url":"https://api.github.com/users/chriseth/repos","events_url":"https://api.github.com/users/chriseth/events{/privacy}","received_events_url":"https://api.github.com/users/chriseth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chriseth/cpp-ethereum","description":"Gavin Wood's C++ implementation of the Ethereum yellowpaper.","fork":true,"url":"https://api.github.com/repos/chriseth/cpp-ethereum","forks_url":"https://api.github.com/repos/chriseth/cpp-ethereum/forks","keys_url":"https://api.github.com/repos/chriseth/cpp-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chriseth/cpp-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chriseth/cpp-ethereum/teams","hooks_url":"https://api.github.com/repos/chriseth/cpp-ethereum/hooks","issue_events_url":"https://api.github.com/repos/chriseth/cpp-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/chriseth/cpp-ethereum/events","assignees_url":"https://api.github.com/repos/chriseth/cpp-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/chriseth/cpp-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/chriseth/cpp-ethereum/tags","blobs_url":"https://api.github.com/repos/chriseth/cpp-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chriseth/cpp-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chriseth/cpp-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/chriseth/cpp-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chriseth/cpp-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/chriseth/cpp-ethereum/languages","stargazers_url":"https://api.github.com/repos/chriseth/cpp-ethereum/stargazers","contributors_url":"https://api.github.com/repos/chriseth/cpp-ethereum/contributors","subscribers_url":"https://api.github.com/repos/chriseth/cpp-ethereum/subscribers","subscription_url":"https://api.github.com/repos/chriseth/cpp-ethereum/subscription","commits_url":"https://api.github.com/repos/chriseth/cpp-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/chriseth/cpp-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/chriseth/cpp-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/chriseth/cpp-ethereum/issues/comments{/number}","contents_url":"https://api.github.com/repos/chriseth/cpp-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/chriseth/cpp-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chriseth/cpp-ethereum/merges","archive_url":"https://api.github.com/repos/chriseth/cpp-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chriseth/cpp-ethereum/downloads","issues_url":"https://api.github.com/repos/chriseth/cpp-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/chriseth/cpp-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/chriseth/cpp-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/chriseth/cpp-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chriseth/cpp-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/chriseth/cpp-ethereum/releases{/id}","created_at":"2014-10-08T09:01:35Z","updated_at":"2015-03-02T16:58:54Z","pushed_at":"2015-05-07T09:14:15Z","git_url":"git://github.com/chriseth/cpp-ethereum.git","ssh_url":"git@github.com:chriseth/cpp-ethereum.git","clone_url":"https://github.com/chriseth/cpp-ethereum.git","svn_url":"https://github.com/chriseth/cpp-ethereum","homepage":"www.gavwood.com/Paper.pdf","size":46124,"stargazers_count":2,"watchers_count":2,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"develop"}},"base":{"label":"ethereum:develop","ref":"develop","sha":"808886a38478d47d183c1b622b2a71bad476f67c","user":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"repo":{"id":15460666,"name":"cpp-ethereum","full_name":"ethereum/cpp-ethereum","owner":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethereum/cpp-ethereum","description":"Gavin Wood's C++ implementation of the Ethereum yellowpaper.","fork":false,"url":"https://api.github.com/repos/ethereum/cpp-ethereum","forks_url":"https://api.github.com/repos/ethereum/cpp-ethereum/forks","keys_url":"https://api.github.com/repos/ethereum/cpp-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/cpp-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/cpp-ethereum/teams","hooks_url":"https://api.github.com/repos/ethereum/cpp-ethereum/hooks","issue_events_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/cpp-ethereum/events","assignees_url":"https://api.github.com/repos/ethereum/cpp-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/cpp-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/cpp-ethereum/tags","blobs_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/cpp-ethereum/languages","stargazers_url":"https://api.github.com/repos/ethereum/cpp-ethereum/stargazers","contributors_url":"https://api.github.com/repos/ethereum/cpp-ethereum/contributors","subscribers_url":"https://api.github.com/repos/ethereum/cpp-ethereum/subscribers","subscription_url":"https://api.github.com/repos/ethereum/cpp-ethereum/subscription","commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethereum/cpp-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/cpp-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/cpp-ethereum/merges","archive_url":"https://api.github.com/repos/ethereum/cpp-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/cpp-ethereum/downloads","issues_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/cpp-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/cpp-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/cpp-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/cpp-ethereum/releases{/id}","created_at":"2013-12-26T21:26:06Z","updated_at":"2015-05-07T08:09:03Z","pushed_at":"2015-05-07T09:14:16Z","git_url":"git://github.com/ethereum/cpp-ethereum.git","ssh_url":"git@github.com:ethereum/cpp-ethereum.git","clone_url":"https://github.com/ethereum/cpp-ethereum.git","svn_url":"https://github.com/ethereum/cpp-ethereum","homepage":"www.gavwood.com/Paper.pdf","size":96485,"stargazers_count":460,"watchers_count":460,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"open_issues_count":128,"forks":156,"open_issues":128,"watchers":460,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/1810"},"html":{"href":"https://github.com/ethereum/cpp-ethereum/pull/1810"},"issue":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/1810"},"comments":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/1810/comments"},"review_comments":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/1810/comments"},"review_comment":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/1810/commits"},"statuses":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/7c8de3f0ea14f47babd037947ec7235f9a9c1023"}}}}