Giter Site home page Giter Site logo

bog's People

Contributors

data-man avatar garrisonhh avatar iddev5 avatar marler8997 avatar vexu avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bog's Issues

Question: is this a stack based or register based VM?

Very cool library in Zig!

Just a quick question: I’m reading the code and having a hard time determining if this is register or stack based? I’m very new to Zig syntax and I see a stack pointer (sp) variable but no actually stack-like array in the code.

I’m also see code related to register allocation but can’t find the specific registers.

For those learning can you point me to some clues in the code?

Thanks again!

Add syntax for range

# basics
let zero_to_five_step_two = 0:5:2
# any of the values can be omitted with defaults
let zero_to_five_step_one = :5
let zero_to_inf_step_five = ::5

This would mean having to changing the syntax for maps:

let map = {
-    a: 2
+    a = 2
}

Add syntax for list.append

Now that there is a append_double instruction there should probably be syntax for it.
If #9 is accepted + and << cannot be used.

Cut a release?

👋 looks like a very interesting project, any interest of tracking the stable zig and cut off a release for downstream package manager use? Thanks!

Feature request: user-defined number type

E.g.:

pub fn Vm(comptime intType: type, comptime floatType: type) {
 ...
}

var vm = bog.Vm(u128, f128).init(allocator, .{ .import_files = true });

or

pub fn Vm(comptime intBits: u8, comptime floatBits: u8) {
 ...
}

About updating to zig master

Hello,

I have been trying to port this project over to zig master from the past couple days. While I am already successful in it and all tests are passing, there is a small problem. AutoIndentingStream is removed from std lib in recent versions. For tests, I ended up copying the same source code over to here (and made slight modifications), but concern is licensing.

How I should go about from here? I have been considering somehow remaking the AIS...

My branch is here: https://github.com/iddev5/bog/tree/fix-build it is complete minus cleanup/zig fmt

Thank you.

Multilevel captures are bugged

let x = 2
const foo = fn()
    return fn()
        return x + 5

const bar = foo()
return bar()

Bytecode with fix:

function_0:
-     5 load_capture_double  0 <- [1]
+     5 load_capture_double  0 <- [0]

     6 const_int            3 <- (5)

     7 add_triple           2 <- 0 + 3

     8 return_single        2

function_1:
    13 load_capture_double  1 <- [0]

    14 build_func           0 <- function_0(0)[1]

    16 store_capture_triple 0[0] <- 1

    17 return_single        0

entry:
    20 const_int            1 <- (2)

    23 build_func           0 <- function_1(0)[1]

    25 store_capture_triple 0[0] <- 1

    28 call                 2 <- 0()

    32 call                 3 <- 2()

    34 return_single        3

Implement match

Example behavior:

const {assert} = import("std.debug")
const func = fn(val) match (val)
    let @foo(name, 0) => name + 2
    @bar => 3
    1, 2, 3 => 5
    let (foo, "true") => foo as bool
    let error(foo) => foo
    _ = 42



assert(func(@foo(2, 0)) == 4)
assert(func(@bar) == 3)
assert(func(2) == 3)
assert(func(("false", "true")) == false)
assert(func(error(2)) == 2)
assert(func("nope") == 42)

This will require some new instructions like try_unwrap_* and try_get.
Once those are implemented this should also work:

if (let (foo, "some") = x) foo + 2

Add lazy expressions

lazy expressions would be the language level equivalent of std.once. The value of the expression would only be executed once and only if needed. These would mainly be beneficial for expensive calculations that are only needed sometimes.

const {print} = import("std.io")
const {assert} = import("std.debug")
const x = lazy
    print("resolved")
    2

let y = 2
y += x # "resolved"
y += x # nothing
assert(y == 6)

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.