blazify / blazex Goto Github PK
View Code? Open in Web Editor NEWAOT compiled object oriented programming language
Home Page: https://www.blazex.blazify.rocks
License: Apache License 2.0
AOT compiled object oriented programming language
Home Page: https://www.blazex.blazify.rocks
License: Apache License 2.0
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...
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...
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.
The BlazeVM is being inconsistent.
To reproduce:
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.
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.