Skip to content

Commit bf284d9

Browse files
committed
Escape HTML correctly
1 parent 6aa74cf commit bf284d9

File tree

12 files changed

+74
-96
lines changed

12 files changed

+74
-96
lines changed

.github/workflows/ci.yml

+11-16
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ on:
66
workflow_dispatch:
77
env:
88
CARGO_TERM_COLOR: always
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
912
jobs:
1013
lint:
1114
runs-on: ubuntu-latest
1215
steps:
1316
- name: Checkout repository
1417
uses: actions/checkout@v2
15-
- name: Install Rust
16-
uses: actions-rs/toolchain@v1
17-
with:
18-
components: clippy
19-
profile: minimal
20-
toolchain: 1.78.0
2118
- name: Install Rust (nightly)
22-
uses: actions-rs/toolchain@v1
19+
uses: dtolnay/rust-toolchain@nightly
2320
with:
2421
components: rustfmt
25-
profile: minimal
2622
toolchain: nightly
23+
- name: Install Rust
24+
uses: dtolnay/[email protected]
25+
with:
26+
components: clippy
2727
- name: Install pnpm
2828
uses: pnpm/action-setup@v4
2929
with:
@@ -51,11 +51,9 @@ jobs:
5151
- name: Checkout repository
5252
uses: actions/checkout@v2
5353
- name: Install Rust
54-
uses: actions-rs/toolchain@v1
54+
uses: dtolnay/rust-toolchain@nightly
5555
with:
5656
components: miri
57-
profile: minimal
58-
toolchain: nightly
5957
- name: Setup Rust cache
6058
uses: Swatinem/rust-cache@v1
6159
- name: Install cargo-nextest
@@ -72,12 +70,9 @@ jobs:
7270
- name: Checkout repository
7371
uses: actions/checkout@v2
7472
- name: Install Rust
75-
uses: actions-rs/toolchain@v1
76-
with:
77-
profile: minimal
78-
toolchain: stable
73+
uses: dtolnay/[email protected]
7974
- name: Setup Rust cache
80-
uses: Swatinem/rust-cache@v1
75+
uses: Swatinem/rust-cache@v2
8176
- name: Install cargo-nextest
8277
uses: taiki-e/install-action@v2
8378
with:

.github/workflows/pages.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ jobs:
3232
cache-dependency-path: playground/pnpm-lock.yaml
3333
node-version: 18
3434
- name: Install Rust
35-
uses: actions-rs/toolchain@v1
36-
with:
37-
profile: minimal
38-
toolchain: 1.69.0
35+
uses: dtolnay/[email protected]
3936
- name: Setup Rust cache
4037
uses: Swatinem/rust-cache@v2
4138
with:
4239
cache-directories: ./playground/rust/lox-wasm
40+
- name: Install Task
41+
uses: arduino/setup-task@v2
42+
with:
43+
version: 3.x
4344
- name: Build playground
44-
run: pnpm install && BASE_PATH=/loxcraft pnpm run build
45-
working-directory: playground
45+
run: BASE_PATH=/loxcraft task build-playground
4646
- name: Upload artifact
47-
uses: actions/upload-pages-artifact@v1
47+
uses: actions/upload-pages-artifact@v3
4848
with:
4949
path: playground/out/
5050
- name: Deploy to GitHub Pages
5151
id: deployment
52-
uses: actions/deploy-pages@v1
52+
uses: actions/deploy-pages@v4

Cargo.lock

+15-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = [
55
]
66
categories = ["development-tools"]
77
description = "A compiler, VM, language server, and online playground for the Lox programming language"
8-
edition = "2021"
8+
edition = "2024"
99
keywords = [
1010
"cli",
1111
"compiler",
@@ -24,7 +24,7 @@ keywords = [
2424
license = "MIT"
2525
name = "loxcraft"
2626
repository = "https://github.com/ajeetdsouza/loxcraft"
27-
rust-version = "1.70.0"
27+
rust-version = "1.85.0"
2828
version = "0.1.1"
2929

3030
[badges]
@@ -75,7 +75,7 @@ warp-embed = { version = "0.5.0", optional = true }
7575
webbrowser = { version = "1.0.2", optional = true }
7676

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

8080
[target.'cfg(not(any(miri, target_family = "wasm")))'.dependencies]
8181
mimalloc = { version = "0.1.27", default-features = false }

playground/out/.gitkeep

Whitespace-only changes.

playground/rust/lox-wasm/Cargo.lock

+20-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/rust/lox-wasm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "lox-wasm"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[lib]
77
crate-type = ["cdylib"]

playground/rust/lox-wasm/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use wasm_bindgen::prelude::*;
1010
#[wasm_bindgen]
1111
#[allow(non_snake_case)]
1212
pub fn loxRun(source: &str) {
13-
let output = &mut Output::new();
14-
match VM::default().run(source, output) {
13+
let writer = Output::new();
14+
let mut writer = HtmlWriter::new(writer);
15+
match VM::default().run(source, &mut writer) {
1516
Ok(()) => postMessage(&Message::ExitSuccess.to_string()),
1617
Err(errors) => {
17-
let mut writer = HtmlWriter::new(output);
1818
for e in errors.iter() {
1919
report_error(&mut writer, source, e);
2020
}

src/syntax/lexer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl<'a> Lexer<'a> {
1616
}
1717
}
1818

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

2222
fn next(&mut self) -> Option<Self::Item> {

src/vm/allocator.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ impl<T> Allocator<T> {
2828
unsafe impl<T: GlobalAlloc> GlobalAlloc for Allocator<T> {
2929
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
3030
self.allocated_bytes.fetch_add(layout.size(), Ordering::Relaxed);
31-
self.inner.alloc(layout)
31+
unsafe { self.inner.alloc(layout) }
3232
}
3333

3434
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
3535
self.allocated_bytes.fetch_sub(layout.size(), Ordering::Relaxed);
36-
self.inner.dealloc(ptr, layout)
36+
unsafe { self.inner.dealloc(ptr, layout) }
3737
}
3838

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

4444
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
4545
self.allocated_bytes.fetch_add(new_size.wrapping_sub(layout.size()), Ordering::Relaxed);
46-
self.inner.realloc(ptr, layout, new_size)
46+
unsafe { self.inner.realloc(ptr, layout, new_size) }
4747
}
4848
}

src/vm/util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn now() -> f64 {
2323
.as_secs_f64()
2424
}
2525

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

0 commit comments

Comments
 (0)