diff --git a/Cargo.lock b/Cargo.lock
index ccdf1ae..7c9ddc2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -112,7 +112,7 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "fplc"
-version = "0.9.503"
+version = "0.9.504"
dependencies = [
"chrono",
"chrono-tz",
diff --git a/Cargo.toml b/Cargo.toml
index 5f753a6..2bd95cd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
[package]
name = "fplc"
-version = "0.9.503"
+version = "0.9.504"
edition = "2021"
description = "A pseudolang interpreter written in Rust"
repository = "https://github.com/PseudoLang-Software-Foundation/Pseudolang"
diff --git a/installer/pseudolang.nsi b/installer/pseudolang.nsi
index a70a8a5..a47e658 100644
--- a/installer/pseudolang.nsi
+++ b/installer/pseudolang.nsi
@@ -4,7 +4,7 @@
!define MUI_ICON "Pseudolang-Logo.ico"
-Name "PseudoLang Installer v0.9.503"
+Name "PseudoLang Installer v0.9.504"
InstallDir "$PROGRAMFILES\PseudoLang\"
OutFile "../release/installer/pseudolang-setup-x64.exe"
BrandingText "(c) 2024 PseudoLang Software Foundation"
@@ -33,7 +33,7 @@ Section ""
WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$INSTDIR;$R0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "DisplayName" "Pseudolang"
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "DisplayVersion" "0.9.503"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "DisplayVersion" "0.9.504"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "Publisher" "Pseudolang Software Foundation"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "DisplayIcon" "$INSTDIR\Pseudolang-Logo.ico"
diff --git a/readme.md b/readme.md
index bc3c2ff..0d6a63e 100644
--- a/readme.md
+++ b/readme.md
@@ -9,7 +9,7 @@
diff --git a/src/core.rs b/src/core.rs
index 3e00ff4..821f6da 100644
--- a/src/core.rs
+++ b/src/core.rs
@@ -1,4 +1,5 @@
use crate::{interpreter, lexer::Lexer, parser};
+use std::fmt::Write;
pub fn execute_code(input: &str, debug: bool, return_output: bool) -> Result {
let mut lexer = Lexer::new(input);
@@ -25,6 +26,31 @@ pub fn execute_code(input: &str, debug: bool, return_output: bool) -> Result Result {
+ let mut output = String::new();
+ let mut lexer = Lexer::new(input);
+ let tokens = lexer.tokenize();
+
+ if debug {
+ writeln!(output, "\n=== Lexer Output ===").unwrap();
+ writeln!(output, "Tokens: {:?}", tokens).unwrap();
+ writeln!(output, "\n=== Parser Starting ===").unwrap();
+ }
+
+ let ast = parser::parse(tokens, false)?;
+
+ if debug {
+ writeln!(output, "\n=== Parser Output ===").unwrap();
+ writeln!(output, "AST: {:#?}", ast).unwrap();
+ writeln!(output, "\n=== Starting Execution ===").unwrap();
+ }
+
+ let program_output = interpreter::run(ast)?;
+ writeln!(output, "{}", program_output).unwrap();
+
+ Ok(output)
+}
+
pub const HELP_MESSAGE: &str = r#"PseudoLang Usage:
fplc [OPTIONS] COMMAND [ARGS]
diff --git a/src/wasm.rs b/src/wasm.rs
index 962c5db..d68640e 100644
--- a/src/wasm.rs
+++ b/src/wasm.rs
@@ -1,7 +1,27 @@
#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
-use crate::core::execute_code;
+use crate::core::execute_code_with_capture;
#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
use std::fmt::Write;
+#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
+use wasm_bindgen::prelude::*;
+
+include!(concat!(env!("OUT_DIR"), "/version.rs"));
+
+#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
+#[no_mangle]
+pub extern "C" fn get_version_raw() -> u64 {
+ let version = VERSION.as_bytes();
+ let ptr = version.as_ptr() as u64;
+ let len = version.len() as u64;
+ std::mem::forget(version);
+ (ptr << 32) | len
+}
+
+#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
+#[wasm_bindgen]
+pub fn get_version() -> String {
+ VERSION.to_string()
+}
#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
#[no_mangle]
@@ -11,7 +31,7 @@ pub extern "C" fn run_pseudolang_raw(ptr: *const u8, len: usize, debug: bool) ->
std::str::from_utf8_unchecked(slice)
};
- match run_with_debug(input, debug) {
+ match execute_code_with_capture(input, debug) {
Ok(output) => {
let bytes = output.into_bytes();
let ptr = bytes.as_ptr() as u64;
@@ -23,40 +43,11 @@ pub extern "C" fn run_pseudolang_raw(ptr: *const u8, len: usize, debug: bool) ->
}
}
-#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
-use wasm_bindgen::prelude::*;
-
#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
#[wasm_bindgen]
pub fn run_pseudolang(input: &str, debug: bool) -> Result {
console_error_panic_hook::set_once();
- run_with_debug(input, debug).map_err(|e| JsValue::from_str(&e))
-}
-
-#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
-fn run_with_debug(input: &str, debug: bool) -> Result {
- let mut output = String::new();
- let mut lexer = crate::lexer::Lexer::new(input);
- let tokens = lexer.tokenize();
-
- if debug {
- writeln!(output, "\n=== Lexer Output ===").unwrap();
- writeln!(output, "Tokens: {:?}", tokens).unwrap();
- writeln!(output, "\n=== Parser Starting ===").unwrap();
- }
-
- let ast = crate::parser::parse(tokens, false)?;
-
- if debug {
- writeln!(output, "\n=== Parser Output ===").unwrap();
- writeln!(output, "AST: {:#?}", ast).unwrap();
- writeln!(output, "\n=== Starting Execution ===").unwrap();
- }
-
- let program_output = crate::interpreter::run(ast)?;
- writeln!(output, "{}", program_output).unwrap();
-
- Ok(output)
+ execute_code_with_capture(input, debug).map_err(|e| JsValue::from_str(&e))
}
#[cfg(all(target_arch = "wasm32", not(feature = "wasi")))]
diff --git a/wapm.toml b/wapm.toml
index 22b147e..63a78eb 100644
--- a/wapm.toml
+++ b/wapm.toml
@@ -1,7 +1,7 @@
[package]
name = "pseudolang/fplc"
-version = "0.9.503"
+version = "0.9.504"
description = "A pseudolang interpreter written in Rust"
license = "MIT"
readme = "readme.md"