Coder Social home page Coder Social logo

sfranzyshen / esp8266-arduino-javascript Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 2.0 37 KB

JavaScript scripting engine Arduino IDE Library for ESP8266

License: Other

C++ 0.11% C 99.89%
javascript arduino arduino-ide esp8266 esp8266-arduino arduino-library interpreter scripting-language scripting-engine scripting-interface

esp8266-arduino-javascript's People

Contributors

sfranzyshen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

esp8266-arduino-javascript's Issues

Multiple issues

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");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.