Code Monkey home page Code Monkey logo

blazex's People

Contributors

devhypercoder avatar gitter-badger avatar n0t-r0n1t avatar paulotten avatar romeah-zz avatar thatanonyg 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

Watchers

 avatar  avatar  avatar

blazex's Issues

SymbolTable & Context Issue

var a = 0;

fun sum_to_a(b) => {
       a = a + b;
       return a;
}

var c = sum_to_a(5);

println(c == a); @ false
println(a) @ 0
println(c) @ 5

In this case when the function sum_to_a and variable a is defined the context table looks something like

Context {
    symbol_table: [Symbol(a, 0), Symbol(sum_to_a, fun() -> int)],
    parent: Context {
        symbol_table: [...global functions...],
        parent: None
    }
}

but after calling the function a new context which has the previous context as it's context, due to the get_and_set method in SymbolTable struct, it only sets a new value to the table if the table has a existing variable, and for VarReassignNode, this method is used but for some reasons in the function the Symbol is set to the nearest SymbolTable rather than the one in which the variable is present as a result the function returns the sum but the variable stays the same...

Over-cloning in code which results in unintended behaviour

class Main {
    @ property
    var a = 0;

    @ constructor
    fun() => { 
        a = a + 1;
        sum_to_a(5);
    }

    @ method
    fun sum_to_a(new_a) => {
    	a = new_a;
    }
}

var main_ins = new Main();
println(main_ins);

main_ins.sum_to_a(4);
println(main_ins);

The output will be something like

{
     a: 5,
     sum_to_a: fun sum_to_a(new_a)
}
Runtime Error: Variable not found to be reassigned
File examples/main.bzs, line 13

 
    a = new_a
    ^^^^^^^^^^
Traceback (most recent call last):
    at Function<sum_to_a>
    at examples/main.bzs

Here what happens is that after the class in initialized i.e the constructor is ran it returns a Object of the properties and it's methods but this results in popping of the context, so when the function is accessed after initialization, the method is returned but the context which consisted of the properties and other methods in not present.
The Class Initialization related code

Any help or pull requests are greatly appreciated...

Classes don't function as intended

class A {
	var a = 0;
	fun() => {
		soul.a = 69;
	}
	fun return_soul() {
		return soul;
	}
}

For a code like this when you do new A().a it returns 0 for some reasons even though we use Rc<RefCell<Konstants>> for storing variables and other symbols, and when <A>.return_soul() is called the soul isn't in the scope and therefore not accessible. Any help or contribution is appreciated.

Inconsistency of BlazeVM

The BlazeVM is being inconsistent.
To reproduce:

  1. Clone the repository
  2. Run cargo run -- examples/main.bzs and cargo run --quiet -- examples/main.bze multiple times.
  3. Sometimes the execution will just run on forever.
    Screenshot from 2021-05-08 20-09-54

Closures

Closures aren't implemented yet i have no idea on how to.
So for a program like

fun a(i) => {
        fun() => { i }
}
----Blazescript compiler----
Version: 0.0.1
File: examples/main.bzs
Compilation Success: Wrote to examples/main.bze
Time taken for Compilation Process: 1 milliseconds
----Blaze Virtual Machine----
Version: 0.0.1
File: examples/main.bze
thread 'main' panicked at 'Variable not found', crates/blaze_vm/src/lib.rs:350:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

after a(i)() is called the function context gets dropped, which doesn't leave behind any symbol to i, this can be solved by closures but i have currently no clue on how i can implement em. Any contribution or help of any sort is appreciated.

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.