{"action":"closed","number":8,"pull_request":{"url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/pulls/8","id":177319393,"html_url":"https://github.com/MikeInnes/Charlotte.jl/pull/8","diff_url":"https://github.com/MikeInnes/Charlotte.jl/pull/8.diff","patch_url":"https://github.com/MikeInnes/Charlotte.jl/pull/8.patch","issue_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/issues/8","number":8,"state":"closed","locked":false,"title":"WIP: Import-export support","user":{"login":"tshort","id":636420,"avatar_url":"https://avatars2.githubusercontent.com/u/636420?v=4","gravatar_id":"","url":"https://api.github.com/users/tshort","html_url":"https://github.com/tshort","followers_url":"https://api.github.com/users/tshort/followers","following_url":"https://api.github.com/users/tshort/following{/other_user}","gists_url":"https://api.github.com/users/tshort/gists{/gist_id}","starred_url":"https://api.github.com/users/tshort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tshort/subscriptions","organizations_url":"https://api.github.com/users/tshort/orgs","repos_url":"https://api.github.com/users/tshort/repos","events_url":"https://api.github.com/users/tshort/events{/privacy}","received_events_url":"https://api.github.com/users/tshort/received_events","type":"User","site_admin":false},"body":"This is a sibling PR that goes with https://github.com/MikeInnes/WebAssembly.jl/pull/4. The goal is to add support for importing and exporting functions. Exporting works now. This gets us some of the way toward #3:\r\n\r\n```julia\r\njulia> function mathfun(x)\r\n           2x\r\n       end\r\nmathfun (generic function with 1 method)\r\n\r\njulia> function mathfun2(x, y)\r\n           2x + y\r\n       end\r\nmathfun2 (generic function with 2 methods)\r\n\r\njulia> m = wasm_module([mathfun => Tuple{Float64},\r\n                        mathfun2 => Tuple{Float64, Float64}])\r\n(module\r\n  (export \"mathfun\" (func $mathfun))\r\n  (export \"mathfun2\" (func $mathfun2))\r\n  (func $mathfun  (param f64) (result f64)\r\n    (i64.const 2)\r\n    (f64.convert_s/i64)\r\n    (get_local 0)\r\n    (f64.mul)\r\n    (return))\r\n  (func $mathfun2  (param f64) (param f64) (result f64)\r\n    (i64.const 2)\r\n    (f64.convert_s/i64)\r\n    (get_local 0)\r\n    (f64.mul)\r\n    (get_local 1)\r\n    (f64.add)\r\n    (return)))\r\n```\r\nThat seems to work when pasted into https://cdn.rawgit.com/WebAssembly/wabt/aae5a4b7/demo/wat2wasm/. \r\n\r\nImporting still needs some work. This PR adds a macro to support importing:\r\n\r\n```julia\r\n@wasm_import sin(Float64)::Float64 in env\r\n```\r\nThat syntax means: create a function `sin` from JS/wasm environment `env`. Argument types and return types are specified. As far as naming, one alternative to `@wasm_import` is `@extern` if we don't want the `wasm_` prefix.\r\n\r\nTo finish the importing part, I need to find where methods are parsed and look for the `:meta` attached to wasm imports. Then, an import needs to be added to the module, and the function needs to be replaced with a call to the imported function. \r\n\r\nThe most invasive aspect of this PR is that I passed in a wasm module `m` to all of the `towasm` methods. That's to allow imports to be added to the wasm module when they're encountered during parsing.\r\n","created_at":"2018-03-25T23:59:42Z","updated_at":"2018-04-07T01:01:24Z","closed_at":"2018-04-07T01:01:24Z","merged_at":null,"merge_commit_sha":"d91f5585905bb7164775192e22b7adc55152c609","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/pulls/8/commits","review_comments_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/pulls/8/comments","review_comment_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/issues/8/comments","statuses_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/statuses/f56f8d89865483a65a2bdd71ca5e630b139e3058","head":{"label":"tshort:import-export","ref":"import-export","sha":"f56f8d89865483a65a2bdd71ca5e630b139e3058","user":{"login":"tshort","id":636420,"avatar_url":"https://avatars2.githubusercontent.com/u/636420?v=4","gravatar_id":"","url":"https://api.github.com/users/tshort","html_url":"https://github.com/tshort","followers_url":"https://api.github.com/users/tshort/followers","following_url":"https://api.github.com/users/tshort/following{/other_user}","gists_url":"https://api.github.com/users/tshort/gists{/gist_id}","starred_url":"https://api.github.com/users/tshort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tshort/subscriptions","organizations_url":"https://api.github.com/users/tshort/orgs","repos_url":"https://api.github.com/users/tshort/repos","events_url":"https://api.github.com/users/tshort/events{/privacy}","received_events_url":"https://api.github.com/users/tshort/received_events","type":"User","site_admin":false},"repo":{"id":126689728,"name":"Charlotte.jl","full_name":"tshort/Charlotte.jl","owner":{"login":"tshort","id":636420,"avatar_url":"https://avatars2.githubusercontent.com/u/636420?v=4","gravatar_id":"","url":"https://api.github.com/users/tshort","html_url":"https://github.com/tshort","followers_url":"https://api.github.com/users/tshort/followers","following_url":"https://api.github.com/users/tshort/following{/other_user}","gists_url":"https://api.github.com/users/tshort/gists{/gist_id}","starred_url":"https://api.github.com/users/tshort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tshort/subscriptions","organizations_url":"https://api.github.com/users/tshort/orgs","repos_url":"https://api.github.com/users/tshort/repos","events_url":"https://api.github.com/users/tshort/events{/privacy}","received_events_url":"https://api.github.com/users/tshort/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tshort/Charlotte.jl","description":"Charlotte's Web Scale","fork":true,"url":"https://api.github.com/repos/tshort/Charlotte.jl","forks_url":"https://api.github.com/repos/tshort/Charlotte.jl/forks","keys_url":"https://api.github.com/repos/tshort/Charlotte.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tshort/Charlotte.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tshort/Charlotte.jl/teams","hooks_url":"https://api.github.com/repos/tshort/Charlotte.jl/hooks","issue_events_url":"https://api.github.com/repos/tshort/Charlotte.jl/issues/events{/number}","events_url":"https://api.github.com/repos/tshort/Charlotte.jl/events","assignees_url":"https://api.github.com/repos/tshort/Charlotte.jl/assignees{/user}","branches_url":"https://api.github.com/repos/tshort/Charlotte.jl/branches{/branch}","tags_url":"https://api.github.com/repos/tshort/Charlotte.jl/tags","blobs_url":"https://api.github.com/repos/tshort/Charlotte.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tshort/Charlotte.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tshort/Charlotte.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/tshort/Charlotte.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tshort/Charlotte.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/tshort/Charlotte.jl/languages","stargazers_url":"https://api.github.com/repos/tshort/Charlotte.jl/stargazers","contributors_url":"https://api.github.com/repos/tshort/Charlotte.jl/contributors","subscribers_url":"https://api.github.com/repos/tshort/Charlotte.jl/subscribers","subscription_url":"https://api.github.com/repos/tshort/Charlotte.jl/subscription","commits_url":"https://api.github.com/repos/tshort/Charlotte.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/tshort/Charlotte.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/tshort/Charlotte.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/tshort/Charlotte.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/tshort/Charlotte.jl/contents/{+path}","compare_url":"https://api.github.com/repos/tshort/Charlotte.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tshort/Charlotte.jl/merges","archive_url":"https://api.github.com/repos/tshort/Charlotte.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tshort/Charlotte.jl/downloads","issues_url":"https://api.github.com/repos/tshort/Charlotte.jl/issues{/number}","pulls_url":"https://api.github.com/repos/tshort/Charlotte.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/tshort/Charlotte.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/tshort/Charlotte.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tshort/Charlotte.jl/labels{/name}","releases_url":"https://api.github.com/repos/tshort/Charlotte.jl/releases{/id}","deployments_url":"https://api.github.com/repos/tshort/Charlotte.jl/deployments","created_at":"2018-03-25T11:16:46Z","updated_at":"2018-03-25T11:16:48Z","pushed_at":"2018-04-07T00:58:27Z","git_url":"git://github.com/tshort/Charlotte.jl.git","ssh_url":"git@github.com:tshort/Charlotte.jl.git","clone_url":"https://github.com/tshort/Charlotte.jl.git","svn_url":"https://github.com/tshort/Charlotte.jl","homepage":"","size":20,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"MikeInnes:master","ref":"master","sha":"6629fd41ed005c756b36d4022e240ce9e6d10c39","user":{"login":"MikeInnes","id":2234614,"avatar_url":"https://avatars3.githubusercontent.com/u/2234614?v=4","gravatar_id":"","url":"https://api.github.com/users/MikeInnes","html_url":"https://github.com/MikeInnes","followers_url":"https://api.github.com/users/MikeInnes/followers","following_url":"https://api.github.com/users/MikeInnes/following{/other_user}","gists_url":"https://api.github.com/users/MikeInnes/gists{/gist_id}","starred_url":"https://api.github.com/users/MikeInnes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikeInnes/subscriptions","organizations_url":"https://api.github.com/users/MikeInnes/orgs","repos_url":"https://api.github.com/users/MikeInnes/repos","events_url":"https://api.github.com/users/MikeInnes/events{/privacy}","received_events_url":"https://api.github.com/users/MikeInnes/received_events","type":"User","site_admin":false},"repo":{"id":125208542,"name":"Charlotte.jl","full_name":"MikeInnes/Charlotte.jl","owner":{"login":"MikeInnes","id":2234614,"avatar_url":"https://avatars3.githubusercontent.com/u/2234614?v=4","gravatar_id":"","url":"https://api.github.com/users/MikeInnes","html_url":"https://github.com/MikeInnes","followers_url":"https://api.github.com/users/MikeInnes/followers","following_url":"https://api.github.com/users/MikeInnes/following{/other_user}","gists_url":"https://api.github.com/users/MikeInnes/gists{/gist_id}","starred_url":"https://api.github.com/users/MikeInnes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikeInnes/subscriptions","organizations_url":"https://api.github.com/users/MikeInnes/orgs","repos_url":"https://api.github.com/users/MikeInnes/repos","events_url":"https://api.github.com/users/MikeInnes/events{/privacy}","received_events_url":"https://api.github.com/users/MikeInnes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MikeInnes/Charlotte.jl","description":"Charlotte's Web Scale","fork":false,"url":"https://api.github.com/repos/MikeInnes/Charlotte.jl","forks_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/forks","keys_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/teams","hooks_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/hooks","issue_events_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/issues/events{/number}","events_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/events","assignees_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/assignees{/user}","branches_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/branches{/branch}","tags_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/tags","blobs_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/languages","stargazers_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/stargazers","contributors_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/contributors","subscribers_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/subscribers","subscription_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/subscription","commits_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/contents/{+path}","compare_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/merges","archive_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/downloads","issues_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/issues{/number}","pulls_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/labels{/name}","releases_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/releases{/id}","deployments_url":"https://api.github.com/repos/MikeInnes/Charlotte.jl/deployments","created_at":"2018-03-14T12:24:21Z","updated_at":"2018-04-01T23:30:11Z","pushed_at":"2018-04-07T00:58:28Z","git_url":"git://github.com/MikeInnes/Charlotte.jl.git","ssh_url":"git@github.com:MikeInnes/Charlotte.jl.git","clone_url":"https://github.com/MikeInnes/Charlotte.jl.git","svn_url":"https://github.com/MikeInnes/Charlotte.jl","homepage":"","size":14,"stargazers_count":14,"watchers_count":14,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":8,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":3,"open_issues":8,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MikeInnes/Charlotte.jl/pulls/8"},"html":{"href":"https://github.com/MikeInnes/Charlotte.jl/pull/8"},"issue":{"href":"https://api.github.com/repos/MikeInnes/Charlotte.jl/issues/8"},"comments":{"href":"https://api.github.com/repos/MikeInnes/Charlotte.jl/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/MikeInnes/Charlotte.jl/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/MikeInnes/Charlotte.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MikeInnes/Charlotte.jl/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/MikeInnes/Charlotte.jl/statuses/f56f8d89865483a65a2bdd71ca5e630b139e3058"}},"author_association":"NONE","merged":false,"mergeable":true,"rebaseable":true,"mergeable_state":"clean","merged_by":null,"comments":3,"review_comments":0,"maintainer_can_modify":false,"commits":4,"additions":92,"deletions":14,"changed_files":3}}
{"actor":{"display_login":"tshort"}}