MCPcopy Create free account
hub / github.com/asm-js/validator

github.com/asm-js/validator @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
40 symbols 58 edges 13 files 0 documented · 0% 3 cross-repo links updated 7y ago★ 1,77434 open issues

Browse by type

Functions 40 Types & classes 0
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

asm.js

A Mozilla Research project to specify and develop the extremely optimizable subset of JS targeted by compilers like Emscripten, Mandreel, and LLJS.

~Discussion of the asm.js spec now takes place on Specifiction here.~

The spec repo hosts the source for the current asm.js Working Draft.

This repo hosts JS source code which performs asm.js validation, however as of this update, this code is not up to date with the latest working draft and is not extensively tested. Patches to update it or fix bugs are welcome though.

Example

function mymodule(stdlib, foreign, heap) {
    "use asm";

    // -------------------------------------------------------------------------
    // SECTION 1: globals

    var H32 = new stdlib.Int32Array(heap);
    var HU32 = new stdlib.Uint32Array(heap);
    var log = foreign.consoleDotLog;

    var g_i = 0;   // int global
    var g_f = 0.0; // double global

    // -------------------------------------------------------------------------
    // SECTION 2: functions

    function f(x, y) {
        // SECTION A: parameter type declarations
        x = x|0;      // int parameter
        y = +y;       // double parameter

        // SECTION B: function body
        log(x|0);     // call into FFI -- must force the sign
        log(y);       // call into FFI -- already know it's a double
        x = (x+3)|0;  // signed addition

        // SECTION C: unconditional return
        return ((((x+1)|0)>>>0)/(x>>>0))|0; // compound expression
    }

    function g() {
        g_f = +(g_i|0); // read/write globals
        return;
    }

    function g2() {
        return;
    }

    function h(i, x) {
        i = i|0;
        x = x|0;
        H32[i>>2] = x;       // shifted by log2(byte count)
        ftable_2[(x-2)&1](); // dynamic call of functions in table 2

        // no return necessary when return type is void
    }

    // -------------------------------------------------------------------------
    // SECTION 3: function tables

    var ftable_1 = [f];
    var ftable_2 = [g, g2]; // all of the same type

    // -------------------------------------------------------------------------
    // SECTION 4: exports

    return { f_export: f, goop: g };
}

License

Apache 2.0.

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 40

Languages

TypeScript100%

Modules by API surface

lib/validate.js10 symbols
lib/types.js6 symbols
test/index.js4 symbols
lib/fail.js4 symbols
test/valid/GeometricMean-umd.js3 symbols
test/valid/GeometricMean-common.js3 symbols
test/invalid/GeometricMean-type.js3 symbols
test/invalid/GeometricMean-no-export.js3 symbols
lib/asmAssert.js2 symbols
lib/report.js1 symbols
lib/env.js1 symbols

Dependencies from manifests, versioned

array-extended0.0.4 · 1×
colors1.0.3 · 1×
dict1.4.0 · 1×
esprima1.0.4 · 1×
minimist1.1.0 · 1×
nodeunit0.9.0 · 1×
pattern-match0.3.0 · 1×

For agents

$ claude mcp add validator \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page