Compiled code improvements

Posted on
  • I've just fixed a few big issues with the online compiler, the main ones being:

    • Shift/compare operators
    • pre/postincrement behaviour
    • this in function calls
    • Error reporting (hacky, but now usually reports issues in the console window)
    • some array access types that weren't working
    • Fixed incorrect calculation of local variables (local var list not cleared between compiles!)

    You still can't do stuff like:

    • defining functions in functions
    • creating fields in objects, or global variables

    So you're a bit limited, but what you can now do is stuff like:

    function setPixel(x,y,c){
        "compiled";
        ce.reset();
        spi.write(0x2A,dc);
        spi.write(x>>8,x,(x+1)>>8,x+1);
        spi.write(0x2B,dc);
        spi.write(y>>8,y,(y+1)>>8,y+1);
        spi.write(0x2C,dc);
        spi.write(c>>8,c);
        ce.set();
      }
    

    So hopefully it can provide some nice speed improvements where IO is concerned.

    I'll update the documentation on it later on.

  • Like that a lot... will speed up communication quite a bit. Have to go back and apply to some of my past code.

  • Like

    Do you think this is working well enough to start using it in some of the IO modules (e.g., nrf24l01p)? I imagine that's where it'll get the most use.

  • Do you think this is working well enough to start using it in some of the IO modules

    Probably not quite yet. First off I'm not sure the Web IDE scans modules for code to compile yet, but also it only handles:

    function a() { "compiled"; ... }
    

    and not:

    var a = function () { "compiled"; ... }
    

    which tends to be used a lot in modules (especially when doing A.prototype.b = function() {...}.

    But when that's done then yes, it'd be really handy. Using it in some of the display drivers (especially the ones that have to define fillRect/setPixel) would provide some really big improvements.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Compiled code improvements

Posted by Avatar for Gordon @Gordon

Actions