gmh5225 / wrench Goto Github PK
View Code? Open in Web Editor NEWThis project forked from jingoro2112/wrench
practical embedded script interpreter
License: MIT License
This project forked from jingoro2112/wrench
practical embedded script interpreter
License: MIT License
http://northarc.com/wrench/www/ A full-featured compiler+interpreter that uses a bare minimum of ram and program space. How little? The wrench Virtual Machine compiles to ~26k on an Arduino, and uses less than 700 Bytes of RAM to operate, it is fully functional on an Uno Mini. Highlights: - Weakly typed, supporting native 32-bit int, float and string. Code is easy to write and intuitive. - Optimizing compiler and very fast VM - Produces very compact endian-neutral bytecode: compile-anywhere-run-anywhere. - Executes from ROM, no local copy of the code is made - Multiple concurrent contexts supported - Code is easy to write, imagine c with the typenames removed; that's pretty much it. - Supports everything a good interpreter should: if/then/else/do/while/for/switch/functions/operators/etc.. - Yes structs too - Can operate directly on native data without thunking - Can call back and forth to native code with minimal overhead - API is designed to be extended, that's the whole point - Memory is garbage-collected but only for dynamic arrays. Unless you are allocating/de-allocating arrays the gc _never_ runs. - MIT licence - Includes a handy command-line tool - Easy to integrate, here is a complete example: ----- Step 1: The entire source tree is included, but is wrapped up in two files, src/wrench.h and src/wrench.cpp simply include these in your build and you have everything. ----- Step 2: Here is a complete source-code example: #include <wrench.h> #include <string.h> #include <stdio.h> void print( WRState* w, const WRValue* argv, const int argn, WRValue& retVal, void* usr ) { char buf[1024]; for( int i=0; i<argn; ++i ) { printf( "%s", argv[i].asString(buf,1024) ); } } const char* wrenchCode = "print( \"Hello World!\\n\" );" "for( i=0; i<10; i++ ) " "{ " " print( i ); " "} " "print(\"\\n\"); "; int main( int argn, char** argv ) { WRState* w = wr_newState(); // create the state wr_registerFunction( w, "print", print ); // bind a function unsigned char* outBytes; // compiled code is alloc'ed int outLen; int err = wr_compile( wrenchCode, strlen(wrenchCode), &outBytes, &outLen ); // compile it if ( err == 0 ) { wr_run( w, outBytes, outLen ); // load and run the code! delete[] outBytes; // clean up } wr_destroyState( w ); return 0; } ---- Step 3: compile the above with something like: g++ -o example example.c wrench.cpp ---- Step 4: done!
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.