Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
✨ v1.6.3 (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
JumperBot authored Dec 23, 2022
1 parent 34a9c69 commit 15690dd
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 211 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

---

[![Banner.png](./.github/ShortenedBanner.png)](./.github/ShortenedBanner.png)
[![Banner.png](./res/ShortenedBanner.png)](./res/ShortenedBanner.png)

[![UFBDesc.apng](./.github/UFBDesc.apng)](./.github/UFBDesc.apng)
[![UFBDesc.apng](./res/UFBDesc.apng)](./res/UFBDesc.apng)
---

> Unsafe Four Bit / UFB / Unsafe-4-Bit is a fast-paced, compiled-interpreted, dynamically-typed, imperative-procedural programming language built with Rust.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified build/aarch64-unknown-linux-gnu/ufb
Binary file not shown.
Binary file modified build/aarch64-unknown-linux-musl/ufb
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
Binary file added res/syntax-highlight.tar
Binary file not shown.
8 changes: 6 additions & 2 deletions src/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[package]
name = "ufb"
version = "1.6.2"
name = "unsafe-4-bit"
version = "1.6.3"
edition = "2021"
license = "GPL-3.0-or-later"

[[bin]]
name = "ufb"
path = "src/main.rs"

[profile.release]
codegen-units = 1
debug = false
Expand Down
10 changes: 5 additions & 5 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ UFB_RELEASE_DIR_MUSL="target/aarch64-unknown-linux-musl/release"
UFB_RELEASE_BIN_TEMP="$UFB_RELEASE_DIR/ufb"
UFB_RELEASE_BIN_TEMP_MUSL="$UFB_RELEASE_DIR_MUSL/ufb"
UFB_RELEASE_BIN_DIR="../build/aarch64-unknown-linux-gnu"
UFB_RELEASE_BIN_MUSL_DIR="../build/aarch64-unknown-linux-musl"
UFB_RELEASE_BIN_DIR_MUSL="../build/aarch64-unknown-linux-musl"
UFB_RELEASE_BIN="$UFB_RELEASE_BIN_DIR/ufb"
UFB_RELEASE_BIN_MUSL="$UFB_RELEASE_BIN_MUSL_DIR/ufb"
UFB_RELEASE_BIN_MUSL="$UFB_RELEASE_BIN_DIR_MUSL/ufb"
RUSTFLAGS="--remap-path-prefix $HOME=~"

rustfmt src/*
rm $UFB_RELEASE_BIN
rm $UFB_RELEASE_BIN_MUSL
rm $UFB_RELEASE_BIN_DIR/*
rm $UFB_RELEASE_BIN_DIR_MUSL/*
rm ../build/*.tar
cargo clean

Expand All @@ -22,7 +22,7 @@ mv -f "$UFB_RELEASE_BIN_TEMP_MUSL" "$UFB_RELEASE_BIN_MUSL"

UFB_RELEASE_VERSION="$(cat Cargo.toml | grep "version" | cut -d'"' -f 2)"
tar -cf "../build/Unsafe-4-Bit_v"$UFB_RELEASE_VERSION"_aarch64-unknown-linux-gnu.tar" -C $UFB_RELEASE_BIN_DIR . --numeric-owner
tar -cf "../build/Unsafe-4-Bit_v"$UFB_RELEASE_VERSION"_aarch64-unknown-linux-musl.tar" -C $UFB_RELEASE_BIN_MUSL_DIR . --numeric-owner
tar -cf "../build/Unsafe-4-Bit_v"$UFB_RELEASE_VERSION"_aarch64-unknown-linux-musl.tar" -C $UFB_RELEASE_BIN_DIR_MUSL . --numeric-owner
sudo rm target -r

rm Cargo.lock
2 changes: 1 addition & 1 deletion src/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() {
let flags: FlagManager = FlagManager::new(&env::args().collect::<Vec<String>>());
if flags.version_flag {
// TODO: Always Change Version Tag Here And At Cargo.toml
println!("UFB Version: v1.6.2\nFlag Triggered, Continuing Anyway...\n\n");
println!("UFB Version: v1.6.3\nFlag Triggered, Continuing Anyway...\n\n");
}
if flags.license_flag {
println!(
Expand Down
171 changes: 97 additions & 74 deletions src/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use crate::universal::Universal;

use std::fs;
use std::fs::File;
use std::fs::Metadata;
use std::io;
use std::io::ErrorKind;
use std::io::Read;
Expand Down Expand Up @@ -51,36 +50,35 @@ pub struct Runner {

impl Runner {
pub fn new(file_name: String, perfmes: bool, nanosec: bool, commmes: bool) -> Runner {
let res: Result<File, _> = File::open(&file_name);
if let Err(ref x) = res {
Universal::err_exit(format!(
match File::open(&file_name) {
Err(x) => Universal::err_exit(format!(
"File Provided Does Not Exist...\n{}\nTerminating...",
x.to_string(),
));
)),
Ok(x) => match x.metadata() {
Err(y) => Universal::err_exit(y.to_string()),
Ok(y) => {
return Runner {
file: x,
file_name: file_name,
file_size: y.len(),
ptr: 0,
mem_ind: [0; 256],
mem: Self::init_mem(),
byte_ind: Vec::<u64>::new(),
perfmes: perfmes,
nanosec: nanosec,
commmes: commmes,
}
}
},
}
let file: File = res.unwrap();
let res2: Result<Metadata, _> = file.metadata();
if let Err(ref y) = res2 {
Universal::err_exit(y.to_string());
}
return Runner {
file: file,
file_name: file_name,
file_size: res2.unwrap().len(),
ptr: 0,
mem_ind: [0; 256],
mem: Self::init_mem(),
byte_ind: Vec::<u64>::new(),
perfmes: perfmes,
nanosec: nanosec,
commmes: commmes,
};
return Self::new(file_name, perfmes, nanosec, commmes);
}

pub fn run(&mut self) {
let ten_millis: Duration = Duration::from_millis(10);
let start: u128;
if self.perfmes {
let start: u128;
match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(x) => {
if self.nanosec {
Expand All @@ -90,61 +88,36 @@ impl Runner {
}
}
Err(_) => start = 0,
};
} else {
start = 0;
}
while self.ptr != self.file_size {
if let Err(_) = self.byte_ind.binary_search(&self.ptr) {
self.byte_ind.push(self.ptr.clone());
}
let com: u8 = self.next();
let start: u128;
if self.commmes {
match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(x) => {
if self.nanosec {
start = x.as_nanos();
} else {
start = x.as_millis();
}
}
Err(_) => start = 0,
};
self.run_commands_with_time();
} else {
start = 0;
}
match com {
0 => self.wvar(),
1 => {
let ind: u8 = self.next();
self.nvar(&ind);
},
2 => self.trim(),
3..=8 => self.math(&com),
9 => thread::sleep(ten_millis.clone()),
10..=13 => self.jump(&com),
14 => self.print(),
15 => self.read(),
16 => self.wfile(),
17 => self.rfile(),
18 => self.dfile(),
_ => Universal::err_exit(format!(
"\nCommand Index: {com} Is Not Recognized By The Interpreter...\nTerminating...",
)),
self.run_commands();
}
if self.commmes {
if let Ok(x) = SystemTime::now().duration_since(UNIX_EPOCH) {
if self.nanosec {
println!("\nCommand Index {com} Took {}ns", x.as_nanos() - start);
} else {
println!("\nCommand Index {com} Took {}ms", x.as_millis() - start);
let mut mem_leaks: String = String::new();
for i in 0..32 {
for ratio in 0..8 {
let ind: usize = i + (ratio * 32);
if self.mem_ind[ind] != 0 {
mem_leaks = format!("{mem_leaks}\nMemory Leak At Index: {ind}");
}
}
}
if !mem_leaks.is_empty() {
Universal::err_exit(mem_leaks);
}
if let Ok(x) = SystemTime::now().duration_since(UNIX_EPOCH) {
if self.nanosec {
println!("Program Took {}ns", x.as_nanos() - start);
} else {
println!("\nCommand Index {com} Took ?~");
println!("Program Took {}ms", x.as_millis() - start);
}
} else {
println!("Program Took ?~");
}
return;
}
self.run_commands();
let mut mem_leaks: String = String::new();
for i in 0..32 {
for ratio in 0..8 {
Expand All @@ -157,16 +130,66 @@ impl Runner {
if !mem_leaks.is_empty() {
Universal::err_exit(mem_leaks);
}
if self.perfmes {
}
fn run_commands(&mut self) {
let ten_millis: Duration = Duration::from_millis(10);
while self.ptr != self.file_size {
if let Err(_) = self.byte_ind.binary_search(&self.ptr) {
self.byte_ind.push(self.ptr.clone());
}
let com: u8 = self.next();
self.run_command(com, ten_millis.clone());
}
}
fn run_commands_with_time(&mut self) {
let ten_millis: Duration = Duration::from_millis(10);
while self.ptr != self.file_size {
let start: u128;
match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(x) => {
if self.nanosec {
start = x.as_nanos();
} else {
start = x.as_millis();
}
}
Err(_) => start = 0,
}
if let Err(_) = self.byte_ind.binary_search(&self.ptr) {
self.byte_ind.push(self.ptr.clone());
}
let com: u8 = self.next();
self.run_command(com.clone(), ten_millis.clone());
if let Ok(x) = SystemTime::now().duration_since(UNIX_EPOCH) {
if self.nanosec {
println!("Program Took {}ns", x.as_nanos() - start);
println!("\nCommand Index {com} Took {}ns", x.as_nanos() - start);
} else {
println!("Program Took {}ms", x.as_millis() - start);
println!("\nCommand Index {com} Took {}ms", x.as_millis() - start);
}
} else {
println!("Program Took ?~");
println!("\nCommand Index {com} Took ?~");
}
}
}
fn run_command(&mut self, com: u8, ten_millis: Duration) {
match com {
0 => self.wvar(),
1 => {
let ind: u8 = self.next();
self.nvar(&ind);
}
2 => self.trim(),
3..=8 => self.math(&com),
9 => thread::sleep(ten_millis),
10..=13 => self.jump(&com),
14 => self.print(),
15 => self.read(),
16 => self.wfile(),
17 => self.rfile(),
18 => self.dfile(),
_ => Universal::err_exit(format!(
"\nCommand Index: {com} Is Not Recognized By The Interpreter...\nTerminating...",
)),
}
}

Expand Down
Binary file removed syntax-highlight/unsafe-4-bit/Icon.png
Binary file not shown.
18 changes: 0 additions & 18 deletions syntax-highlight/unsafe-4-bit/language-configuration.json

This file was deleted.

27 changes: 0 additions & 27 deletions syntax-highlight/unsafe-4-bit/package.json

This file was deleted.

Loading

0 comments on commit 15690dd

Please sign in to comment.