sfranzyshen / esp8266-arduino-javascript Goto Github PK
View Code? Open in Web Editor NEWJavaScript scripting engine Arduino IDE Library for ESP8266
License: Other
JavaScript scripting engine Arduino IDE Library for ESP8266
License: Other
Hi! Great work on this tiny JS engine, and thank you for releasing it!
I'm having some issues making it work, though.
The one-line blink example is too simple to expose the issues, it'd be great with much more advanced examples.
Here's one issue I'm seeing:
let lets you create a variable and assign a number to it. You can then increment and decrement and multiple the variable, that works.
But you can’t reassign it afterwards!
{
let hello=3;
hello=5;
}
..actually crashes the vm and the ESP!
Panic src/mjs3.c:349 void abandon(vm*, val_t): Assertion 'mjs_type(prop->key) == MJS_TYPE_STRING' failed.
Additionally, if you don’t use a block, the let variable seems to become global, and then the next eval will fail because you also can’t let the same variable name again.
Do you have a newer version you haven't gotten around to pushing to github yet, by any chance? :)
Edit: Perhaps there aren't as many issues as I initially thought. By commenting out the do_op handler for '=' it no longer crashes, but rather complains that '=' isn't a supported command -- fair enough. I can then use a workaround:
{
let hello=3;
hello-=hello; hello+=5;
}
..something akin to xor eax,eax
to zero out a register in x86 assembly.
With that, and destroying/renewing the mJS engine after any error, it seems to work OK.
That said, it'd be nice if assignment worked too. :)
Edit:
Oh come on. Comparison doesn't work either? Give me a break!
if(value > 1.0)
{
//no joy
}
Well, say what you will, mJS is certainly extensible!! :-D
mjs_ffi(vm, "ticks", (cfn_t) jsTicks, "f");
mjs_ffi(vm, "idx", (cfn_t) jsIdx, "f");
mjs_ffi(vm, "rgb", (cfn_t) jsRGB, "vfff");
mjs_ffi(vm, "hsv", (cfn_t) jsHSV, "vfff");
mjs_ffi(vm, "yb", (cfn_t) jsYellowBoost, "vi");
mjs_ffi(vm, "cw", (cfn_t) jsHSV, "vff");
mjs_ffi(vm, "sin", (cfn_t) jsSine, "ff");
mjs_ffi(vm, "pow", (cfn_t) jsPow, "fff");
mjs_ffi(vm, "abs", (cfn_t) jsAbs, "ff");
mjs_ffi(vm, "gt", (cfn_t) jsGreater, "bff");
mjs_ffi(vm, "lt", (cfn_t) jsLess, "bff");
mjs_ffi(vm, "debug", (cfn_t) jsDebug, "vsf");
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.