Skip to content

add url and urlsearchparams classes with c bridge#107

Merged
cs01 merged 4 commits intomainfrom
feat/url-class
Mar 7, 2026
Merged

add url and urlsearchparams classes with c bridge#107
cs01 merged 4 commits intomainfrom
feat/url-class

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Mar 6, 2026

feat: add URL and URLSearchParams classes

Adds URL and URLSearchParams as built-in classes, implemented via a new C bridge (url-bridge.c). Also fixes two CI bugs discovered during development: missing bridge artifacts in the cross-compile SDK tarball, and stage1 compiling with native CPU instructions that crash GitHub's x86-64 runners.

What's new

URL

const u = new URL("https://example.com:8080/path?q=hello#section");
u.protocol  // "https:"
u.hostname  // "example.com"
u.port      // "8080"
u.host      // "example.com:8080"
u.pathname  // "/path"
u.search    // "?q=hello"
u.hash      // "#section"
u.origin    // "https://example.com:8080"
u.href      // full URL string

URLSearchParams

const p = new URLSearchParams("q=hello&page=2");
p.get("q")           // "hello"
p.has("page")        // true
p.set("q", "world")
p.append("tag", "foo")
p.delete("page")
p.toString()         // "q=world&tag=foo"

Implementation

  • c_bridges/url-bridge.c (new) — GC-aware C bridge. URL parsing: cs_url_parse_protocol, cs_url_parse_hostname, cs_url_parse_port, cs_url_parse_pathname, cs_url_parse_search, cs_url_parse_hash. URLSearchParams: cs_urlsearch_get, cs_urlsearch_has, cs_urlsearch_set, cs_urlsearch_append, cs_urlsearch_delete, cs_urlsearch_tostring.
  • src/codegen/stdlib/url.ts (new) — codegen for URL and URLSearchParams constructor and method dispatch.
  • src/codegen/infrastructure/symbol-table.tsdefineUrl/defineUrlSearchParams now initialize all 17 Symbol fields. Previously only 5 were set; getConcreteClass reads symbol.concreteClass at index 15, causing a SIGSEGV from reading past the end of the struct.
  • scripts/build-vendor.sh, src/compiler.ts, src/native-compiler-lib.ts — build and link url-bridge.o.

CI fixes

  • scripts/build-target-sdk.sh — add url-bridge.o to the cross-compile SDK tarball. Missing bridges cause linker failures when cross-compiling macOS → Linux.
  • .github/workflows/ci.yml — add url-bridge.o to all 4 artifact copy locations (Linux verify, Linux release, macOS verify, macOS release).
  • tests/self-hosting.test.ts — pass --target-cpu=x86-64 to both stage0 and stage1 builds. Stage1 is compiled by stage0 and inherits the same CPU target issue; without the flag it emits AVX/newer instructions that SIGILL on GitHub's baseline x86-64 runners.

Commits

fd484b3 fix: pass --target-cpu=x86-64 to stage1 compilation
a4db449 fix: add url-bridge.o to cross-compile target sdk packaging
8856094 fix: add url-bridge.o to ci install/release
64f4a6c add url and urlsearchparams classes with c bridge

18 files changed, 659 insertions(+), 11 deletions(-)

@cs01 cs01 force-pushed the feat/url-class branch from 77df3e7 to 64f4a6c Compare March 6, 2026 22:58
@cs01 cs01 merged commit d15d7bc into main Mar 7, 2026
10 of 11 checks passed
@cs01 cs01 deleted the feat/url-class branch March 7, 2026 00:01
@cs01 cs01 mentioned this pull request Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant