anvaka / asmalidator

Online asm.js validator
http://anvaka.github.io/asmalidator/
MIT License
7 stars 1 forks source link

es6 in validator and asm in general #2

Open dotnetCarpenter opened 8 years ago

dotnetCarpenter commented 8 years ago

Not sure that es6 is generally supported in asm but I my guess is that it is. Currently the validator complaints about the following es6'ism in the return object:

return {
    add(id) { // es6 shorthand method name
      heap[tail >> 3] = id|0
    },
    // etc.
}
anvaka commented 8 years ago

Looking at asm.js spec I don't think export objects supports es6: http://asmjs.org/spec/latest/#external-code-and-data

Maybe I'm missing something? Please let me know

dotnetCarpenter commented 8 years ago

You might be right. I'm still learning. But I can't find anywhere, that asm.js is constrained to es5.1.

Validation of an asm.js module is specified by reference to the ECMAScript grammar, but conceptually operates at the level of abstract syntax. In particular, an asm.js validator must obey the following rules:

Empty statements (;) are always ignored, whether in the top level of a module or inside an asm.js function body. No variables bound anywhere in an asm.js module (whether in the module function parameter list, global variable declarations, asm.js function names, asm.js function parameters, or local variable declarations) may have the name eval or arguments. Where it would otherwise parse equivalently in JavaScript, parentheses are meaningless. Even where the specification matches on specific productions of Expression such as literals, the source may contain extra meaningless parentheses without affecting validation. Automatic semicolon insertion is respected. An asm.js source file may omit semicolons wherever JavaScript allows them to be omitted.

These rules are otherwise left implicit in the rest of the specification.

Although there is a link to the es5.1 specification (ECMAScript grammar)