ziyu123 / koalajs Goto Github PK
View Code? Open in Web Editor NEWThis project forked from lovekoala/tinyjsmobile
A JS-Native Framework
License: Apache License 2.0
This project forked from lovekoala/tinyjsmobile
A JS-Native Framework
License: Apache License 2.0
.Author Misa.Z [email protected] .About Bytecode compiler and vm are all wrote by Misa.Z. .How to do arm cross compile on mac osx: download arm-toolchain for macosx from: https://github.com/downloads/UnhandledException/ARMx/ARMx-2009q3-67.tar.bz2 tar -zx -C ./ --strip-components 1 -f ARMx-2009q3-67.tar.bz2 add the path which has 'arm-none-linux-gnueabi-g++' to default paths. ---------------------------------------------------------------------------------------- KoalaJS source code reading guide. by Misa.Z([email protected]) ---------------------------------------------------------------------------------------- Directories: | +- demos : Demos for embedded KoalaJS in your c++ project. +- jsvm : Bytecode compiler and virtual machine. +- utils : 3rd libs. +- native : native class/functions extend. +- test : test and demo scripts. 1.Bytecode design (Bytecode.h, Bytecode.cpp) TinysJS bytecode has been designed by very simple way, it has only two parts: "instruction set" and "string table". Instruction is 32 bits size with 16 bits high for instruction code (short as INSTR), and 16 bit low for short int (SINT) or offset of string table (SOFF). Instruction set: ------------------- | 32 bits | ------------------- | instruction 0 | | instruction 1 | | instruction 2 | | ...... | | instruction n-1 | | instruction n | ------------------- String table: ----------------- |index | string | ----------------- | 0 | str 0 | | 1 | str 1 | ----------------- Instruction: (defined in Instr.h) ------------------------- | 16 bits | 16 bits | ------------------------- | INSTR | SINT/SOFF | ------------------------- For example: push string variable 'str1' to stack. ------------------------- | INSTR_STR | 0x0001 | ------------------------- If INSTR has no operate variable, the lower 16 bits will be filled as 0xFFFF. For example: math operate '=' ------------------------- | INSTR_ASIGN | 0xFFFF | ------------------------- How to do with 32 bits INT and FLOAT, INSTR_INT or INSTR_FLOAT will be set the INT or FLOAT value as next instruction. For example: int 655360 ------------------------- | INSTR_INT | 0xFFFF | ------------------------- | 0x000A0000 | ------------------------- 2. Bytecode file format Bytecode file has two parts: string table and instructions. ---------------- | string table | ---------------- | instructions | ---------------- like this: ---------------------------------- | str0 len(4 bits) | string 0 | ---------------------------------- | str1 len | string 1 | ---------------------------------- | ...... | ---------------------------------- | str(n-1) len | string(n-1) | ---------------------------------- | str(n) len | string(n) | ---------------------------------- | len = 0 for end of table | ---------------------------------- | instructions | ---------------------------------- 3. Stack VM KoalaJS virtual machine runing as a typical stack machine, that means push variables to stack before operate, pop variables from stack and operate, then push the result back to stack. For example: Script code: name = "Misa"; Run as: load name ; load variable $name and push it to stack str "Misa" ; push string "Misa" to stack. asign ; pop "Misa", pop $name, and asign "Misa" to $name, and push value of $name to stack. pop ; pop and drop. Bytecode: -------string table-------------------- 0000: name 0001: Misa --------------------------------------- 0000 0x00030000 ; load name 0001 0x00090001 ; str "Misa" 0002 0x0006FFFF ; asign 0003 0x0080FFFF ; pop
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.