Update examples and fix ssa bug in serveEmbedded#55
Merged
Conversation
d1ed468 to
58d864c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update examples and fix serveEmbedded codegen bug
Summary
ArgumentParserfromsrc/argparse.tsfor all examples that parse argumentsstring-searchChadScript.serveEmbedded()codegenChanges
Bugfix: SSA temp ordering in
serveEmbedded(src/codegen/stdlib/embed.ts)generateServeEmbedded()allocated two SSA temps in the wrong order relative to their emission. The GEP result (onePtr) was emitted before theselect(stripped), butstrippedhad the lower register number. LLVM requires numbered temps to be defined in ascending order, so this caused aninstruction expected to be numbered '%N' or greatererror wheneverChadScript.serveEmbedded()was used.Fix: swap the
nextTemp()allocation order to match emission order.Examples: helpful console output
All examples now print a banner on startup explaining what they do. Server examples print full URLs (
http://localhost:3000) instead of just port numbers.Examples: ArgumentParser adoption
Examples that parse arguments now use
ArgumentParserfromsrc/argparse.tsinstead of hand-rolledprocess.argvloops:word-count.ts— supports-l,-w,-cflags to show only lines/words/charscli-parser-demo.ts— replaced 83 lines of manual parsing with argparse (auto--help)http-server.ts—--port/-poptionhackernews/app.ts—--port/-poptionwebsocket/app.ts—--port/-poptionstring-search.ts— already used argparse, added--no-color/-CflagExamples: colorized string-search
string-search.tsnow outputs ripgrep-style colored results using ANSI escape codes (\x1b):Includes
--no-color/-Cflag to disable.Examples: websocket overhaul
Replaced
websocket-server.ts(inline HTML withprompt()dialogs) withwebsocket/app.ts:examples/websocket/public/viaChadScript.embedDir()+ChadScript.serveEmbedded()README
Updated to use
chad runas the primary way to run examples instead ofchad build+ running the binary.Test plan
--helpworks on all argparse examples