Skip to content

Commit

Permalink
Escape HTML correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed Feb 25, 2025
1 parent 6aa74cf commit c57e834
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 95 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ on:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
components: clippy
profile: minimal
toolchain: 1.78.0
- name: Install Rust (nightly)
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
profile: minimal
toolchain: nightly
- name: Install Rust
uses: dtolnay/[email protected]
with:
components: clippy
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
Expand Down Expand Up @@ -51,11 +51,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@nightly
with:
components: miri
profile: minimal
toolchain: nightly
- name: Setup Rust cache
uses: Swatinem/rust-cache@v1
- name: Install cargo-nextest
Expand All @@ -72,12 +70,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
uses: dtolnay/[email protected]
- name: Setup Rust cache
uses: Swatinem/rust-cache@v1
uses: Swatinem/rust-cache@v2
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ jobs:
cache-dependency-path: playground/pnpm-lock.yaml
node-version: 18
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.69.0
uses: dtolnay/[email protected]
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ./playground/rust/lox-wasm
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
- name: Build playground
run: pnpm install && BASE_PATH=/loxcraft pnpm run build
working-directory: playground
run: task build-playground
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: playground/out/
- name: Deploy to GitHub Pages
Expand Down
27 changes: 15 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = [
]
categories = ["development-tools"]
description = "A compiler, VM, language server, and online playground for the Lox programming language"
edition = "2021"
edition = "2024"
keywords = [
"cli",
"compiler",
Expand All @@ -24,7 +24,7 @@ keywords = [
license = "MIT"
name = "loxcraft"
repository = "https://github.com/ajeetdsouza/loxcraft"
rust-version = "1.70.0"
rust-version = "1.85.0"
version = "0.1.1"

[badges]
Expand Down Expand Up @@ -75,7 +75,7 @@ warp-embed = { version = "0.5.0", optional = true }
webbrowser = { version = "1.0.2", optional = true }

[target.'cfg(target_family = "wasm")'.dependencies]
wasm-bindgen = "0.2.67"
wasm-bindgen = "0.2.100"

[target.'cfg(not(any(miri, target_family = "wasm")))'.dependencies]
mimalloc = { version = "0.1.27", default-features = false }
Expand Down
Empty file added playground/out/.gitkeep
Empty file.
36 changes: 20 additions & 16 deletions playground/rust/lox-wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion playground/rust/lox-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "lox-wasm"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
6 changes: 3 additions & 3 deletions playground/rust/lox-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use wasm_bindgen::prelude::*;
#[wasm_bindgen]
#[allow(non_snake_case)]
pub fn loxRun(source: &str) {
let output = &mut Output::new();
match VM::default().run(source, output) {
let writer = Output::new();
let mut writer = HtmlWriter::new(writer);
match VM::default().run(source, &mut writer) {
Ok(()) => postMessage(&Message::ExitSuccess.to_string()),
Err(errors) => {
let mut writer = HtmlWriter::new(output);
for e in errors.iter() {
report_error(&mut writer, source, e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/syntax/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'a> Lexer<'a> {
}
}

impl<'a> Iterator for Lexer<'a> {
impl Iterator for Lexer<'_> {
type Item = Result<(usize, Token, usize), ErrorS>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
8 changes: 4 additions & 4 deletions src/vm/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ impl<T> Allocator<T> {
unsafe impl<T: GlobalAlloc> GlobalAlloc for Allocator<T> {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
self.allocated_bytes.fetch_add(layout.size(), Ordering::Relaxed);
self.inner.alloc(layout)
unsafe { self.inner.alloc(layout) }
}

unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
self.allocated_bytes.fetch_sub(layout.size(), Ordering::Relaxed);
self.inner.dealloc(ptr, layout)
unsafe { self.inner.dealloc(ptr, layout) }
}

unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
self.allocated_bytes.fetch_add(layout.size(), Ordering::Relaxed);
self.inner.alloc_zeroed(layout)
unsafe { self.inner.alloc_zeroed(layout) }
}

unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
self.allocated_bytes.fetch_add(new_size.wrapping_sub(layout.size()), Ordering::Relaxed);
self.inner.realloc(ptr, layout, new_size)
unsafe { self.inner.realloc(ptr, layout, new_size) }
}
}
1 change: 1 addition & 0 deletions src/vm/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub fn now() -> f64 {
.as_secs_f64()
}

#[inline(always)]
pub const fn unreachable() -> ! {
if cfg!(debug_assertions) { unreachable!() } else { unsafe { hint::unreachable_unchecked() } }
}
Loading

0 comments on commit c57e834

Please sign in to comment.