Commit Graph
100 Commits
Author SHA1 Message Date
Bob Nystrom 6c2d673638 fix: alert missing interpreter in benchmark runner instead of crashing on OSError 2015-01-08 15:44:29 +00:00
Bob Nystrom b882b33019 docs: fix typo "they behavior" to "their behavior" in expressions documentation 2015-01-08 15:43:00 +00:00
Bob Nystrom 845b95e3b3 refactor: replace strlen calls with sprintf return value in num_toString and range_toString
Use the integer length returned by sprintf directly instead of calling strlen on the buffer, eliminating redundant string length calculations in two native functions for number and range string conversion.
2015-01-08 15:41:49 +00:00
Bob Nystrom 041e6213d5 refactor: change ObjString length field from size_t to int for consistency and reduced memory usage
The length field in ObjString struct now uses int instead of size_t, saving memory
and aligning with other string length storage conventions throughout the VM.
This eliminates signed/unsigned conversion warnings and matches the type used
elsewhere for string lengths.
2015-01-08 15:41:30 +00:00
Bob Nystrom 56355baf42 refactor: use sprintf return value to avoid redundant strlen calls in num_toString and range_toString
Replace strlen(buffer) calls with the length returned directly by sprintf in the
num_toString and range_toString native functions, eliminating unnecessary string
length calculations after formatting.
2015-01-08 15:01:21 +00:00
Bob Nystrom a48edd5874 feat: store string length in ObjString to avoid O(n) strlen calls
Replace all uses of `strlen()` and `strcmp()` on string values with the precomputed `length` field and `memcmp()` for equality checks. This eliminates repeated O(n) length calculations in `string_count`, `string_contains`, `string_eqeq`, `string_bangeq`, and `string_subscript`. Also fixes memory accounting in `markString` to use the stored length instead of recalculating it.
2015-01-08 14:59:41 +00:00
Bob Nystrom caad37b187 feat: add benchmark metrics tracking to script/metrics.py
Extend the metrics script to walk the benchmark directory, counting benchmark files, TODOs, non-empty lines, and empty lines, and print these new benchmark statistics alongside existing source and test metrics.
2015-01-07 15:30:59 +00:00
Bob Nystrom 1874938a57 fix: convert print statements to functions and add shebang for Python 3 compatibility in run_bench script 2015-01-07 15:25:46 +00:00
Bob Nystrom fc168cb6fc chore: add travis build badge and fix trailing semicolons in benchmark
Add Travis CI build status badge to README for continuous integration visibility.
Remove trailing semicolons from three assignment statements in delta_blue.wren
benchmark to maintain consistent coding style across the codebase.
2015-01-07 15:23:03 +00:00
Bob Nystrom 513a6fe4be fix: remove trailing semicolons from assignment statements in delta_blue.wren benchmark
Remove unnecessary semicolons from three assignment expressions in the
delta_blue.wren benchmark file to conform to Wren language style conventions,
where semicolons are optional and typically omitted.
2015-01-07 15:22:05 +00:00
Bob Nystrom c1980e4c58 refactor: embed string data as flexible array member in ObjString
Remove separate heap allocation for string text by converting ObjString.value from a char pointer to a C99 flexible array member. This eliminates the extra allocation in wrenNewUninitializedString and the corresponding free in wrenFreeObj, reducing memory fragmentation and pointer indirection for all string objects.
2015-01-07 15:20:12 +00:00
Bob Nystrom 44e85f652e docs: add Travis CI build status badge to README.md
Insert a Markdown image link pointing to the Travis CI build status SVG for the munificent/wren repository, placed between the contribution call-to-action paragraph and the syntax reference link. Also fix the missing trailing newline on the contributing URL line.
2015-01-06 15:21:22 +00:00
Bob Nystrom 44d667665b fix: handle NaN formatting in num_toString to ensure consistent output
The previous implementation relied on sprintf's "%.14g" format for NaN values,
which produces platform-dependent results (some libc versions add a sign prefix).
This change adds an explicit NaN check using the self-comparison idiom (value != value)
and returns a lowercase "nan" string directly, ensuring consistent behavior across
all platforms. The buffer size comment is also updated to remove the now-inaccurate
reference to NaN handling.
2015-01-06 15:09:45 +00:00
Bob Nystrom ba91af1f4d chore: add Paul Woolcock to AUTHORS file to resolve merge conflict 2015-01-06 05:58:23 +00:00
Bob Nystrom 95d3ae5cc6 chore: add Paul Woolcock to AUTHORS file with email address
Append Paul Woolcock's name and email (paul@woolcock.us) to the list of contributors in the AUTHORS file, following the existing entry for Robert Nystrom.
2015-01-06 04:52:01 +00:00
Bob Nystrom a3e6d028c4 docs: fix logical or operator description to correctly state truthy behavior 2015-01-05 15:46:26 +00:00
Bob Nystrom e07fe5149b docs: add AUTHORS file and expand contributor guide with detailed workflow
- Create AUTHORS file listing Robert Nystrom as initial contributor
- Rewrite README to emphasize Wren as concurrent scripting language with fiber examples
- Expand contributing.markdown with structured sections for finding tasks and making changes
- Update index.markdown with call-to-action links for trying and contributing
2015-01-04 21:36:23 +00:00
Bob Nystrom b61e55d4c9 fix: skip duplicate lexer error reporting in compiler error handler
The `error()` function in the compiler now returns early when the offending token
is of type `TOKEN_ERROR`, preventing the lexer's already-reported error from
being emitted a second time to stderr. This eliminates redundant error messages
for malformed tokens.
2015-01-04 21:10:46 +00:00
Bob Nystrom 96d893a637 feat: ignore shebang lines starting with #! on first line of source
Add special handling in the lexer's nextToken function to detect a '#' character followed by '!' on the first line (currentLine == 1) and skip the entire line as a comment. If the shebang appears on any other line, or if a '#' is not followed by '!', emit a lex error for invalid character. Include test cases for valid shebang execution, shebang at EOF, shebang on a non-first line (expected error), and an invalid shebang pattern (expected error).
2015-01-04 21:02:42 +00:00
Bob Nystrom ed31544ead fix: handle empty and comment-only files by removing early skip in repl and compiler
Remove the empty-line check in runRepl that skipped interpretation for blank input, and refactor the main compilation loop in wrenCompile to use a while loop with TOKEN_EOF matching instead of a for loop with redundant EOF break. This allows the compiler to process files containing only comments or whitespace without prematurely terminating, fixing issue #57. Add test fixtures for comment-only source files.
2015-01-04 21:00:53 +00:00
Bob Nystrom a6bef8586f fix: skip wrenInterpret call on empty input line in repl loop 2015-01-04 18:03:16 +00:00
Bob Nystrom 1e49dc666a chore: add shared library artifacts to gitignore and clarify makefile comment for lib build
Add libwren.a and libwrend.a to .gitignore to prevent tracking of static library build outputs, and update the Makefile comment to explain that main.c is excluded from shared library object lists.
2015-01-04 18:02:50 +00:00
Bob Nystrom f1e4871521 feat: add static library targets and exclude main.o from shared objects
Add `libwren.a` and `libwrend.a` static library build targets using `ar rcu`, compile all object files with `-fPIC` for position-independent code, and exclude `main.o` from the shared library object lists via `subst` to allow linking the interpreter separately against the static archive.
2015-01-04 17:57:05 +00:00
Bob Nystrom 0451059109 fix: skip wrenInterpret call when REPL input is empty newline 2015-01-04 07:40:20 +00:00
Bob Nystrom 98d358142d docs: reflow all markdown files to 80-char width and add control-flow page with branching/looping content 2015-01-04 07:27:02 +00:00
Bob Nystrom 1951059c8f feat: remove semicolon token from lexer and treat it as invalid syntax
Remove the `;` case from the `nextToken` function in `wren_compiler.c` so that semicolons are no longer lexed as `TOKEN_LINE`. Update the documentation in `doc/site/syntax.markdown` to describe newlines as the sole statement separator, and adjust all test files (`test/limit/many_constants.wren`, `test/limit/many_globals.wren`, `test/limit/too_many_constants.wren`, `test/semicolon.wren`) to reflect that semicolons now produce an error instead of being treated as line breaks.
2015-01-03 18:02:45 +00:00
Bob Nystrom 3b63f25690 docs: update error-handling doc to show "Caught error:" prefix in example output 2015-01-03 04:17:36 +00:00
Bob Nystrom 1663d4d95c fix: name anonymous union in Method struct to comply with strict C99
The anonymous union inside the Method struct was previously unnamed, which is not allowed in strict C99 mode. This change names the union `fn` and updates all references to its members (`.primitive`, `.foreign`, `.obj`) to use the qualified syntax (`.fn.primitive`, `.fn.foreign`, `.fn.obj`). The NATIVE macro parameter was also renamed from `fn` to `function` to avoid shadowing the new union field name.
2015-01-03 04:17:10 +00:00
Bob Nystrom c69be6012a fix: correct example output for catching and printing an error in error-handling docs 2015-01-03 04:09:43 +00:00
Bob Nystrom 2d7b4f951c fix: correct Wren class syntax in README and doc site examples to use getter methods 2015-01-03 04:07:43 +00:00
Bob Nystrom 6d1801603c feat: add Travis CI config and fail-exit in test script
Add .travis.yml with gcc and clang compilers running make && make test.
Modify script/test.py to call sys.exit(1) when any tests fail, ensuring
CI build correctly reports failure status.
2015-01-02 16:13:51 +00:00
Bob Nystrom 464a2139b1 fix: remove embedded newline from "small" in Wren class adjectives array 2015-01-02 15:59:31 +00:00
Bob Nystrom e820580f73 docs: add README with Wren language overview and feature highlights
- Introduce Wren as a small, clean, fast class-based scripting language
- Include code example demonstrating class syntax with adjectives list
- List key features: small codebase under 4000 semicolons, clean C99 implementation, fast single-pass compiler, class-based object model, embedding-focused design
- Provide links to source code, NaN tagging implementation, performance benchmarks, class documentation, and embedding API
2015-01-02 15:42:08 +00:00
Bob Nystrom 52677edf48 fix: extend copyright year range and clarify permission notice inclusion in binary distributions 2015-01-02 15:38:00 +00:00
Bob Nystrom f069a38228 style: rename local variable num_read to numRead and reorder feof check in runRepl 2015-01-02 15:31:02 +00:00
Bob Nystrom 374bb4aed9 fix: correct broken link to embedding API documentation in site index
The link target for the embedding API reference was pointing to the wrong
filename (`embedding.html` instead of `embedding-api.html`), causing a 404
error when users clicked the link. This commit updates the href to match the
actual generated documentation file.
2015-01-02 06:59:38 +00:00
Bob Nystrom 9c286204ff fix: correct range operator example in values documentation from .. to ... 2015-01-02 06:48:43 +00:00
Bob Nystrom 5c867fbc49 feat: add gh-pages make target to build docs and copy to gh-pages directory
Add a new `gh-pages` make target that depends on the `docs` target and copies the generated documentation from `build/docs/` into a local `gh-pages/` directory. Also update `.gitignore` to exclude the `gh-pages/` directory, which is intended to be a separate checkout of the repository for pushing to GitHub Pages.
2015-01-02 04:58:36 +00:00
Bob Nystrom 722ca8f61d docs: expand contributing guide with MIT license and GitHub links, reword error handling and performance sections 2015-01-02 04:45:15 +00:00
Bob Nystrom 0868cf1d8c chore: add TODO comment for arity getter in wren_core.c
- Inserted a TODO comment before the toString native binding in the
  function class initialization to remind about implementing an arity
  getter for Wren functions.
2015-01-02 02:49:10 +00:00
Bob Nystrom 151b352bee docs: expand embedding API, functions, lists, maps, and looping documentation with examples and clarifications 2015-01-02 02:48:59 +00:00
Bob Nystrom 0a54f68ad3 docs: add comprehensive error-handling documentation covering syntax and runtime errors with examples 2015-01-02 00:02:02 +00:00
Bob Nystrom 0f5eb1885e feat: add Fiber.abort() method to abort fiber with error message
Implements a new `Fiber.abort()` static method that allows a fiber to terminate with a custom error message string. The method validates that the argument is a string, then returns a PRIM_ERROR to abort the current fiber. Includes three test cases: basic abort with error message retrieval via `fiber.try`, aborting the main fiber with a runtime error, and type checking that non-string arguments produce an appropriate error message.
2015-01-01 18:40:14 +00:00
Bob Nystrom d287d084ed refactor: simplify empty list range check in list_subscript native
Consolidate the two separate conditional branches for empty range on zero-length list into a single expression using ternary on range->isInclusive, removing the TODO comment and reducing code duplication.
2014-12-31 18:34:44 +00:00
Bob Nystrom 0fafa4bd07 refactor: replace integer stack index with pointer for stack top in fiber
Migrate fiber stack management from an integer `stackSize` counter to a direct `Value* stackTop` pointer, eliminating repeated `stack[stackSize - 1]` calculations. Update all stack slot accesses, iteration loops, and the `CallFrame::stackStart` field to use pointer arithmetic, simplifying the code and reducing index arithmetic overhead.
2014-12-31 18:34:27 +00:00
Bob Nystrom d34cbd33ee perf: cache frame stack start pointer in local variable to reduce memory accesses
Store the start of the current frame's stack in a local `stackStart` variable
during LOAD_FRAME() macro execution, replacing repeated calculations of
`fiber->stack[frame->stackStart + offset]` with `stackStart[offset]` across
LOAD_LOCAL and LOAD_FIELD opcodes. Also remove unused `upvalues` register
variable and its assignments from closure handling paths.
2014-12-08 14:57:36 +00:00
Bob Nystrom ee9d10f5f5 fix: update benchmark chart values for method call and delta blue tests
The performance numbers in the documentation's benchmark chart have been refreshed to reflect the latest measurements. Method call results now show wren at 5100 (up from 4930), luajit at 4441 (up from 4266), ruby at 2868 (up from 2752), lua at 1742 (up from 1728), python3 at 884 (up from 865), and python at 779 (up from 764). DeltaBlue results show wren at 7006 (up from 6662) and python3 at 2333 (down from 2336).
2014-12-07 22:34:17 +00:00
Bob Nystrom d224721f79 feat: store class reference directly in Obj struct and inline class lookup for method dispatch
Move the class pointer from ObjInstance into the base Obj struct and remove the separate metaclass field from ObjClass, allowing all heap objects to directly reference their class. Add an inlined wrenGetClassInline function in the header to eliminate function call overhead during method dispatch, yielding 10-43% performance gains across benchmarks.
2014-12-07 22:29:50 +00:00
Bob Nystrom 520e841044 feat: add specialized LOAD_LOCAL_0..8 instructions to skip arg byte decode
Introduce nine new bytecode instructions (CODE_LOAD_LOCAL_0 through CODE_LOAD_LOCAL_8) that directly encode the local slot number in the opcode itself, eliminating the need to read and decode a separate argument byte for the most frequently accessed local variables. This optimization targets the hottest path in the interpreter, as LOAD_LOCAL is the most executed instruction across benchmarks (e.g., 3.75M times in delta_blue). The compiler's `loadLocal` helper emits the specialized opcode when the slot index is ≤8, falling back to the generic `CODE_LOAD_LOCAL` with an argument byte otherwise. The VM dispatch table and debug printer are updated accordingly. Benchmarks show consistent speedups: fib +7.3%, method_call +5.9%, binary_trees +1.9%, for +2.8%, delta_blue +1.0%.
2014-12-07 03:59:11 +00:00
Bob Nystrom a665e14804 feat: add regression test for function with 8195 constants exceeding limit
Add a new test file `test/limit/too_many_constants.wren` containing a single function with 8195 integer literal constants to verify the compiler correctly rejects functions that exceed the maximum constant count limit.
2014-12-07 00:39:39 +00:00
Bob Nystrom 77bddf8f0a refactor: extract wrenNewUninitializedString to avoid passing NULL to wrenNewString for empty buffers 2014-12-06 18:04:46 +00:00
Bob Nystrom 9b498b4638 fix: ensure all switch and unreachable paths return a value in release builds
In `getNumArguments`, add a `return 0` after the `UNREACHABLE()` default case to prevent
undefined behavior when assertions are disabled. In `wrenGetClass`, reorder the
`UNREACHABLE()` macro before the `return NULL` so the unreachable annotation is
always emitted. In `runInterpreter`, replace the `ASSERT(0, ...)` with an explicit
`UNREACHABLE()` and `return false` to guarantee a return value on all control paths
when the interpreter exits unexpectedly.
2014-12-02 05:36:06 +00:00
Bob Nystrom 306c33f01c fix: wrap ASSERT in do-while and add UNREACHABLE macro for GCC compatibility 2014-11-28 19:21:01 +00:00
Bob Nystrom 3266491cf5 fix: correct break statement instruction size from 2 to 3 in endLoop to prevent code walker from misinterpreting arguments 2014-11-27 02:33:54 +00:00
Bob Nystrom d9a42f21ba fix: add missing -lm link flag and fix GCC warnings for getline and switch coverage
Add -lm flag to both debug and release linker commands in Makefile to resolve
undefined math library references. Define _GNU_SOURCE in main.c to make getline()
available under GCC. Add default cases to switch statements in runFile and
getNumArguments to suppress -Wswitch warnings. Fix u_int8_t to uint8_t type in
wrenNewFunction declaration and definition for POSIX compliance.
2014-11-26 22:03:05 +00:00
Bob Nystrom d60068db56 feat: add Fiber.try() method for catching errors across fiber boundaries
Implement a new `Fiber.try()` method that allows a calling fiber to catch runtime errors from a called fiber. When a fiber is invoked with `try()` instead of `call()`, any runtime error that occurs in the called fiber is returned as a string to the caller rather than terminating the program with a stack trace. The `callerIsTrying` flag on `ObjFiber` tracks this state, and the `runtimeError` function now checks this flag to redirect the error to the caller's stack. Also adds `Fiber.error` getter to retrieve the error string from a failed fiber, changes `Fiber.isDone` to return `true` for errored fibers, and migrates the fiber error field from a raw `char*` to an `ObjString*` for proper memory management. Includes comprehensive test cases for try behavior, re-entry prevention, and error state queries.
2014-10-15 13:36:42 +00:00
Bob Nystrom d4a858da43 style: darken site color palette and remove left margin from main paragraphs and pre blocks 2014-10-04 16:57:40 +00:00
Bob Nystrom c427ca4c10 style: shift all SCSS color variables from 200° to 210° hue and adjust link/string saturation and lightness 2014-09-14 16:39:44 +00:00
Bob Nystrom ee05fb67b0 feat: replace placeholder core-libraries doc with full core-library reference and refine site design
Replace the empty `core-libraries.markdown` placeholder with a comprehensive `core-library.markdown` documenting Object, Class, Bool, and Fiber classes. Update site template to link to the new page. Tweak SCSS styles: reduce body font to 16px/25px, darken header background with text-shadow, adjust code font size and borders, add left margin to main content paragraphs and pre blocks, and refine link colors. Fix prose in functions.markdown to use "arguments" instead of "parameters" and clarify dynamic dispatch wording.
2014-08-24 16:09:10 +00:00
Bob Nystrom 235518637a style: update site color scheme, typography, and copy across documentation pages 2014-08-19 14:35:20 +00:00
Bob Nystrom 5055e1fb87 chore: reorder Makefile targets and add comments for build steps 2014-04-26 15:07:03 +00:00
Bob Nystrom 4d413f3473 fix: add null check when walking upvalue list in captureUpvalue
The crash occurred in captureUpvalue() when an upvalue for an earlier local
variable was captured after a later one. The function walked to the end of the
open upvalue list but then dereferenced a NULL pointer when comparing
upvalue->value against the target local slot.

Added a NULL guard before the equality check so that if no existing upvalue
is found, the function correctly proceeds to create a new one instead of
dereferencing a null pointer.

Also fixed a typo in the comment ("existsing" -> "existing").

Added regression test close_over_later_variable.wren that exercises the
scenario of capturing upvalues for locals in reverse declaration order.
2014-04-25 00:52:53 +00:00
Bob Nystrom 8abbc4197c feat: add MAX_VARIABLE_NAME limit and improve field overflow error message
Add a 64-character maximum identifier length with compile-time error reporting, and enhance the runtime field overflow error to include the class name and remove the TODO comment. Update test expectations for both limit scenarios.
2014-04-22 14:06:26 +00:00
Bob Nystrom 74ca0d8aad style: replace hardcoded column classes with semantic nav-column/main-column and add responsive breakpoints 2014-04-21 04:42:17 +00:00
Bob Nystrom bbd4cc0f56 feat: add benchmark chart visualization to performance page
Refactor benchmark runner to store results in a nested dict keyed by language name, enabling per-benchmark result aggregation. Add bar chart HTML tables to doc/site/performance.markdown displaying method call, DeltaBlue, and binary trees benchmarks across languages. Include SCSS styles for chart layout, bar coloring, and main content padding.
2014-04-21 04:04:41 +00:00
Bob Nystrom 7ee9987ab3 docs: remove comparison to Python/C# generators and merge fiber scheduling paragraphs in fibers doc 2014-04-20 03:33:49 +00:00
Bob Nystrom e665d4a9d3 feat: add closure test for shadowing closed-over variable with local
Add a new test case `shadow_closure_with_local.wren` that verifies a closed-over
variable can be shadowed by a local variable in an inner scope within the same
closure. The test ensures that the outer closure variable retains its value
outside the inner scope after the shadowing local goes out of scope.

Also remove an incomplete TODO comment from `reuse_closure_slot.wren` and add
a detailed TODO comment in `wren_compiler.c` discussing the design trade-off
between treating capitalized names as globals versus implicit `this` calls
when walking the scope chain.
2014-04-20 00:48:06 +00:00
Bob Nystrom 963773ecbc test: add super call tests for arity dispatch and missing method errors
Add test cases for super calls with different argument arities to verify correct method dispatch to the superclass. Also add a test for runtime error when calling a non-existent superclass method, and remove the TODO comment for that case.
2014-04-19 18:51:36 +00:00
Bob Nystrom 29f4b8167c feat: add zero-arg IO.print overload and remove newline skipping in parameter parsing
Add a static `print` method with no arguments that writes only a newline, enabling blank-line output. Remove the `ignoreNewlines` calls before closing parentheses in parameter lists and method calls, tightening syntax rules. Add a `strlen` TODO comment in symbol table lookup for future optimization. Move the `Foo.toString` test from `test/io/write.wren` to `test/io/print.wren` and delete the old write test file.
2014-04-19 18:44:51 +00:00
Bob Nystrom 15560a95f6 chore: move truthiness tests from if/ to for/ directory with Iter class
The truth.wren test file is relocated from test/if/ to test/for/, and the test logic is rewritten to use a custom Iter class with for-in loops instead of if statements, while preserving the same truthiness assertions for false, null, true, 0, and empty string values.
2014-04-19 18:41:21 +00:00
Bob Nystrom 818551fd4a feat: add category metadata to doc pages and switch code blocks from wren to dart
Add `^category` front matter to branching, classes, error-handling, fibers, functions, lists, looping, maps, method-calls, performance, and qa markdown files. Create new placeholder pages for contributing, core-libraries, and embedding-api under reference category. Remove old embedding and getting-involved pages. Change all `:::wren` code block annotations to `:::dart` across multiple documentation files. Update index title from "Welcome" to "Welcome!" and fix a typo in the Wren class example string. Refine performance page wording for clarity.
2014-04-16 15:00:42 +00:00
Bob Nystrom f2edb03389 docs: clarify fiber scheduling and Lua coroutine comparison in documentation 2014-04-15 13:47:16 +00:00
Bob Nystrom 6ed15da597 feat: add category metadata to doc pages and switch code blocks to dart syntax
Add `^category` front matter to all language, types, and reference doc pages for site navigation restructuring. Replace `:::wren` and `:::java` code block annotations with `:::dart` across multiple files. Create new stub pages for core-libraries, embedding-api, and contributing under the reference category. Remove the old embedding and getting-involved stub pages.
2014-04-15 04:23:46 +00:00
Bob Nystrom 10b19d969b feat: implement symmetric coroutines with fiber.call and fiber.run distinction
Add new `fiber.call` method that remembers the calling fiber for symmetric transfer, while `fiber.run` now performs tail-call style switching without preserving the caller. Introduce re-entrancy guards preventing a fiber from being called multiple times, update all test fixtures to use the new API, and add comprehensive test coverage for call semantics including direct/indirect re-entrancy, value passing, and finished fiber errors.
2014-04-14 14:23:05 +00:00
Bob Nystrom 71783400ae docs: add documentation for conditional operator, fibers, break statements, and ranges; remove placeholder usage page 2014-04-11 17:45:20 +00:00
Bob Nystrom 5140d096a1 feat: add responsive layout with viewport meta, media queries, and semantic HTML elements
Replace fixed-width `.page` with `max-width`, add `padding` to body, and introduce two breakpoints (639px and 479px) that adjust nav gutter, header centering, and main margin. Convert `.header`, `.content`, `.nav` divs to `<header>`, `<main>`, `<nav>` tags, add viewport meta tag, and hide GitHub ribbon on small screens.
2014-04-11 17:44:33 +00:00
Bob Nystrom d791dd0d7c docs: add Getting Started page with setup instructions and interactive mode examples
Add a comprehensive Getting Started guide covering Unix/Mac installation via git clone and make, interactive mode usage with code examples, and script execution with a Mandelbrot fractal demo. Also update the site navigation template to link the new page, add placeholder pages for Embedding, Error Handling, and Getting Involved, fix the index page link from "usage.html" to "embedding.html", and reorder the types section in the nav to list Fibers before Functions.
2014-04-09 14:53:30 +00:00
Bob Nystrom 3e5fdc2250 feat: add overloaded IO.print methods accepting 2-16 arguments and printList_ helper
Add 15 static overloads of IO.print in builtin/io.wren and src/wren_io.c, each delegating to a new private printList_ method that iterates over a list of objects. Update all benchmark and test files to use the new multi-argument syntax, removing explicit .toString calls and string concatenation. Add a comprehensive test/io/print.wren verifying single-argument return value, multi-argument null return, and concatenation of up to 16 arguments.
2014-04-09 14:48:35 +00:00
Bob Nystrom 786e20ba93 fix: update delta_blue benchmark setter methods to new Wren syntax
Replace legacy setter syntax `property = value { ... }` with the modern
`property=(value) { ... }` form across all five property setters in the
Variable class (determinedBy, mark, walkStrength, stay, value).
2014-04-09 04:40:31 +00:00
Bob Nystrom 985b1b9cf7 docs: add block syntax documentation, remove outdated TODOs, and add prefix ~ operator test 2014-04-09 04:18:17 +00:00
Bob Nystrom 0d74b128a5 fix: enforce string type validation in string_plus and remove coercion TODO
- Replace silent null return with explicit string type check in string_plus native
- Remove outdated TODO comments about string coercion from both num_plus and string_plus
- Add test for basic string concatenation ("a" + "b")
- Add test verifying runtime error when concatenating string with non-string ("a" + 123)
2014-04-09 04:17:49 +00:00
Bob Nystrom fca506fdf1 feat: require parentheses around operator and setter method parameters in Wren
Enforce syntactic requirement for parentheses in operator method signatures (e.g., `+(other)` instead of `+ other`) and setter definitions (e.g., `bar=(value)` instead of `bar = value`). Update the compiler's `infixSignature`, `mixedSignature`, and `namedSignature` functions to consume explicit `(` and `)` tokens around parameter names. Migrate all built-in core library operator definitions and test fixtures to the new parenthesized syntax.
2014-04-09 00:54:37 +00:00
Bob Nystrom 25098cd181 style: shift stylesheet color palette from warm orange to cool blue tones 2014-04-08 14:46:47 +00:00
Bob Nystrom 8d1e9750b8 feat: implement List instantiation via "new" and fix inline functions to static
Add `list_instantiate` native to create empty lists, bind it to List's metaclass for `new` support, and remove the related TODO. Also change three `inline` functions in `wren_value.h` to `static inline` to prevent linker errors. Include a new test `test/list/new.wren` verifying `new List` yields an empty list that supports `add`.
2014-04-08 14:31:23 +00:00
Bob Nystrom 8113e0bfc0 perf: inline wrenIsBool and wrenIsObjType into header, remove from source
Move the wrenIsBool and wrenIsObjType function definitions from wren_value.c
into wren_value.h as inline functions, eliminating function call overhead.
Also relocate OBJ_VAL macro definition to appear before its first use in the
header and add inline for wrenObjectToValue. This yields 3-13% speedup across
benchmarks (binary_trees, delta_blue, fib, for, method_call).
2014-04-08 14:17:25 +00:00
Bob Nystrom c92a12bf31 docs: recolor doc site with warm earth tones and update prose for clarity 2014-04-08 04:03:16 +00:00
Bob Nystrom c148fc307b fix: rename PinnedObj to WrenPinnedObj for public visibility in macros
The internal PinnedObj type was renamed to WrenPinnedObj across the codebase to make it publicly accessible, as the WREN_PIN macro expands to stack allocations of this type that must be visible to external consumers. Updated all typedefs, function signatures, and variable declarations in wren_vm.c and wren_vm.h to use the new prefixed name, and removed the TODO comment about moving the struct into wren_vm.c.
2014-04-07 14:47:58 +00:00
Bob Nystrom 2aaf6e5489 chore: rename debug and feature flags to consistent WREN_DEBUG_ and WREN_USE_ prefixes
Rename boolean defines from `true`/`false` to `1`/`0` for consistency, prefix debug flags with `WREN_DEBUG_`, add `WREN_USE_LIB_IO` flag to guard IO library loading, and wrap IO module includes and function declarations in conditional compilation blocks.
2014-04-07 14:45:09 +00:00
Bob Nystrom e1cd942656 refactor: rename SymbolTable fields and flatten struct to StringBuffer alias
Replace the nested `SymbolTable` struct (containing a `StringBuffer names` field) with a direct `typedef StringBuffer SymbolTable`, updating all internal accesses from `symbols->names.data` to `symbols->data` and `symbols->names.count` to `symbols->count`. Rename `vm->methods` to `vm->methodNames` and `vm->globalSymbols` to `vm->globalNames` across the codebase, including debug printing, compiler symbol resolution, core initialization, and VM interpreter error messages. Remove the stale TODO comment about error codes in `wren.h` and adjust the `instantiate` method name to include a leading space to prevent direct user invocation.
2014-04-07 01:59:53 +00:00
Bob Nystrom 23f5647fd8 fix: correct typo in dart reserved word list and capitalize nav link titles
Fix missing space between 'false' and 'for' in the reserved words example
on the syntax documentation page. Also capitalize 'Method calls' to
'Method Calls' and 'Error handling' to 'Error Handling' in the template
navigation sidebar for consistent title casing.
2014-04-06 23:16:24 +00:00
Bob Nystrom e7d2684d30 feat: replace fixed-size global array with growable ValueBuffer to support more than 256 globals
Replace the static `Value globals[MAX_GLOBALS]` array in WrenVM with a dynamic `ValueBuffer` that grows on demand, removing the 256-global limit. Introduce `wrenDefineGlobal()` helper that adds a named global to the symbol table and stores its value in the buffer, returning -2 when the 65536 limit is reached. Update all global access sites (compiler emit, runtime interpreter, GC marking, debug disassembly, core class definition) to use the buffer's data pointer and short (16-bit) opcode arguments instead of byte-sized ones. Add a regression test `many_globals.wren` that defines 8200 globals to verify the new capacity.
2014-04-06 23:16:15 +00:00
Bob Nystrom f291f2ca6e docs: replace IO.write with IO.print across multiple documentation files 2014-04-06 15:38:00 +00:00
Bob Nystrom be8c586d4b feat: implement List.addAll() method to append elements from iterable
Add `addAll(other)` method to the List class in both the Wren core library source and its embedded C string representation. The method iterates over the given `other` sequence, appends each element to the list using the existing `add()` method, and returns the original `other` argument to match the documented return behavior. Include a new test file `test/list/add_all.wren` covering basic appending, empty iterable, range input, and return value verification.
2014-04-06 15:37:37 +00:00
Bob Nystrom e8d31eddaf feat: replace hand-written CSS with Sass compilation and update site design with new fonts and layout
- Delete doc/site/style.css and add doc/site/style.scss with Sass variables, Dosis header font, box-sizing, absolute header positioning, and link hover effects
- Update template.html to reference Dosis font, lowercase nav headings, and change tagline to "a classy little scripting language"
- Add .sass-cache/ to .gitignore and rename Makefile phony target from docs to builtin
- Modify generate_docs.py to compile style.scss via sass subprocess instead of copying static CSS
- Tweak performance.markdown and qa.markdown for minor wording improvements
2014-04-05 22:39:02 +00:00
Bob Nystrom e3e9178f3a docs: add comprehensive documentation for functions in Wren language
Replace the placeholder TODO stub with full documentation covering function creation, block arguments, parameters, closures, and usage patterns. The new content includes examples of block argument syntax, method definitions accepting functions, and passing existing function objects as arguments.
2014-04-05 03:45:12 +00:00
Bob Nystrom 059d3e4fe6 feat: replace Fiber.create constructor with new Fiber instantiation pattern
Refactor fiber creation from a static `Fiber.create` method to a constructor-based `new Fiber` pattern. This introduces a `fiber_instantiate` native that returns the Fiber class itself, allowing `new Fiber` to invoke `fiber_new` for validation and creation. A shared `validateFn` helper is added to centralize function argument checking, replacing inline validation in both `fiber_new` and `fn_new`. All test files are updated to use the new syntax, and the old `create_wrong_arg_type` test is replaced with `new_wrong_arg_type`.
2014-04-05 01:24:55 +00:00
Bob Nystrom 4c4f32b5b2 feat: validate argument type in Fn.new and add runtime error test
Add type checking to the `fn_new` native function to ensure the argument
passed to `Fn.new` is either a function or closure. Previously, passing
an invalid type like an integer would silently succeed. Now it returns
a clear runtime error message: "Argument must be a function."

Also remove two stale TODO comments about newline handling in the
compiler that were no longer relevant to current parsing logic.
2014-04-05 01:13:13 +00:00
Bob Nystrom 093da7befb refactor: move newline handling from lexer into parser grammar rules
This change shifts newline tokenization from the lexer's readRawToken into the parser's nextToken, allowing the grammar to selectively ignore newlines in specific contexts (e.g., after operators like "|", "is", "for", "if", "while") while treating them as errors in others (e.g., after "var", "new", "class", "static", before commas in lists). The lexer now emits TOKEN_LINE for semicolons and newlines uniformly, and the parser decides which to elide. Test files are updated to reflect the new error expectations and to remove tests for newlines that are now grammatically allowed.
2014-04-04 14:51:18 +00:00
Bob Nystrom a1365c4183 feat: unify block, function, and method body parsing to support single-expression implicit returns
Refactor `finishBlock` in `wren_compiler.c` to detect single-expression bodies (no newline after `{`) and leave a value on the stack, enabling implicit returns for methods and functions. Add `finishBody` wrapper to handle constructor flag. Update all benchmark and test `.wren` files to remove explicit `return` keywords from getters and single-expression methods, relying on the new implicit return behavior. Remove old `return_null_if_brace.wren` test, add `newline_body.wren`, `newline_in_expression_block.wren`, and `no_newline_before_close.wren` tests for edge cases.
2014-04-03 14:48:19 +00:00
Bob Nystrom de2650b0ba fix: remove deprecated TOKEN_FN and old function syntax from wren compiler
Remove the TOKEN_FN enum value, its keyword mapping in readName, and the
associated function syntax handling from the tokenizer. Also clean up
unnecessary operator tokens from the newline-skipping switch in nextToken
to simplify the token processing logic.
2014-04-03 03:22:36 +00:00