GithubHelp home page GithubHelp logo

jazzlight's People

Contributors

playxe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jazzlight's Issues

Fix recursive functions

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)

index out of bounds errors

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.

Registering an external function

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:

  • generating IDs, UUIDs, random strings etc.
  • comparing and patching files just like diff and patch do
  • many-many math functions
  • Full list

Those 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.

Finishing new VM implementation and compiler

Roadmap for VM:

  • Multithreading without using Arc from std. Maybe implement garbage collector from scratch.
  • x64 JIT Compiler
  • TailCall implementation
  • Calls and object operations
  • Binary operations

Roadmap for compiler:

  • Function compilation
  • Handle global variables
  • Try/Throw implementation
  • Inline bytecode
    Example:
var a = 2
inline_bc(
"
AccInt 1
Push
AccStack <a>
Add 
"
)
  • Simple compilation.
    For now code with simple arithmetic operations and variable initialization compiles
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)

Module system

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.

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.