Title: In assemblyscript,Is there a way to check the type of a value in wasm which has been loaded by assemblyscript, example:i32? · Issue #888 · AssemblyScript/assemblyscript · GitHub
Open Graph Title: In assemblyscript,Is there a way to check the type of a value in wasm which has been loaded by assemblyscript, example:i32? · Issue #888 · AssemblyScript/assemblyscript
X Title: In assemblyscript,Is there a way to check the type of a value in wasm which has been loaded by assemblyscript, example:i32? · Issue #888 · AssemblyScript/assemblyscript
Description: -1 In the capture image,main.ts is a assemblyscript assembly/main.ts (assemblyscript) declare function sayHello(): void; sayHello() export function add(x: i32, y: i32): i32 { return x + y; } export function getTypeOf():string { let x:i32...
Open Graph Description: -1 In the capture image,main.ts is a assemblyscript assembly/main.ts (assemblyscript) declare function sayHello(): void; sayHello() export function add(x: i32, y: i32): i32 { return x + y; } export...
X Description: -1 In the capture image,main.ts is a assemblyscript assembly/main.ts (assemblyscript) declare function sayHello(): void; sayHello() export function add(x: i32, y: i32): i32 { return x + y; } export...
Opengraph URL: https://github.com/AssemblyScript/assemblyscript/issues/888
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"In assemblyscript,Is there a way to check the type of a value in wasm which has been loaded by assemblyscript, example:i32?","articleBody":"\r\n-1\r\nIn the capture image,main.ts is a assemblyscript\r\n\r\nassembly/main.ts (assemblyscript)\r\n```main.ts \r\ndeclare function sayHello(): void;\r\n\r\nsayHello()\r\n\r\nexport function add(x: i32, y: i32): i32 {\r\n return x + y;\r\n}\r\n\r\nexport function getTypeOf():string {\r\n let x:i32 = 12;\r\n return typeof x;\r\n}\r\nexport function teste(): string {\r\n let x = \"ZZZZZZZZZZZZ\"\r\n return x;\r\n}\r\n```\r\nbut the code \r\n```\r\nexport function getTypeOf():string {\r\n let x:i32 = 12;\r\n return typeof x;\r\n}\r\n```\r\n\r\nsrc/main.js\r\n```\r\n(async()=>{\r\n let buffer = await fetch(\"../out/main.wasm\");\r\n let arrayBuffer = await buffer.arrayBuffer();\r\n let lib = instantiateBuffer(arrayBuffer,{\r\n main: {\r\n sayHello() {\r\n console.log(\"Hello from WebAssembly!\");\r\n }\r\n },\r\n env: {\r\n abort(_msg, _file, line, column) {\r\n console.error(\"abort called at main.ts:\" + line + \":\" + column);\r\n }\r\n },\r\n });\r\n document.getElementById(\"container\").textContent = \"Result: \" + lib.add(19, 23) \r\n + \" Type:\" + lib.__getString(lib.getTypeOf()) \r\n + \" teste:\" + lib.__getString(lib.teste()) ;\r\n})();\r\n\r\n```\r\nlib.getTypeOf() return a ptr of a string,so I use lib.__getString(ptr) to convert ptr to string.but a value is \"number\",not the \"i32\"\r\n\r\n **### Issue: The Expected value of This Function is \"i32\",but actuality the result is \"number\"**\r\n\r\n\r\nI added a assemblyscript loader by download from 「 https://raw.githubusercontent.com/AssemblyScript/assemblyscript/master/lib/loader/index.js 」,and rename the to loader.js and put the file to folder src.\r\n\r\n\r\n**### In assemblyscript,we have i32 A 32-bit signed integer,if we load this wasm ,so we can check the type of i32?If cannot check i32 by assemblyscript,is there another way to check the value of wasm ?**\r\n[wasm-project201910070050.zip](https://github.com/AssemblyScript/assemblyscript/files/3694603/wasm-project201910070050.zip)\r\n\r\nPS:\r\nThis days ,I found the https://github.com/AssemblyScript/assemblyscript/tree/master/lib/parse \r\n ,but I don`t know the detail about the parse,is this parse can check type the type of i32?\r\n","author":{"url":"https://github.com/chooaya","@type":"Person","name":"chooaya"},"datePublished":"2019-10-06T16:06:52Z","url":"https://github.com/AssemblyScript/assemblyscript/issues/888"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:051b131d-f5ac-68db-b6a2-b43881701881 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A61E:FA439:242666:31369B:6AFC0096 |
| html-safe-nonce | 2b90ad841e0641d9d1c1cbade4db4bc4909de8e2407432dedd980b9803d83f1f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjFFOkZBNDM5OjI0MjY2NjozMTM2OUI6NkFGQzAwOTYiLCJ2aXNpdG9yX2lkIjoiNTc2NjU2NTMxNTkyNTc3MTc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 42851536bb943a856c7094d56bfef6d738d8ed5284e9544d257cb6592c7a08aa |
| hovercard-subject-tag | issue:503122002 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/AssemblyScript/assemblyscript/888/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ad2eeab7cf4f106bd2ddb61ebb129cb38e2367e06e863beb2349c9f14199caa5/AssemblyScript/assemblyscript/issues/888 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ad2eeab7cf4f106bd2ddb61ebb129cb38e2367e06e863beb2349c9f14199caa5/AssemblyScript/assemblyscript/issues/888 |
| og:image:alt | -1 In the capture image,main.ts is a assemblyscript assembly/main.ts (assemblyscript) declare function sayHello(): void; sayHello() export function add(x: i32, y: i32): i32 { return x + y; } export... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chooaya |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| turbo-cache-control | no-preview |
| go-import | github.com/AssemblyScript/assemblyscript git https://github.com/AssemblyScript/assemblyscript.git |
| octolytics-dimension-user_id | 28916798 |
| octolytics-dimension-user_login | AssemblyScript |
| octolytics-dimension-repository_id | 105138356 |
| octolytics-dimension-repository_nwo | AssemblyScript/assemblyscript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 105138356 |
| octolytics-dimension-repository_network_root_nwo | AssemblyScript/assemblyscript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width