Closed sletz closed 8 years ago
Perhaps try to escape your code with 4-backticks (`) before and after?
It seems that the "for loop" syntax is not handled in "parseAfterKeyword" (in parse.h file)
for (i0 = 0; (((i0 | 0) < 2) | 0); i0 = (((i0 | 0) + 1) | 0)) { HEAP32[dsp + 0 + ((i0 | 0) << 2) >> 2] = 0; }
Ok, that makes sense. We have support for parsing emscripten asm.js output, which is a subset of asm.js - it never uses for loops, for example. It should be easy to add this support though, if it would be useful.
Well, our code backend currently generates "for loop" yes.
Ah, out of curiosity, what code backend is this?
FAUST (Functional Audio Stream) functional programming language specifically designed for real-time audio signal processing and synthesis (see http://faust.grame.fr)
Interesting, thanks for the info.
Ok, I just added for-loop support. I didn't test it beyond a simple testcase (see the commit), so let me know if you hit any issues
Working now, thanks!
Great, thanks for confirming.
Well I found later on that the following generated JS code is not parsed correctly. Any chance it could also be fixed?
function getJSONmydsp() { return "{ \"name\": \"Noise\", \"outputs\": \"1\", \"meta\": [ { \"author\": \"Grame\" }, { \"copyright\": \"(c)GRAME 2009\" }, { \"license\": \"BSD\" }, { \"name\": \"Noise\" }, { \"version\": \"1.1\" } ], \"ui\": [ { \"type\": \"vgroup\", \"label\": \"0x00\", \"items\": [ { \"type\": \"vslider\", \"label\": \"Volume\", \"address\": \"/0x00/Volume\", \"meta\": [ { \"style\": \"knob\" } ], \"init\": \"0\", \"min\": \"0\", \"max\": \"1\", \"step\": \"0.1\" } ] } ] } "; }
That doesn't look like valid asm.js? It doesn't have arrays or strings.
Btw, please use escaping (4 backticks "`") to make code easier to read.
OK, this is additional pure JS code that our backend adds with the asm.js module. We can live without that�
Thanks.
Le 5 janv. 2016 � 18:25, Alon Zakai notifications@github.com a �crit :
That doesn't look like valid asm.js? It doesn't have arrays or strings.
Btw, please use escaping (4 backticks "`") to make code easier to read.
� Reply to this email directly or view it on GitHub.
Crash with the following command :
bin/asm2wasm noise.js
for:
(i0 = 0; (((i0 | 0) < 2) | 0); i0 = (((i0 | 0) + 1) | 0)) { HEAP32[dsp + 0 + ((i0 | 0) << 2) >> 2] = 0;
Abort trap: 6
Noise.js file content is :
/* ------------------------------------------------------------ author: "Grame" copyright: "(c)GRAME 2009" license: "BSD" name: "Noise" version: "1.1" Code generated with Faust 2.0.a41 (http://faust.grame.fr) ------------------------------------------------------------ */
function mydspModule(global, foreign, buffer) {
}
function getSizemydsp() { return 16; }
function getPathTablemydsp() {
}
function getJSONmydsp() { return "{ \"name\": \"Noise\", \"outputs\": \"1\", \"meta\": [ { \"author\": \"Grame\" }, { \"copyright\": \"(c)GRAME 2009\" }, { \"license\": \"BSD\" }, { \"name\": \"Noise\" }, { \"version\": \"1.1\" } ], \"ui\": [ { \"type\": \"vgroup\", \"label\": \"0x00\", \"items\": [ { \"type\": \"vslider\", \"label\": \"Volume\", \"address\": \"/0x00/Volume\", \"meta\": [ { \"style\": \"knob\" } ], \"init\": \"0\", \"min\": \"0\", \"max\": \"1\", \"step\": \"0.1\" } ] } ] } "; }
function metadatamydsp(m) { m.declare("author", "Grame"); m.declare("copyright", "(c)GRAME 2009"); m.declare("license", "BSD"); m.declare("name", "Noise"); m.declare("version", "1.1"); }
Crash log is :
bt
__pthread_kill + 10 frame #1: 0x00007fff8cdd835c libsystem_pthread.dylib
pthread_kill + 92 frame #2: 0x00007fff858e3b1a libsystemc.dylibabort + 125 frame #3: 0x000000010000f04f asm2wasm
cashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseAfterKeyword(cashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::Frag&, char&, char const) + 575 frame #4: 0x000000010000e8df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElement(char*&, char const*) + 335 frame #5: 0x000000010000e481 asm2wasm
cashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElementOrStatement(char&, char const) + 577 frame #6: 0x000000010000e0df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBlock(char*&, char const*, cashew::IString, cashew::IString) + 463 frame #7: 0x0000000100012eff asm2wasm
cashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBracketedBlock(char&) + 287 frame #8: 0x000000010001350a asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseFunction(char_&, char const_) + 922 frame #9: 0x000000010000e8df asm2wasm
cashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElement(char&, char const) + 335 frame #10: 0x000000010000e481 asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElementOrStatement(char_&, char const_) + 577 frame #11: 0x000000010000e0df asm2wasm
cashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBlock(char&, char const, cashew::IString, cashew::IString) + 463 frame #12: 0x0000000100012eff asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBracketedBlock(char_&) + 287 frame #13: 0x000000010001350a asm2wasm
cashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseFunction(char&, char const) + 922 frame #14: 0x000000010000e8df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElement(char_&, char const_) + 335 frame #15: 0x000000010000e481 asm2wasm
cashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElementOrStatement(char&, char const) + 577 frame #16: 0x000000010000e0df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBlock(char_&, char const_, cashew::IString, cashew::IString) + 463 frame #17: 0x000000010000485f asm2wasm
main + 463 frame #18: 0x00007fff8fcc15fd libdyld.dylib`start + 1