jazz-lang / jazzlight Goto Github PK
View Code? Open in Web Editor NEWSimple and clear embedabble programming language
License: MIT License
Simple and clear embedabble programming language
License: MIT License
var fac = function(x) if x < 2 return 1 else return fac(x - 1) * x
Produces this code:
global count: 1
fields count: 1
code size: 27
globals:
function at 1, nargs 1
fields:
fac => 0xdcb97918fedffaf1
code:
0: Jump 17
1: LdInt 0
2: LdLocal 0
3: Eq
4: JumpIfNot 7
5: LdInt 1
6: Ret
7: Nop
8: LdLocal 0
9: LdInt 1
10: LdLocal 0
11: Sub
12: LdGlobal 0
13: Call 1
14: Mul
15: Ret
16: Ret
17: LdGlobal 1 // This thing causes error
18: SetLocal 0
19: LdInt 5
20: LdLocal 0
21: Call 1
22: LdBuiltin 2
23: Call 1
24: LdBuiltin 255
25: LdLocal 0
26: SetField -2541867366411666703
And if we try to run that bytecode we get this error:
root@server:~/JazzLight# jazz-vm/target/debug/jazzvm factorial.j
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', /rustc/929b48ec98aaff2239257574b5897f419cec2647/src/libcore/slice/mod.rs:2681:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
(Thanks to @naturallymitchell for issue)
root@server:~/JazzLight# jazz-vm/target/debug/jazzvm examples/file.j
thread 'main' panicked at 'index out of bounds: the len is 148 but the index is 148', /rustc/929b48ec98aaff2239257574b5897f419cec2647/src/libcore/slice/mod.rs:2681:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
root@server:~/JazzLight# jazz-vm/target/debug/jazzvm factorial.j
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', /rustc/929b48ec98aaff2239257574b5897f419cec2647/src/libcore/slice/mod.rs:2681:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
We would like to use your interpreter and language in our project called torchbear, which is a developer accelerator.
The accelerator performs many kinds of helper actions:
diff
and patch
doThose functions are coded in pure Rust and need to be called by user using bindings between a scripting language (that is, Jazz
) and their implementation in Rust.
We have been using Lua
, but now we are going to replace it with Jazz
.
We could probably add the ability for registering external functions (along with existing Jazz
built-ins) to make our bindings work. It will also allow you to code the Jazz
standard library in high performance language like Rust.
Please, tell what you think. Thanks.
Roadmap for VM:
Arc
from std. Maybe implement garbage collector from scratch.Roadmap for compiler:
var a = 2
inline_bc(
"
AccInt 1
Push
AccStack <a>
Add
"
)
var a = 2 + 3
var b = a + 2
return b
Compiles to this:
AccInt(2)
Push
AccInt(3)
Add
Push
AccStack0
Push
AccInt(2)
Add
Push
AccStack1
Ret(3)
Pop(2)
Since JazzLight now can emit and read bytecode files we need a module system for loading symbols from other bytecode files. Example:
var mod = $loadmodule("module.j")
$print(mod.name)
// module.j
$exports.name = "Module"
There are already loadmodule
function, but that function doesn't work correctly when you load and try to call a function from some module.
TODO List
[x] Read bytecode files and get all exports
[x] Read functions from these files properly and allow executing that functions.
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.