ktye / w Goto Github PK
View Code? Open in Web Editor NEWwebassembly compiler
webassembly compiler
webassembly compiler (github.com/ktye/w) write wasm by hand, but more compact than wat (source file has same size as wasm binary) add:I:II{x+y} /exported function sum.I:I {x/x+:i;x} /private function mac: {a:3;b:5} /flat macro 0: {add;sum} /function table sin:F:F {} /imported function (from module "ext") 256!{010203ff} /data section types are I(i32) F(f64) no preference apl style x*a+b, but lhs is evaluted first: x a b + * arguments x,y,z,x3,x4,.. are typed in the function declaration f:R:XYZ.. locals are detected at evaluation order (type is derived) r:x+y memory/heap C x;I x;F x (get from addr x) x::y (write y to addr x), also x::C?y a;b;c sequence. c(last) returns a typed value all others must return null x?y if x then y $[a;b;c;d;e] if a then b elseif c then d else e x/y n-loop execute-y x-times (x evaluates to I, y must be null) creates implicit local i, and n if x is an expression. no nesting. x?/y while x do y (y must have no type) C?x I?x F?x I?'x type conversions ?'(signed) sum x ; x add y named function call, dyad(infix), names can be defined later 8:{f;g;h} add f,g,h to function table starting at offset 8 (I.x+1)(a;b) call indirect: return type I, function index x+1, args a b build $ go build w.go $ ./w j.w > j.wasm examples file size(w) size(wasm) what try online j.w 2642 2576 stack language ktye.github.io/j k3.w 20803 20963 k interpreter ktye.github.io/zoo/#kw # a complete wasm module (11 bytes input / 50 bytes output): $ echo "f:I:II{x+y}" | w | xxd 0000000: 0061 736d 0100 0000 0107 0160 027f 7f01 .asm.......`.... 0000010: 7f03 0201 0005 0301 0001 070b 0203 6d65 ..............me 0000020: 6d02 0001 6600 000a 0901 0700 2000 2001 m...f....... . . 0000030: 6a0b ^^^^ ^^^^ j. ^^add(i32) locX locY see also github.com/ktye/wg (uses go subset as source instead of custom language) much easier to debug because the program runs as go as it is. but not as compact.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.