feat: add wasm build targets, profile hooks, os_demo example, and restructure manual source

- Add `wasm`, `wasm-clean`, and `install-emscripten` phony targets to Makefile for WebAssembly cross-compilation
- Insert `WREN_PROFILE_ENTER`/`WREN_PROFILE_EXIT` macros in `wren_vm.h` and `wren_vm.c` to support optional runtime profiling via `WREN_PROFILE_ENABLED`
- Create `example/os_demo.wren` demonstrating Platform, Process, and conditional exit usage
- Update `example/regex_demo.wren` to import `Match` and exercise Match object properties, groups, and `matchAll`
- Remove static HTML manual pages (`base64.html`, `dns.html`, `json.html`) and replace with structured `manual_src/` directory containing Jinja2 templates, YAML metadata, and content pages
- Expand `README.md` with build targets table, manual building instructions, source layout, and guide for adding new module documentation
This commit is contained in:
2026-01-26 04:12:14 +00:00
parent 79ff93c9a2
commit 04e467e09b
143 changed files with 13333 additions and 15112 deletions
+36
View File
@@ -0,0 +1,36 @@
// retoor <retoor@molodetz.nl>
import "os" for Platform, Process
System.print("=== OS Module Demo ===\n")
System.print("--- Platform Information ---")
System.print("Name: %(Platform.name)")
System.print("Is POSIX: %(Platform.isPosix)")
System.print("Is Windows: %(Platform.isWindows)")
System.print("Home Path: %(Platform.homePath)")
System.print("\n--- Process Information ---")
System.print("PID: %(Process.pid)")
System.print("Parent PID: %(Process.ppid)")
System.print("Working Directory: %(Process.cwd)")
System.print("Wren Version: %(Process.version)")
System.print("\n--- Command Line Arguments ---")
System.print("Arguments: %(Process.arguments)")
System.print("All Arguments: %(Process.allArguments)")
System.print("\n--- Platform-Specific Paths ---")
var separator = Platform.isWindows ? "\\" : "/"
var configPath = Platform.homePath + separator + ".config"
System.print("Config directory: %(configPath)")
System.print("\n--- Conditional Exit ---")
var args = Process.arguments
if (args.count > 0 && args[0] == "--fail") {
System.print("Exiting with error code 1")
Process.exit(1)
}
System.print("Exiting normally")
Process.exit(0)
+33 -1
View File
@@ -1,6 +1,6 @@
// retoor <retoor@molodetz.nl>
import "regex" for Regex
import "regex" for Regex, Match
System.print("=== Regex Module Demo ===\n")
@@ -128,3 +128,35 @@ var sentence = "hello, world; foo bar"
var tokens = tokenSeparator.split(sentence)
System.print("Input: %(sentence)")
System.print("Tokens: %(tokens)")
System.print("\n--- Match Object ---")
var emailRe = Regex.new("(\\w+)@(\\w+)\\.(\\w+)")
var match = emailRe.match("Contact: alice@example.com for info")
if (match != null) {
System.print("Full match: %(match.text)")
System.print("Start index: %(match.start)")
System.print("End index: %(match.end)")
System.print("group(0): %(match.group(0))")
System.print("group(1): %(match.group(1))")
System.print("group(2): %(match.group(2))")
System.print("group(3): %(match.group(3))")
}
System.print("\n--- Groups Property ---")
var dateRe = Regex.new("(\\d{4})-(\\d{2})-(\\d{2})")
var dateMatch = dateRe.match("Date: 2024-01-15")
if (dateMatch != null) {
System.print("groups[0] (full match): %(dateMatch.groups[0])")
System.print("groups[1] (year): %(dateMatch.groups[1])")
System.print("groups[2] (month): %(dateMatch.groups[2])")
System.print("groups[3] (day): %(dateMatch.groups[3])")
System.print("Total groups: %(dateMatch.groups.count)")
}
System.print("\n--- Find All Matches ---")
var numRe = Regex.new("\\d+")
var allMatches = numRe.matchAll("Order 123 has 5 items at $99 each")
System.print("Found %(allMatches.count) numbers:")
for (m in allMatches) {
System.print(" '%(m.text)' at position %(m.start)-%(m.end)")
}