Skip to content
Open

Dev #85

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7f30885
Remove unnecessary libraries from ellie-core with vm feature & implem…
ahmetcanaksu Mar 6, 2024
7d99387
Remove unnecessary clones from vm
ahmetcanaksu Mar 6, 2024
b1f57fd
Rewrite deep scan
ahmetcanaksu Mar 6, 2024
20b4e3f
Prototype of new constructor code
ahmetcanaksu Mar 6, 2024
c27dfa8
Fix parser duplicate items error
ahmetcanaksu Mar 10, 2024
d4368f4
Add new type transpiler implementations
ahmetcanaksu Apr 21, 2024
01bf7c1
Fix constructor errors
ahmetcanaksu Apr 21, 2024
82cb498
Fix error printing and add error handling in compile_file.rs
ahmetcanaksu Apr 21, 2024
c3fb843
Add benchmark & fix setter bug
ahmetcanaksu Apr 28, 2024
d1c19f5
Prevent main function to have parameters
ahmetcanaksu Jun 6, 2024
281edf0
Fix constructor size bug
ahmetcanaksu Jun 6, 2024
a2e0c4e
Fix old code on integration test
ahmetcanaksu Jun 6, 2024
fb990b4
Add display instead of int on panics
ahmetcanaksu Jun 6, 2024
6b5a282
Correct in boy variable defining
ahmetcanaksu Jun 7, 2024
d60eec2
Implement conversion between string and class
ahmetcanaksu Jun 7, 2024
b643817
Remove possible unnecessary parameter usage
ahmetcanaksu Jun 7, 2024
953809f
Add types to constructor
ahmetcanaksu Jun 17, 2024
0b9cf7c
Fix typos & linter errors & function parameter indexing error & void …
ahmetcanaksu Jul 3, 2024
a4ad5ae
Implement class variable and constructor function support & Implement…
ahmetcanaksu Jul 3, 2024
bc1a8d9
Buff versions
ahmetcanaksu Jul 3, 2024
95c72c4
Apply clippy
ahmetcanaksu Jul 3, 2024
e6856f3
Merge pull request #84 from behemehal/ConstructorFixes
ahmetcanaksu Jul 3, 2024
2806fb6
Add new version info
ahmetcanaksu Jul 3, 2024
97c7a1c
Update versions
ahmetcanaksu Jul 6, 2024
abb73d0
Add test _openFile function
ahmetcanaksu Sep 8, 2024
7554c85
Fix constructor variable linking issue
ahmetcanaksu Nov 30, 2024
5a6f2ac
Experiment convert_generic_by_name
ahmetcanaksu Dec 18, 2024
87f2a03
Implement more basic channel interface & fix cloak memory problems
ahmetcanaksu Jan 1, 2025
f76d4d6
Fix removed fields
ahmetcanaksu Jan 5, 2025
56bf089
Add ffi for testing
ahmetcanaksu Jan 7, 2025
1f8d166
Add ffi libs
ahmetcanaksu Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dtsvet.vscode-wasm",
"vadimcn.vscode-lldb",
"spmeesseman.vscode-taskexplorer",
"serayuzgur.crates",
"fill-labs.dependi",
"denoland.vscode-deno",
]
"rioj7.command-variable",
],
}
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"editor.smoothScrolling": true,
"workbench.editor.labelFormat": "short",
"workbench.startupEditor": "readme",
"rust-analyzer.imports.preferNoStd": "true",
"files.exclude": {
"**/ellie_engine": true,
"**/elliec": true,
Expand Down
31 changes: 19 additions & 12 deletions ellie_engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ellie_engine"
description = "Why ellie? Ellie is a type-safe programing language that runs on embedded and sandboxed environments."
version = "1.4.13-alpha"
version = "1.5.20-alpha"
authors = ["Ahmetcan Aksu <ahmetcanaksu@behemehal.org>", "Behemehal <info@behemehal.org>"]
edition = "2021"
license-file = "../LICENSE"
Expand All @@ -15,19 +15,19 @@ homepage = "https://www.ellie-lang.org"
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true }
path-absolutize = { version = "3.0.10", optional = true }
ellie_core = { path = "core", version = "0.7.2", default-features = false }
ellie_core = { path = "core", version = "0.7.3", default-features = false }
#ellie_assist = { path = "EllieAssist", version = "*", optional = true }
ellie_tokenizer = { path = "tokenizer", version = "0.6.2", default-features = false, optional = true }
ellie_parser = { path = "parser", version = "0.7.2", default-features = false, optional = true }
ellie_bytecode = { path = "bytecode", version = "0.4.3", optional = true }
ellie_vm = { path = "vm", version = "0.5.4", optional = true }
ellie_fmt = { path = "fmt", version = "0.5.2", optional = true }
ellie_tokenizer = { path = "tokenizer", version = "0.7.3", default-features = false, optional = true }
ellie_parser = { path = "parser", version = "0.8.3", default-features = false, optional = true }
ellie_bytecode = { path = "bytecode", version = "0.5.4", optional = true }
ellie_vm = { path = "vm", version = "0.6.5", optional = true }
ellie_fmt = { path = "fmt", version = "0.5.3", optional = true }
ellie_renderer_utils = { path = "renderer_utils", version = "0.3.0", optional = true, default-features = false }

[features]
default = ["vm", "compiler", "fmt", "std"]
compiler = ["ellie_tokenizer", "ellie_parser", "ellie_bytecode", "ellie_core/compiler_utils"]
vm = ["ellie_vm", "ellie_vm/std"]
vm = ["ellie_vm"]
std = ["ellie_vm/std", "ellie_core/std"]
renderer_utils = ["ellie_renderer_utils"]
fmt = ["ellie_fmt"]
Expand All @@ -37,10 +37,17 @@ cli-utils = ["ellie_renderer_utils/cli-utils"]

[build-dependencies]
path-absolutize = { version = "3.0.10" }
toml = "0.8.0"
regex = { version = "1.1.7" }
toml = "0.8.19"
regex = { version = "1.10.6" }
chrono = "0.4.22"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports", "csv_output"] }

[[bench]]
name = "compile"
harness = false

[workspace]
members = [".", "./core", "./tokenizer", "./parser", "./bytecode", "./vm", "./fmt", "./renderer_utils" ]
default-members = ["."]
members = [".", "./core", "./tokenizer", "./parser", "./bytecode", "./vm", "./fmt", "./renderer_utils"]
default-members = ["."]
158 changes: 158 additions & 0 deletions ellie_engine/benches/codes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
pub const BENCH_CLASS: &str = r#"
/// -- Required Types --
@dont_fix_variant;
class int {}

@dont_fix_variant;
class void {}


@dont_fix_variant;
class bool {}

@dont_fix_variant;
class function {}

@dont_fix_variant;
class string {}

@dont_fix_variant;
class nullAble<T> {}

fn println(s: string);
/// -- Required Types --

class Human {
co(name, age);
v name : string;
v age : int;
fn introduce() : string {
ret "Hello my name is " + self.name + ", I born at " + (2023 - self.age);
}
}


fn main() {
v human = new Human("Ahmetcan", 22);
println(human.introduce());
}
"#;

pub const BENCH_LOOP: &str = r#"
/// -- Required Types --
@dont_fix_variant;
class int {}

@dont_fix_variant;
class void {}


@dont_fix_variant;
class bool {}

@dont_fix_variant;
class function {}

@dont_fix_variant;
class string {}

@dont_fix_variant;
class nullAble<T> {}

fn println(s: string);
/// -- Required Types --

fn main() {
v last = 0;
v current = 1;
v count = 2;
v fib = 0;

loop count <= 10 {
fib = last + current;
last = current;
current = fib;
count += 1;
}

println("fib(10) = " + fib);
}
"#;

pub const BENCH_FIBONACCI_LOOP: &str = r#"
/// -- Required Types --
@dont_fix_variant;
class int {}

@dont_fix_variant;
class void {}


@dont_fix_variant;
class bool {}

@dont_fix_variant;
class function {}

@dont_fix_variant;
class string {}

@dont_fix_variant;
class nullAble<T> {}

fn println(s: string);
/// -- Required Types --

fn main() {
v last = 0;
v current = 1;
v count = 2;
v fib = 0;

loop count <= 10 {
fib = last + current;
last = current;
current = fib;
count += 1;
}

println("fib(10) = " + fib);
}
"#;

pub const BENCH_FIBONACCI_RECURSION: &str = r#"
/// -- Required Types --
@dont_fix_variant;
class int {}

@dont_fix_variant;
class void {}


@dont_fix_variant;
class bool {}

@dont_fix_variant;
class function {}

@dont_fix_variant;
class string {}

@dont_fix_variant;
class nullAble<T> {}

fn println(s: string);
/// -- Required Types --

fn main() {
fn fib(n: int) : int {
if n <= 1 {
ret n;
} else {
ret fib(n - 1) + fib(n - 2);
}
}

println("fib(10) = " + fib(10));
}
"#;
80 changes: 80 additions & 0 deletions ellie_engine/benches/compile.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use ellie_engine::{parseText};


pub mod codes;
pub mod utils;

fn tokenize(c: &mut Criterion) {
c.bench_function("class_tokenize", |b| {
b.iter(|| {
let _ = black_box(utils::tokenize_code(black_box(codes::BENCH_CLASS)));
})
});
c.bench_function("loop_tokenize", |b| {
b.iter(|| {
let _ = black_box(utils::tokenize_code(black_box(codes::BENCH_LOOP)));
})
});
c.bench_function("fibonacci_loop_tokenize", |b| {
b.iter(|| {
let _ = black_box(utils::tokenize_code(black_box(codes::BENCH_FIBONACCI_LOOP)));
})
});
c.bench_function("fibonacci_recursion_tokenize", |b| {
b.iter(|| {
let _ = black_box(utils::tokenize_code(black_box(
codes::BENCH_FIBONACCI_RECURSION,
)));
})
});
}

fn parse(c: &mut Criterion) {
let class_tokenized = utils::tokenize_code(codes::BENCH_CLASS);
let loop_tokenized = utils::tokenize_code(codes::BENCH_LOOP);
let fibonacci_loop_tokenized = utils::tokenize_code(codes::BENCH_FIBONACCI_LOOP);
let fibonacci_recursion_tokenized = utils::tokenize_code(codes::BENCH_FIBONACCI_RECURSION);

c.bench_function("class_parse", |b| {
b.iter(|| {
let _ = black_box(utils::parse_code(class_tokenized.clone()));
})
});

c.bench_function("loop_parse", |b| {
b.iter(|| {
let _ = black_box(utils::parse_code(loop_tokenized.clone()));
})
});

c.bench_function("fibonacci_loop_parse", |b| {
b.iter(|| {
let _ = black_box(utils::parse_code(fibonacci_loop_tokenized.clone()));
})
});

c.bench_function("fibonacci_recursion_parse", |b| {
b.iter(|| {
let _ = black_box(utils::parse_code(fibonacci_recursion_tokenized.clone()));
})
});
}

fn byte_code_assembler(c: &mut Criterion) {
let class_parse = parseText!(codes::BENCH_CLASS).expect("should've been successful");
let loop_parse = parseText!(codes::BENCH_LOOP).expect("should've been successful");
let fibonacci_loop_parse =
parseText!(codes::BENCH_FIBONACCI_LOOP).expect("should've been successful");
let fibonacci_recursion_parse =
parseText!(codes::BENCH_FIBONACCI_RECURSION).expect("should've been successful");

//c.bench_function("class_byte_code_assembler", |b| {
// b.iter(|| {
// let _ = black_box(compiler::byte_code_assembler(class_parse.clone()));
// })
//});
}

criterion_group!(benches, tokenize, parse);
criterion_main!(benches);
71 changes: 71 additions & 0 deletions ellie_engine/benches/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
use core::hash::{Hash, Hasher};
use std::hash::DefaultHasher;

use ellie_core::{
defs::{PlatformArchitecture, Version},
utils::PageExport,
};
use ellie_engine::{
compiler, tokenizer,
utils::{CompileOutput, CompilerSettings, MainProgram, ProgramRepository},
};
use ellie_tokenizer::tokenizer::{Page, ResolvedImport};

#[derive(Clone)]
pub struct Repository {
pub code: String,
pub main_hash: usize,
}

impl ProgramRepository for Repository {
fn read_main(&mut self) -> MainProgram {
let mut main_file_hasher = DefaultHasher::new();
self.code.hash(&mut main_file_hasher);
let first_page_hash = main_file_hasher.finish();
self.main_hash = first_page_hash as usize;
MainProgram {
file_content: self.code.clone(),
file_name: "playground.ei".to_string(),
file_hash: first_page_hash as usize,
start_directory: "<ellie_module_playground>".to_string(),
}
}

fn read_module(
&mut self,
_link_module: bool,
_current_path: String,
_requested_path: String,
) -> ResolvedImport {
panic!("Module resolver is not implemented on tests")
}
}

pub fn tokenize_code(code: &str) -> (usize, PageExport<Page>) {
let mut program_repository = Repository {
code: code.to_string(),
main_hash: 0,
};
let pages =
tokenizer::tokenize_file(&mut program_repository).expect("should've been successful");
(program_repository.main_hash, pages)
}

pub fn parse_code(
(main_hash, pages): (usize, PageExport<Page>),
) -> Result<CompileOutput, Vec<ellie_core::error::Error>> {
compiler::parse_pages(
main_hash,
vec![],
pages,
CompilerSettings {
name: "ellie_bench".to_string(),
file_name: String::from("ellie_bench.ei"),
is_lib: false,
description: String::from("No description"),
experimental_features: false,
byte_code_architecture: PlatformArchitecture::B32,
version: Version::build_from_string(&"0.1.0".to_string()),
},
)
}
Loading
Loading