Comments (3)
There seem to be multiple issues related to recent Emscripten changes.
First, Duktape does not currently support typed arrays (ArrayBuffer, UInt8Array etc) and it seems that Emscripten now requires them by default. Setting EMCC_FAST_COMPILER=0 in the env is needed to avoid this issue.
Then there is another issue with the following regexp in Emscripten generated output:
var sourceRegex = /^function\s\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;
The brace characters ('{' and '}') are not escaped as required. This can be fixed manually (I'll submit a pull request for Emscripten for this).
After fixing this one gets:
$ ./duk /tmp/duk-emcc-test.js
TypeError: invalid base reference for property read
duk_hobject_props.c:1938
parseJSFunc /tmp/duk-emcc-test.js:653
anon /tmp/duk-emcc-test.js:661
global /tmp/duk-emcc-test.js:714 preventsyield
This is caused by the generated code trying to parse the toString() output of a function, e.g.:
function empty() {/* source code */}
The (fixed) regexp does not match this (which seems incorrect) but does match e.g.:
function () {}
The E5 spec only requires that function toString() output be in valid syntax (E5 Section 15.3.4.2):
An implementation-dependent representation of the function is returned. This representation
has the syntax of a FunctionDeclaration. Note in particular that the use and placement of white
space, line terminators, and semicolons within the representation String is implementation-
dependent.
The offending function is:
var sourceRegex = /^function\s\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;
function parseJSFunc(jsfunc) {
// Match the body and the return value of a javascript function source
var parsed = jsfunc.toString().match(sourceRegex).slice(1);
return {arguments : parsed[0], body : parsed[1], returnValue: parsed[2]}
}
Just as a quick fix, this makes the hello world test work again:
var sourceRegex = /^function\s\(([^)]*)\)\s*\{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?\}$/;
function parseJSFunc(jsfunc) {
// Match the body and the return value of a javascript function source
var parsed = jsfunc.toString().match(sourceRegex);
if (!parsed) { return {}; }
parsed = parsed.slice(1);
return {arguments : parsed[0], body : parsed[1], returnValue: parsed[2]}
}
from duktape.
The above comment reactivates fix_emscripten.py and adds the necessary regexp fixes to Emscripten output to allow Hello World test to work again. I'll submit fixes to Emscripten soon.
from duktape.
The util/fix_emscripten.py
now fixes a few more issues, all related to Emscripten using a few regexps outside the strict E5 syntax. There's a Ditz issue for tracking that they're submitted to Emscripten closer to 1.0, I'll close this now.
from duktape.
Related Issues (20)
- Is there a way to build this on systems without `npm`? HOT 4
- Reading JS variable within C. HOT 3
- `duk_to_pointer` shows an use-after-free HOT 1
- Json Loop
- Embedding for rust. HOT 2
- Disable usage eval in Javascript code HOT 1
- Include test suite in release tarballs
- Does Buffer have plans to support more encodings?
- Crash Scenario (duk_dup_top and embedding JSON object data within itself) - Solved HOT 4
- webpacked "hello world" from Kotlin/JS erroring out with "empty expression not allowed" HOT 3
- [HELP] Build with emcc to execute wasm on nodejs
- Object.assign throws RangeError for a large number of arguments
- Embedding Duktape in Lazarus / Free Pascal
- A possible performance problem of calling sort function with long array
- Q: Example of using JS callbacks HOT 11
- Makefile.cmdline builds a broken binary that instantly segfaults
- dukluv forward compat HOT 3
- New release? 🤔 HOT 2
- loading handlebars helpers HOT 1
- Is nested duk_pcall_* from the same thread supported? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duktape.