{"action":"created","comment":{"url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/comments/46240148","id":46240148,"diff_hunk":"@@ -453,26 +572,108 @@ class AsmWasmBuilderImpl : public AstVisitor {\n   }                                                                   \\\n   break\n \n+  Expression* GetLeft(BinaryOperation* expr) {\n+    if (expr->op() == Token::BIT_XOR) {\n+      return expr->left()->AsBinaryOperation()->left();\n+    } else {\n+      return expr->left();\n+    }\n+  }\n+\n   void VisitBinaryOperation(BinaryOperation* expr) {\n-    switch (expr->op()) {\n-      BINOP_CASE(Token::ADD, Add, NON_SIGNED_BINOP, true);\n-      BINOP_CASE(Token::SUB, Sub, NON_SIGNED_BINOP, true);\n-      BINOP_CASE(Token::MUL, Mul, NON_SIGNED_BINOP, true);\n-      BINOP_CASE(Token::DIV, Div, SIGNED_BINOP, false);\n-      BINOP_CASE(Token::BIT_OR, Ior, NON_SIGNED_INT_BINOP, true);\n-      BINOP_CASE(Token::BIT_XOR, Xor, NON_SIGNED_INT_BINOP, true);\n-      BINOP_CASE(Token::SHL, Shl, NON_SIGNED_INT_BINOP, true);\n-      BINOP_CASE(Token::SAR, ShrS, NON_SIGNED_INT_BINOP, true);\n-      BINOP_CASE(Token::SHR, ShrU, NON_SIGNED_INT_BINOP, true);\n-      case Token::MOD: {\n+    ConvertOperation convertOperation = MatchBinaryOperation(expr);\n+    if (convertOperation == TO_DOUBLE) {\n+      TypeIndex type = TypeIndexOf(expr->left());\n+      if (type == INT_32) {\n+        current_function_builder_->AppendCode(kExprF64SConvertI32, false);\n+      } else if (type == UINT_32) {\n+        current_function_builder_->AppendCode(kExprF64UConvertI32, false);\n+      } else if (type == FLOAT_32) {\n+        current_function_builder_->AppendCode(kExprF64ConvertF32, false);\n+      } else {\n         UNREACHABLE();\n       }\n-      break;\n-      default:\n+      RECURSE(Visit(expr->left()));\n+    } else if (convertOperation == TO_INT) {\n+      TypeIndex type = TypeIndexOf(GetLeft(expr));\n+      if (type == FLOAT_32) {\n+        current_function_builder_->AppendCode(kExprI32SConvertF32, false);\n+      } else if (type == FLOAT_64) {\n+        current_function_builder_->AppendCode(kExprI32SConvertF64, false);\n+      } else {\n         UNREACHABLE();\n+      }\n+      RECURSE(Visit(GetLeft(expr)));\n+    } else if (convertOperation == AS_IS) {\n+      RECURSE(Visit(GetLeft(expr)));\n+    } else {\n+      bool visit_children = true;\n+      switch (expr->op()) {\n+        BINOP_CASE(Token::ADD, Add, NON_SIGNED_BINOP, true);\n+        BINOP_CASE(Token::SUB, Sub, NON_SIGNED_BINOP, true);\n+        BINOP_CASE(Token::MUL, Mul, NON_SIGNED_BINOP, true);\n+        BINOP_CASE(Token::DIV, Div, SIGNED_BINOP, false);\n+        BINOP_CASE(Token::BIT_OR, Ior, NON_SIGNED_INT_BINOP, true);\n+        BINOP_CASE(Token::BIT_XOR, Xor, NON_SIGNED_INT_BINOP, true);\n+        BINOP_CASE(Token::SHL, Shl, NON_SIGNED_INT_BINOP, true);\n+        BINOP_CASE(Token::SAR, ShrS, NON_SIGNED_INT_BINOP, true);\n+        BINOP_CASE(Token::SHR, ShrU, NON_SIGNED_INT_BINOP, true);\n+        case Token::MOD: {\n+          TypeIndex type = TypeIndexOf(expr->left(), expr->right(), false);\n+          if (type == INT_32) {\n+            current_function_builder_->AppendCode(kExprI32RemS, false);\n+          } else if (type == UINT_32) {\n+            current_function_builder_->AppendCode(kExprI32RemU, false);\n+          } else if (type == FLOAT_64) {\n+            ModF64(expr);\n+            visit_children = false;","path":"src/wasm/asm-wasm-builder.cc","position":248,"original_position":248,"commit_id":"6d1aee7440abfc7652d9a04ceb9b2697fabbc292","original_commit_id":"6d1aee7440abfc7652d9a04ceb9b2697fabbc292","user":{"login":"flagxor","id":7519520,"avatar_url":"https://avatars.githubusercontent.com/u/7519520?v=3","gravatar_id":"","url":"https://api.github.com/users/flagxor","html_url":"https://github.com/flagxor","followers_url":"https://api.github.com/users/flagxor/followers","following_url":"https://api.github.com/users/flagxor/following{/other_user}","gists_url":"https://api.github.com/users/flagxor/gists{/gist_id}","starred_url":"https://api.github.com/users/flagxor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flagxor/subscriptions","organizations_url":"https://api.github.com/users/flagxor/orgs","repos_url":"https://api.github.com/users/flagxor/repos","events_url":"https://api.github.com/users/flagxor/events{/privacy}","received_events_url":"https://api.github.com/users/flagxor/received_events","type":"User","site_admin":false},"body":"This might be more readable as a return; without an extra variable.","created_at":"2015-12-01T04:52:12Z","updated_at":"2015-12-01T04:52:12Z","html_url":"https://github.com/WebAssembly/v8-native-prototype/pull/74#discussion_r46240148","pull_request_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/comments/46240148"},"html":{"href":"https://github.com/WebAssembly/v8-native-prototype/pull/74#discussion_r46240148"},"pull_request":{"href":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/74","id":51429628,"html_url":"https://github.com/WebAssembly/v8-native-prototype/pull/74","diff_url":"https://github.com/WebAssembly/v8-native-prototype/pull/74.diff","patch_url":"https://github.com/WebAssembly/v8-native-prototype/pull/74.patch","issue_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/issues/74","number":74,"state":"open","locked":false,"title":"add typecast functions to asm-to-wasm","user":{"login":"aseemgarg89","id":13683642,"avatar_url":"https://avatars.githubusercontent.com/u/13683642?v=3","gravatar_id":"","url":"https://api.github.com/users/aseemgarg89","html_url":"https://github.com/aseemgarg89","followers_url":"https://api.github.com/users/aseemgarg89/followers","following_url":"https://api.github.com/users/aseemgarg89/following{/other_user}","gists_url":"https://api.github.com/users/aseemgarg89/gists{/gist_id}","starred_url":"https://api.github.com/users/aseemgarg89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aseemgarg89/subscriptions","organizations_url":"https://api.github.com/users/aseemgarg89/orgs","repos_url":"https://api.github.com/users/aseemgarg89/repos","events_url":"https://api.github.com/users/aseemgarg89/events{/privacy}","received_events_url":"https://api.github.com/users/aseemgarg89/received_events","type":"User","site_admin":false},"body":"Next - remove assignment operations that are just coercions, implement MOD, implement other loops","created_at":"2015-11-21T01:43:01Z","updated_at":"2015-12-01T04:52:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c4aea0173cf27746611a9d7ec5756cc62ded9e8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/74/commits","review_comments_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/74/comments","review_comment_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/issues/74/comments","statuses_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/statuses/6d1aee7440abfc7652d9a04ceb9b2697fabbc292","head":{"label":"aseemgarg89:master","ref":"master","sha":"6d1aee7440abfc7652d9a04ceb9b2697fabbc292","user":{"login":"aseemgarg89","id":13683642,"avatar_url":"https://avatars.githubusercontent.com/u/13683642?v=3","gravatar_id":"","url":"https://api.github.com/users/aseemgarg89","html_url":"https://github.com/aseemgarg89","followers_url":"https://api.github.com/users/aseemgarg89/followers","following_url":"https://api.github.com/users/aseemgarg89/following{/other_user}","gists_url":"https://api.github.com/users/aseemgarg89/gists{/gist_id}","starred_url":"https://api.github.com/users/aseemgarg89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aseemgarg89/subscriptions","organizations_url":"https://api.github.com/users/aseemgarg89/orgs","repos_url":"https://api.github.com/users/aseemgarg89/repos","events_url":"https://api.github.com/users/aseemgarg89/events{/privacy}","received_events_url":"https://api.github.com/users/aseemgarg89/received_events","type":"User","site_admin":false},"repo":{"id":40332647,"name":"v8-native-prototype","full_name":"aseemgarg89/v8-native-prototype","owner":{"login":"aseemgarg89","id":13683642,"avatar_url":"https://avatars.githubusercontent.com/u/13683642?v=3","gravatar_id":"","url":"https://api.github.com/users/aseemgarg89","html_url":"https://github.com/aseemgarg89","followers_url":"https://api.github.com/users/aseemgarg89/followers","following_url":"https://api.github.com/users/aseemgarg89/following{/other_user}","gists_url":"https://api.github.com/users/aseemgarg89/gists{/gist_id}","starred_url":"https://api.github.com/users/aseemgarg89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aseemgarg89/subscriptions","organizations_url":"https://api.github.com/users/aseemgarg89/orgs","repos_url":"https://api.github.com/users/aseemgarg89/repos","events_url":"https://api.github.com/users/aseemgarg89/events{/privacy}","received_events_url":"https://api.github.com/users/aseemgarg89/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aseemgarg89/v8-native-prototype","description":"Prototype native decoder that targets TurboFan","fork":true,"url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype","forks_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/forks","keys_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/teams","hooks_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/hooks","issue_events_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/issues/events{/number}","events_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/events","assignees_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/assignees{/user}","branches_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/branches{/branch}","tags_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/tags","blobs_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/git/refs{/sha}","trees_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/statuses/{sha}","languages_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/languages","stargazers_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/stargazers","contributors_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/contributors","subscribers_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/subscribers","subscription_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/subscription","commits_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/commits{/sha}","git_commits_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/git/commits{/sha}","comments_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/comments{/number}","issue_comment_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/issues/comments{/number}","contents_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/contents/{+path}","compare_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/merges","archive_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/downloads","issues_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/issues{/number}","pulls_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/pulls{/number}","milestones_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/milestones{/number}","notifications_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/labels{/name}","releases_url":"https://api.github.com/repos/aseemgarg89/v8-native-prototype/releases{/id}","created_at":"2015-08-07T00:15:11Z","updated_at":"2015-08-07T00:15:12Z","pushed_at":"2015-11-30T23:33:20Z","git_url":"git://github.com/aseemgarg89/v8-native-prototype.git","ssh_url":"git@github.com:aseemgarg89/v8-native-prototype.git","clone_url":"https://github.com/aseemgarg89/v8-native-prototype.git","svn_url":"https://github.com/aseemgarg89/v8-native-prototype","homepage":null,"size":853,"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":"master"}},"base":{"label":"WebAssembly:master","ref":"master","sha":"354ce851eff4092f9a2a9ed3c50f82d8f0d2adc7","user":{"login":"WebAssembly","id":11578470,"avatar_url":"https://avatars.githubusercontent.com/u/11578470?v=3","gravatar_id":"","url":"https://api.github.com/users/WebAssembly","html_url":"https://github.com/WebAssembly","followers_url":"https://api.github.com/users/WebAssembly/followers","following_url":"https://api.github.com/users/WebAssembly/following{/other_user}","gists_url":"https://api.github.com/users/WebAssembly/gists{/gist_id}","starred_url":"https://api.github.com/users/WebAssembly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WebAssembly/subscriptions","organizations_url":"https://api.github.com/users/WebAssembly/orgs","repos_url":"https://api.github.com/users/WebAssembly/repos","events_url":"https://api.github.com/users/WebAssembly/events{/privacy}","received_events_url":"https://api.github.com/users/WebAssembly/received_events","type":"Organization","site_admin":false},"repo":{"id":35500658,"name":"v8-native-prototype","full_name":"WebAssembly/v8-native-prototype","owner":{"login":"WebAssembly","id":11578470,"avatar_url":"https://avatars.githubusercontent.com/u/11578470?v=3","gravatar_id":"","url":"https://api.github.com/users/WebAssembly","html_url":"https://github.com/WebAssembly","followers_url":"https://api.github.com/users/WebAssembly/followers","following_url":"https://api.github.com/users/WebAssembly/following{/other_user}","gists_url":"https://api.github.com/users/WebAssembly/gists{/gist_id}","starred_url":"https://api.github.com/users/WebAssembly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WebAssembly/subscriptions","organizations_url":"https://api.github.com/users/WebAssembly/orgs","repos_url":"https://api.github.com/users/WebAssembly/repos","events_url":"https://api.github.com/users/WebAssembly/events{/privacy}","received_events_url":"https://api.github.com/users/WebAssembly/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WebAssembly/v8-native-prototype","description":"Prototype native decoder that targets TurboFan","fork":false,"url":"https://api.github.com/repos/WebAssembly/v8-native-prototype","forks_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/forks","keys_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/teams","hooks_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/hooks","issue_events_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/issues/events{/number}","events_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/events","assignees_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/assignees{/user}","branches_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/branches{/branch}","tags_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/tags","blobs_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/git/refs{/sha}","trees_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/statuses/{sha}","languages_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/languages","stargazers_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/stargazers","contributors_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/contributors","subscribers_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/subscribers","subscription_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/subscription","commits_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/commits{/sha}","git_commits_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/git/commits{/sha}","comments_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/comments{/number}","issue_comment_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/issues/comments{/number}","contents_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/contents/{+path}","compare_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/merges","archive_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/downloads","issues_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/issues{/number}","pulls_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls{/number}","milestones_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/milestones{/number}","notifications_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/labels{/name}","releases_url":"https://api.github.com/repos/WebAssembly/v8-native-prototype/releases{/id}","created_at":"2015-05-12T16:47:29Z","updated_at":"2015-11-30T07:05:35Z","pushed_at":"2015-12-01T02:58:54Z","git_url":"git://github.com/WebAssembly/v8-native-prototype.git","ssh_url":"git@github.com:WebAssembly/v8-native-prototype.git","clone_url":"https://github.com/WebAssembly/v8-native-prototype.git","svn_url":"https://github.com/WebAssembly/v8-native-prototype","homepage":null,"size":883,"stargazers_count":175,"watchers_count":175,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":14,"forks":26,"open_issues":14,"watchers":175,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/74"},"html":{"href":"https://github.com/WebAssembly/v8-native-prototype/pull/74"},"issue":{"href":"https://api.github.com/repos/WebAssembly/v8-native-prototype/issues/74"},"comments":{"href":"https://api.github.com/repos/WebAssembly/v8-native-prototype/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WebAssembly/v8-native-prototype/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/WebAssembly/v8-native-prototype/statuses/6d1aee7440abfc7652d9a04ceb9b2697fabbc292"}}}}