Skip to content

Commit 06f9940

Browse files
committed
Experimenting with inline-assembler-ish explicit builtins
Starting with explicit loads and stores as part of the respective type namespaces. Might become handy for use with portable code, because these can be polyfilled, while load<T> and store<T> can't.
1 parent d445608 commit 06f9940

File tree

18 files changed

+1372
-281
lines changed

18 files changed

+1372
-281
lines changed

bin/asc.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,12 +803,9 @@ function printStats(stats, output) {
803803

804804
exports.printStats = printStats;
805805

806-
var allocBuffer = null;
807-
if (typeof global !== "undefined" && global.Buffer) {
808-
allocBuffer = function (len) { return Buffer.allocUnsafe(len) };
809-
} else {
810-
allocBuffer = function (len) { return new Uint8Array(len) };
811-
}
806+
var allocBuffer = typeof global !== "undefined" && global.Buffer
807+
? global.Buffer.allocUnsafe || function(len) { return new global.Buffer(len); }
808+
: function(len) { return new Uint8Array(len) };
812809

813810
/** Creates a memory stream that can be used in place of stdout/stderr. */
814811
function createMemoryStream(fn) {

dist/asc.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/asc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assemblyscript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assemblyscript.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/game-of-life/assembly/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// see: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
22

3-
// Configuration imported from JS. On the WASM side, colors are handled in ABGR order (alpha, blue,
4-
// green, red) because WASM is little endian. Doing so makes it possible to just copy the entire
5-
// ABGR memory in little endian byte order to the RGBA image buffer in big endian byte order.
3+
// Configuration imported from JS. On the WASM side, 32-bit color values are modified in ABGR order
4+
// (alpha, blue, green, red) because WASM is little endian. This results in RGBA in memory, which is
5+
// exactly what the image buffer, composed of 8-bit components, expects on the JS side.
66
declare const BGR_ALIVE: u32;
77
declare const BGR_DEAD: u32;
88
declare const BIT_ROT: u32;

lib/lint/base.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
"no-require-imports": {
8080
"severity": "error"
8181
},
82-
"no-shadowed-variable": {},
8382
"no-sparse-arrays": {},
8483
"no-string-literal": {
8584
"severity": "error"

0 commit comments

Comments
 (0)