{"action":"created","comment":{"url":"https://api.github.com/repos/ethereum/solidity/pulls/comments/57210166","id":57210166,"diff_hunk":"@@ -340,11 +368,138 @@ MemberList::MemberMap IntegerType::nativeMembers(ContractDefinition const*) cons\n \t\treturn MemberList::MemberMap();\n }\n \n-bool IntegerConstantType::isValidLiteral(const Literal& _literal)\n+FixedPointType::FixedPointType(int _integerBits, int _fractionalBits, FixedPointType::Modifier _modifier):\n+\tm_integerBits(_integerBits), m_fractionalBits(_fractionalBits), m_modifier(_modifier)\n+{\n+\tsolAssert(\n+\t\tm_integerBits + m_fractionalBits > 0 && \n+\t\tm_integerBits + m_fractionalBits <= 256 && \n+\t\tm_integerBits % 8 == 0 && \n+\t\tm_fractionalBits % 8 == 0,\n+\t\t\"Invalid bit number(s) for fixed type: \" + \n+\t\tdev::toString(_integerBits) + \"x\" + dev::toString(_fractionalBits)\n+\t);\n+}\n+\n+bool FixedPointType::isImplicitlyConvertibleTo(Type const& _convertTo) const\n+{\n+\tif (_convertTo.category() == category())\n+\t{\n+\t\tFixedPointType const& convertTo = dynamic_cast<FixedPointType const&>(_convertTo);\n+\t\tif (convertTo.m_integerBits < m_integerBits || convertTo.m_fractionalBits < m_fractionalBits)\n+\t\t\treturn false;\n+\t\telse if (isSigned())\n+\t\t\treturn convertTo.isSigned();\n+\t\telse\n+\t\t\treturn !convertTo.isSigned() || (convertTo.m_integerBits > m_integerBits && convertTo.m_fractionalBits > m_fractionalBits);\n+\t}\n+\telse if (_convertTo.category() == Category::Integer)\n+\t{\n+\t\tIntegerType const& convertTo = dynamic_cast<IntegerType const&>(_convertTo);\n+\t\tif (convertTo.numBits() < m_integerBits)\n+\t\t\treturn false;\n+\t\telse if (isSigned())\n+\t\t\treturn convertTo.isSigned();\n+\t\telse\n+\t\t\treturn !convertTo.isSigned() || convertTo.numBits() > m_integerBits;\n+\t}\n+\telse\n+\t\treturn false;\n+}\n+\n+bool FixedPointType::isExplicitlyConvertibleTo(Type const& _convertTo) const\n+{\n+\treturn _convertTo.category() == category() ||\n+\t\t_convertTo.category() == Category::Integer ||\n+\t\t_convertTo.category() == Category::Enum ||\n+\t\t_convertTo.category() == Category::FixedBytes;\n+}\n+\n+TypePointer FixedPointType::unaryOperatorResult(Token::Value _operator) const\n+{\n+\t// \"delete\" is ok for all fixed types\n+\tif (_operator == Token::Delete)\n+\t\treturn make_shared<TupleType>();\n+\t// for fixed, we allow +, -, ++ and --\n+\telse if (\n+\t\t_operator == Token::Add || \n+\t\t_operator == Token::Sub ||\n+\t\t_operator == Token::Inc || \n+\t\t_operator == Token::Dec ||\n+\t\t_operator == Token::After\n+\t)\n+\t\treturn shared_from_this();\n+\telse\n+\t\treturn TypePointer();\n+}\n+\n+bool FixedPointType::operator==(Type const& _other) const\n+{\n+\tif (_other.category() != category())\n+\t\treturn false;\n+\tFixedPointType const& other = dynamic_cast<FixedPointType const&>(_other);\n+\treturn other.m_integerBits == m_integerBits && other.m_fractionalBits == m_fractionalBits && other.m_modifier == m_modifier;\n+}\n+\n+string FixedPointType::toString(bool) const\n+{\n+\tstring prefix = isSigned() ? \"fixed\" : \"ufixed\";\n+\treturn prefix + dev::toString(m_integerBits) + \"x\" + dev::toString(m_fractionalBits);\n+}\n+\n+TypePointer FixedPointType::binaryOperatorResult(Token::Value _operator, TypePointer const& _other) const\n+{\n+\tif (_other->category() != Category::NumberConstant \n+\t\t&& _other->category() != category()\n+\t\t&& _other->category() != Category::Integer\n+\t)\n+\t\treturn TypePointer();\n+\tauto commonType = dynamic_pointer_cast<FixedPointType const>(Type::commonType(shared_from_this(), _other));\n+\n+\tif (!commonType)\n+\t\treturn TypePointer();\n+\n+\t// All fixed types can be compared\n+\tif (Token::isCompareOp(_operator))\n+\t\treturn commonType;\n+\tif (Token::isBooleanOp(_operator))\n+\t\treturn TypePointer();\n+\treturn commonType;\n+}\n+\n+bool ConstantNumberType::isValidLiteral(const Literal& _literal)\n {\n \ttry\n \t{\n-\t\tbigint x(_literal.value());\n+\t\trational numerator;\n+\t\trational denominator = bigint(1);","path":"libsolidity/ast/Types.cpp","position":220,"original_position":220,"commit_id":"d91a54defc03be5297def21c93903a3567e03fd5","original_commit_id":"d91a54defc03be5297def21c93903a3567e03fd5","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":"`rational denominator(1)`","created_at":"2016-03-23T18:17:04Z","updated_at":"2016-03-23T18:17:04Z","html_url":"https://github.com/ethereum/solidity/pull/402#discussion_r57210166","pull_request_url":"https://api.github.com/repos/ethereum/solidity/pulls/402","_links":{"self":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/comments/57210166"},"html":{"href":"https://github.com/ethereum/solidity/pull/402#discussion_r57210166"},"pull_request":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/402"}}},"pull_request":{"url":"https://api.github.com/repos/ethereum/solidity/pulls/402","id":59876785,"html_url":"https://github.com/ethereum/solidity/pull/402","diff_url":"https://github.com/ethereum/solidity/pull/402.diff","patch_url":"https://github.com/ethereum/solidity/pull/402.patch","issue_url":"https://api.github.com/repos/ethereum/solidity/issues/402","number":402,"state":"open","locked":false,"title":"Fixed Type initial PR","user":{"login":"VoR0220","id":7756785,"avatar_url":"https://avatars.githubusercontent.com/u/7756785?v=3","gravatar_id":"","url":"https://api.github.com/users/VoR0220","html_url":"https://github.com/VoR0220","followers_url":"https://api.github.com/users/VoR0220/followers","following_url":"https://api.github.com/users/VoR0220/following{/other_user}","gists_url":"https://api.github.com/users/VoR0220/gists{/gist_id}","starred_url":"https://api.github.com/users/VoR0220/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoR0220/subscriptions","organizations_url":"https://api.github.com/users/VoR0220/orgs","repos_url":"https://api.github.com/users/VoR0220/repos","events_url":"https://api.github.com/users/VoR0220/events{/privacy}","received_events_url":"https://api.github.com/users/VoR0220/received_events","type":"User","site_admin":false},"body":"This is moreso going to be a place for general review and help in constructing the type. This is the initial work here. I believe it will also need a constant literal type strictly for fixed points, and I believe that if possible, we ought to have a separate integer itself in addition to the two ints that construct the type and we should make it the size of the two combined. This would enable simple arithmetic and all we would need to do would be to keep track of where the radix point is.\r\n\r\nFrankly, my knowledge of the EVM assembly is still fairly lacking and I'm a bit shaky on how to construct the codegen, so any tips in this area are SUPER helpful. \r\n\r\nAs you can see here, currently we have:\r\n- New tokens\r\n- New type categories\r\n- Updated mechanisms in FromIdentifierOrKeyword as well as ElementaryTypeNameToken to reflect new tokens\r\n- made Integers and Rationals (formerly Integer contants) implicitly convertable to fixed types and vice versa.\r\n- added a couple of tests to ensure parsing would go over smoothly\r\n\r\nWhat we need to work on:\r\n\r\n-var is failing with rational that are of fixed type\r\n-Token::toString and Token::name is not functioning properly for fixed types of dynamic size\r\n-How are we going to implement the fixed cast for exponents? \r\n-How to assert that index access is only doable by integers in a regular array (mappings are fine for fixed types)\r\n-general assuredness of fluid transition from rational to fixed or integer\r\n-assure size capabilities can involve leading zeroes in a rational number (example: 0.0000009)\r\n-There is an optimizer failing in the sequence_number_for_calls test...need some research into why this is happening.\r\n- ElementaryTypeNameToken needs to return proper string for fixed types","created_at":"2016-02-18T22:49:36Z","updated_at":"2016-03-23T18:17:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"efad7117657af3c2380511890b6903f31ae99c16","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ethereum/solidity/pulls/402/commits","review_comments_url":"https://api.github.com/repos/ethereum/solidity/pulls/402/comments","review_comment_url":"https://api.github.com/repos/ethereum/solidity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ethereum/solidity/issues/402/comments","statuses_url":"https://api.github.com/repos/ethereum/solidity/statuses/d91a54defc03be5297def21c93903a3567e03fd5","head":{"label":"VoR0220:fixedDataType","ref":"fixedDataType","sha":"d91a54defc03be5297def21c93903a3567e03fd5","user":{"login":"VoR0220","id":7756785,"avatar_url":"https://avatars.githubusercontent.com/u/7756785?v=3","gravatar_id":"","url":"https://api.github.com/users/VoR0220","html_url":"https://github.com/VoR0220","followers_url":"https://api.github.com/users/VoR0220/followers","following_url":"https://api.github.com/users/VoR0220/following{/other_user}","gists_url":"https://api.github.com/users/VoR0220/gists{/gist_id}","starred_url":"https://api.github.com/users/VoR0220/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoR0220/subscriptions","organizations_url":"https://api.github.com/users/VoR0220/orgs","repos_url":"https://api.github.com/users/VoR0220/repos","events_url":"https://api.github.com/users/VoR0220/events{/privacy}","received_events_url":"https://api.github.com/users/VoR0220/received_events","type":"User","site_admin":false},"repo":{"id":47712924,"name":"solidity","full_name":"VoR0220/solidity","owner":{"login":"VoR0220","id":7756785,"avatar_url":"https://avatars.githubusercontent.com/u/7756785?v=3","gravatar_id":"","url":"https://api.github.com/users/VoR0220","html_url":"https://github.com/VoR0220","followers_url":"https://api.github.com/users/VoR0220/followers","following_url":"https://api.github.com/users/VoR0220/following{/other_user}","gists_url":"https://api.github.com/users/VoR0220/gists{/gist_id}","starred_url":"https://api.github.com/users/VoR0220/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoR0220/subscriptions","organizations_url":"https://api.github.com/users/VoR0220/orgs","repos_url":"https://api.github.com/users/VoR0220/repos","events_url":"https://api.github.com/users/VoR0220/events{/privacy}","received_events_url":"https://api.github.com/users/VoR0220/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/VoR0220/solidity","description":"The Solidity Contract-Oriented Programming Language","fork":true,"url":"https://api.github.com/repos/VoR0220/solidity","forks_url":"https://api.github.com/repos/VoR0220/solidity/forks","keys_url":"https://api.github.com/repos/VoR0220/solidity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoR0220/solidity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoR0220/solidity/teams","hooks_url":"https://api.github.com/repos/VoR0220/solidity/hooks","issue_events_url":"https://api.github.com/repos/VoR0220/solidity/issues/events{/number}","events_url":"https://api.github.com/repos/VoR0220/solidity/events","assignees_url":"https://api.github.com/repos/VoR0220/solidity/assignees{/user}","branches_url":"https://api.github.com/repos/VoR0220/solidity/branches{/branch}","tags_url":"https://api.github.com/repos/VoR0220/solidity/tags","blobs_url":"https://api.github.com/repos/VoR0220/solidity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoR0220/solidity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoR0220/solidity/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoR0220/solidity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoR0220/solidity/statuses/{sha}","languages_url":"https://api.github.com/repos/VoR0220/solidity/languages","stargazers_url":"https://api.github.com/repos/VoR0220/solidity/stargazers","contributors_url":"https://api.github.com/repos/VoR0220/solidity/contributors","subscribers_url":"https://api.github.com/repos/VoR0220/solidity/subscribers","subscription_url":"https://api.github.com/repos/VoR0220/solidity/subscription","commits_url":"https://api.github.com/repos/VoR0220/solidity/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoR0220/solidity/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoR0220/solidity/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoR0220/solidity/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoR0220/solidity/contents/{+path}","compare_url":"https://api.github.com/repos/VoR0220/solidity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoR0220/solidity/merges","archive_url":"https://api.github.com/repos/VoR0220/solidity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoR0220/solidity/downloads","issues_url":"https://api.github.com/repos/VoR0220/solidity/issues{/number}","pulls_url":"https://api.github.com/repos/VoR0220/solidity/pulls{/number}","milestones_url":"https://api.github.com/repos/VoR0220/solidity/milestones{/number}","notifications_url":"https://api.github.com/repos/VoR0220/solidity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoR0220/solidity/labels{/name}","releases_url":"https://api.github.com/repos/VoR0220/solidity/releases{/id}","deployments_url":"https://api.github.com/repos/VoR0220/solidity/deployments","created_at":"2015-12-09T19:11:37Z","updated_at":"2016-01-11T03:36:48Z","pushed_at":"2016-03-22T00:43:01Z","git_url":"git://github.com/VoR0220/solidity.git","ssh_url":"git@github.com:VoR0220/solidity.git","clone_url":"https://github.com/VoR0220/solidity.git","svn_url":"https://github.com/VoR0220/solidity","homepage":"","size":7685,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"ethereum:develop","ref":"develop","sha":"e759a248165b3141495a789fad158eef0cc22ac6","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":40892817,"name":"solidity","full_name":"ethereum/solidity","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/solidity","description":"The Solidity Contract-Oriented Programming Language","fork":false,"url":"https://api.github.com/repos/ethereum/solidity","forks_url":"https://api.github.com/repos/ethereum/solidity/forks","keys_url":"https://api.github.com/repos/ethereum/solidity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/solidity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/solidity/teams","hooks_url":"https://api.github.com/repos/ethereum/solidity/hooks","issue_events_url":"https://api.github.com/repos/ethereum/solidity/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/solidity/events","assignees_url":"https://api.github.com/repos/ethereum/solidity/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/solidity/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/solidity/tags","blobs_url":"https://api.github.com/repos/ethereum/solidity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/solidity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/solidity/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/solidity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/solidity/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/solidity/languages","stargazers_url":"https://api.github.com/repos/ethereum/solidity/stargazers","contributors_url":"https://api.github.com/repos/ethereum/solidity/contributors","subscribers_url":"https://api.github.com/repos/ethereum/solidity/subscribers","subscription_url":"https://api.github.com/repos/ethereum/solidity/subscription","commits_url":"https://api.github.com/repos/ethereum/solidity/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/solidity/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/solidity/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/solidity/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethereum/solidity/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/solidity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/solidity/merges","archive_url":"https://api.github.com/repos/ethereum/solidity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/solidity/downloads","issues_url":"https://api.github.com/repos/ethereum/solidity/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/solidity/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/solidity/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/solidity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/solidity/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/solidity/releases{/id}","deployments_url":"https://api.github.com/repos/ethereum/solidity/deployments","created_at":"2015-08-17T12:27:26Z","updated_at":"2016-03-23T14:36:33Z","pushed_at":"2016-03-23T11:02:23Z","git_url":"git://github.com/ethereum/solidity.git","ssh_url":"git@github.com:ethereum/solidity.git","clone_url":"https://github.com/ethereum/solidity.git","svn_url":"https://github.com/ethereum/solidity","homepage":"","size":9789,"stargazers_count":123,"watchers_count":123,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":69,"mirror_url":null,"open_issues_count":57,"forks":69,"open_issues":57,"watchers":123,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/402"},"html":{"href":"https://github.com/ethereum/solidity/pull/402"},"issue":{"href":"https://api.github.com/repos/ethereum/solidity/issues/402"},"comments":{"href":"https://api.github.com/repos/ethereum/solidity/issues/402/comments"},"review_comments":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/402/comments"},"review_comment":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/402/commits"},"statuses":{"href":"https://api.github.com/repos/ethereum/solidity/statuses/d91a54defc03be5297def21c93903a3567e03fd5"}}}}