Commit Graph
100 Commits
Author SHA1 Message Date
Bob Nystrom 869ecb9f07 fix: correct error message and comment to use 'construct' instead of 'this' in constructor methods 2015-08-21 05:23:53 +00:00
Bob Nystrom 80f60f385d fix: correct test name from 'should_process_empty_input' to 'should_handle_empty_input' 2015-08-21 05:04:42 +00:00
Bob Nystrom f2ba534704 feat: add scientific notation parsing for number literals in wren compiler
Implement support for scientific notation (e.g., 2.55e2, 1.2e-3) in the Wren compiler's number lexer. The readNumber function now handles 'e'/'E' exponent markers with optional negative sign, emitting a lex error for unterminated exponents. Added comprehensive test cases covering valid scientific literals, missing exponents, fractional parts, and multiple exponent markers. Also added Alexander Roper to AUTHORS and removed related TODO comments.
2015-08-21 05:03:19 +00:00
Bob Nystrom e24aba2644 docs: replace placeholder embedding API page with full configuration and hosting guide 2015-08-21 05:02:13 +00:00
Bob Nystrom 8d315517e5 fix: update relative links to absolute URLs for getting-started and contributing pages in README 2015-08-16 02:58:42 +00:00
Bob Nystrom 2dc209e585 feat: add foreign class support with allocation, construct opcodes, and CLI callback wiring
Implement the initial infrastructure for foreign classes in the Wren VM, including new opcodes (FOREIGN_CONSTRUCT, FOREIGN_CLASS), a WrenBindForeignClassFn callback type in the public API, and updated CLI vm.c to store and forward foreign binding callbacks via setForeignCallbacks(). The compiler now tracks whether a class is foreign via a new isForeign flag in ClassCompiler, emits CODE_FOREIGN_CONSTRUCT instead of CODE_CONSTRUCT for foreign class constructors, and errors on field definitions inside foreign classes. The debug dump and opcode header gain entries for the new opcodes, and wrenBindSuperclass handles the -1 numFields sentinel for foreign classes to prevent field inheritance from superclasses.
2015-08-15 19:07:53 +00:00
Bob Nystrom 7551fa8c9b refactor: consolidate per-test subdirectories into flat test/api structure with merged returns and value files 2015-08-13 16:09:27 +00:00
Bob Nystrom f9f8b55b29 feat: add support for passing WrenValue pointers as 'v' type argument to wrenCall
Extend the wrenCall variadic argument handling to accept a new 'v' type specifier,
which allows callers to pass a previously acquired WrenValue* directly without
implicitly releasing it. This enables reusing existing Wren values across multiple
calls without unnecessary string or number conversions.

The implementation reads a WrenValue* from the variadic arguments and extracts
its internal Value for the call. Additionally, fix the parameter counting logic
in makeCallStub to correctly count underscore parameters only within the
parenthesized signature portion, preventing off-by-one errors for methods with
trailing parentheses in their signature strings.
2015-08-07 14:57:23 +00:00
Bob Nystrom 592772a97d feat: add WrenValue handle API for persistent object references outside VM
Introduce WrenValue type and wrenGetArgumentValue/wrenReleaseValue functions to allow C code to hold GC-safe references to Wren objects across foreign calls. Implement doubly-linked list management in VM struct, mark value handles during garbage collection, and add assertion in wrenFreeVM to detect unreleased values. Update test infrastructure with new get_value test case and rename existing test binding functions to camelCase convention.
2015-08-07 05:24:15 +00:00
Bob Nystrom 8468ca7642 fix: fully initialize Signature struct fields in signatureFromToken and methodCall 2015-08-06 14:34:19 +00:00
Bob Nystrom 45c717b11b feat: add module parameter to wrenFindVariable and expose wrenGetCoreModule
Refactor wrenFindVariable to accept an explicit ObjModule* parameter instead of
implicitly using the main module. Promote the internal getCoreModule helper to
a public wrenGetCoreModule function declared in wren_vm.h. Update all call sites
in wren_core.c and wren_meta.c to pass the core module when looking up core
variables, and replace inline getCoreModule calls in wren_vm.c with the new
public function. Remove the NULL-module fallback documentation from
wrenDeclareVariable and wrenDefineVariable.
2015-08-06 14:13:11 +00:00
Bob Nystrom 5e7ea2f135 fix: correct tombstone handling in map insertion to prevent deadlock
The addEntry function was incorrectly skipping tombstone entries when inserting new keys, causing the map to fill up with tombstones and eventually deadlock on insert. The fix removes the tombstone check that prevented overwriting tombstone slots with new entries, allowing proper reuse of removed entries.

A regression test (test/core/map/churn.wren) was added to verify that inserting and removing entries in a loop correctly maintains the map count without deadlocking.
2015-08-06 13:55:30 +00:00
Bob Nystrom 7d9e45e906 feat: replace 'this' keyword with 'construct' for constructor definitions across core lib, compiler, docs, and tests
Add TOKEN_CONSTRUCT as a new reserved word in the Wren compiler lexer and parser, and update the grammar rule table so that 'construct' triggers a constructor signature instead of 'this'. Modify all built-in class definitions in core.wren, wren_core.c, benchmark files, and test fixtures to use 'construct new(...)' and 'construct named(...)' syntax. Update documentation in classes.markdown and syntax.markdown to reflect the new keyword, and remove the deprecated test files for 'new' and infix class expressions.
2015-07-21 14:24:53 +00:00
Bob Nystrom 847edd8e1e fix: correct Fiber instantiation syntax in README code example
The example previously used `new Fiber { ... }` which is incorrect Wren syntax; changed to `Fiber.new { ... }` to match the language's constructor pattern.
2015-07-20 14:34:30 +00:00
Bob Nystrom 67f1480bf0 chore: migrate Travis CI to container-based builds and update README links
- Switch Travis CI from sudo-based apt-get to addons.apt.packages for gcc-multilib
- Enable container-based builds with `sudo: false`
- Update README.md call-to-action links to point to getting-started and browser playground
- Replace `printList_` with `printAll` in IO class and remove redundant `IO.` prefixes
- Add IO.read() method documentation and update IO.print docs for up to 16 arguments
- Reorganize community page with Libraries, Language bindings, and Tools sections
- Add wrenjs JavaScript binding and Sublime Text syntax highlighting
- Fix typo "no where" to "nowhere" in fibers documentation
- Add indentation to preprocessor defines in wren_common.h for consistency
- Remove unreachable `return 0` after UNREACHABLE() in wren_compiler.c
- Fix Windows color output by wrapping text in str() in test script
2015-07-19 19:49:23 +00:00
Bob Nystrom 33560c3824 fix: correct attribute reference and type coercion in test runner error handling
- Fix `validate_runtime_error` to reference `self.runtime_error_message` instead of undefined `runtime_error_message`
- Ensure `color_text` returns `str(text)` on Windows to avoid type mismatch when non-string input is passed
2015-07-19 17:31:55 +00:00
Bob Nystrom bb7ce3b10a refactor: extract inline helper for retrieving ObjFn from CallFrame
Replace three duplicated switch-on-type patterns (in wrenDebugPrintStackTrace, wrenAppendCallFrame, and runInterpreter) with a single static inline wrenGetFrameFunction that handles OBJ_FN and OBJ_CLOSURE cases with an UNREACHABLE default.
2015-07-19 17:16:54 +00:00
Bob Nystrom 177d53fe68 fix: align preprocessor indentation and remove dead code after UNREACHABLE in non-nan-tagged and non-computed-goto modes 2015-07-19 17:16:27 +00:00
Bob Nystrom 4c79185a3d fix: correct argument in test runner fail call to show expected error message
The diff shows that in `script/test.py`, the `self.fail()` call on line 158 was passing `runtime_error_message` (the actual error) instead of `self.runtime_error_message` (the expected error) when formatting the failure message. This fix swaps the argument to display the correct expected error string in the test output.
2015-07-19 16:33:00 +00:00
Bob Nystrom ef4b2f90f7 fix: correct typo "no where" to "nowhere" in fibers documentation
The diff fixes a single-word typo in the fibers documentation markdown file,
changing the incorrect two-word phrase "no where" to the correct compound word
"nowhere" in the sentence explaining why the first value sent to a fiber is ignored.
2015-07-19 16:10:42 +00:00
Bob Nystrom 0c336449e3 fix: correct punctuation in TODO comment and fix brace placement in ioRead function 2015-07-18 21:17:39 +00:00
Bob Nystrom bcd4df7e25 feat: make IO.printAll public and require parentheses on IO.read
Rename private `printList_` to public `printAll` across all overloaded `IO.print` methods in both Wren source and embedded C string. Update `IO.read` to require explicit `()` call syntax in test and documentation. Revise IO documentation to clarify `print`, `printAll`, `write`, and `read` semantics with updated examples.
2015-07-18 21:09:00 +00:00
Bob Nystrom 35305797b2 feat: add string_equals.py benchmark for equality comparison performance
Add a new benchmark file that measures performance of string equality comparisons
across various lengths and match/mismatch scenarios, including type mismatch
between string and integer.
2015-07-18 18:21:49 +00:00
Bob Nystrom 83d01fdf5b docs: restructure community page with library, binding, and editor sections and update README call-to-action links 2015-07-18 18:19:52 +00:00
Bob Nystrom 864210978b chore: switch travis to container-based infra and move apt deps to addons block
Replace manual apt-get install steps with declarative addons.apt.packages for gcc-multilib, and set sudo: false to enable container-based builds for faster CI execution.
2015-07-10 17:35:25 +00:00
Bob Nystrom 3ea9e0f2a9 fix: initialize signature type to SIG_GETTER in unarySignature function 2015-07-10 17:27:32 +00:00
Bob Nystrom 852f726c5a fix: cast enum sum to Code type in createConstructor emitShortArg call 2015-07-10 16:22:04 +00:00
Bob Nystrom e19ff59cce feat: replace new keyword with this constructor syntax and ClassName.new() calls across core library and docs
Replace all uses of the `new` reserved word with explicit `this new()` constructor definitions and `ClassName.new()` instantiation calls in builtin/core.wren. Update all documentation files (classes.markdown, fiber.markdown, fn.markdown, sequence.markdown, error-handling.markdown, expressions.markdown, fibers.markdown, functions.markdown) to reflect the new constructor syntax, removing `new` keyword examples and replacing them with `ClassName.new()` patterns and `this new()` definitions.
2015-07-10 16:18:22 +00:00
Bob Nystrom 121d39cb42 fix: update expect error regex to not match expect error line patterns 2015-07-09 15:09:19 +00:00
Bob Nystrom 357e24efcb fix: correct test runner to fail on all unmet expected errors and refactor into Test class
The test runner previously short-circuited when a test expected an error and found at least one, causing it to miss other expected errors that didn't occur. This commit fixes the error pattern regex to exclude line-specific error expectations, removes specific error message strings from test files (since the runner doesn't validate them yet), and refactors the monolithic test function into a dedicated Test class with parse and run methods for better maintainability.
2015-07-09 15:06:33 +00:00
Bob Nystrom 5401742163 fix: correct typo in AUTHORS file and add Starbeamrainbowlabs to contributor list
Fix the misspelling of "incomplete" in the AUTHORS file header and append
Starbeamrainbowlabs with their email address to the end of the contributor list.
2015-07-01 23:07:51 +00:00
Bob Nystrom b1c9231b5a docs: fix code block language annotations, method formatting, and footer credits in documentation site 2015-07-01 15:11:10 +00:00
Bob Nystrom 272273e539 docs: add IO class documentation with print, write, and read static methods
Add a new doc page for the IO class covering its three static methods:
IO.print() for printing multiple values with a trailing newline, IO.write()
for printing a single value without a newline, and IO.read() for reading a
line of text from the console with a prompt. Also update the core index page
and template sidebar to include a link to the new IO documentation.
2015-07-01 13:44:27 +00:00
Bob Nystrom 29ca6f4ffc feat: dynamically grow fiber call frame array instead of fixed MAX_CALL_FRAMES
Replace the statically-sized CallFrame array in ObjFiber with a dynamically
allocated array that starts at INITIAL_CALL_FRAMES (4) and doubles when
capacity is exceeded. This reduces memory for new fibers and improves
fiber creation benchmark performance by ~45%.
2015-07-01 07:00:25 +00:00
Bob Nystrom 8ae42156d8 feat: add return_this primitive to replace duplicated identity-returning implementations
Extract the common pattern of returning the receiver argument into a single
DEF_PRIMITIVE(return_this) function, and refactor fiber_instantiate,
fn_instantiate, and the default Object constructor to use it instead of
inline RETURN_VAL(args[0]) calls. Also fix trailing whitespace on isEmpty
and class_toString lines in the core library source string.
2015-06-30 14:39:43 +00:00
Bob Nystrom 1dc1c4e2bf feat: add isEmpty method to Sequence class with efficient early-termination check 2015-06-30 13:52:29 +00:00
Bob Nystrom d04e6a61a6 feat: add dedicated toString primitive for Class and simplify object_toString
Extract class name retrieval from object_toString into a new class_toString primitive, registered on the Class metaclass. This removes the IS_CLASS branch from object_toString, which now only handles instances and falls back to "<object>". The change ensures Class objects return their own name directly via toString rather than relying on the generic object handler.
2015-06-28 22:33:37 +00:00
Bob Nystrom 43af98f1a5 refactor: merge duplicate call-handling logic between CODE_CALL and CODE_SUPER into shared code block
Eliminate the performance penalty of an if-test inside the call instruction loop by using explicit goto to share the common tail-end call-handling code between normal and superclass calls. This improves interpreter throughput across multiple benchmarks, with gains of up to 23% on the 'for' benchmark and 14% on 'fib'.
2015-06-28 17:58:48 +00:00
Bob Nystrom 862d1dfb07 fix: change runInterpreter signature to return WrenInterpretResult and accept explicit fiber parameter 2015-06-27 15:56:52 +00:00
Bob Nystrom 5e4ecd4d41 fix: include method name in block argument debug name
When a block is passed as an argument to a method call, the generated
function's debug name now includes the method's signature followed by
" block argument" instead of the generic "(fn)" placeholder. This
improves debugging by showing which method the block belongs to.
2015-06-27 15:36:20 +00:00
Bob Nystrom f481ea7fe6 test: add tests for incomplete UTF-8 sequences in codePointAt and remove TODO comment
Add test cases for single-byte incomplete two-octet and three-octet UTF-8 sequences
in code_point_at_incomplete.wren, and remove the resolved TODO comment about testing
truncated UTF-8 buffer reads in wrenUtf8Decode.
2015-06-27 15:11:58 +00:00
Bob Nystrom ab12bc97e0 fix: remove redundant free in setRootDirectory and fix memory leak in runFile 2015-06-27 06:01:07 +00:00
Bob Nystrom cd64d67c11 fix: prevent memory leaks by freeing rootDirectory and clearing compiler constants 2015-06-27 05:49:24 +00:00
Bob Nystrom 448ef51183 feat: add block argument syntax and operator overloading examples to syntax.wren
- Insert block argument patterns: `fields { block }`, `fields {|a, b| block }`, and variants with parentheses
- Add all infix operators (+, -, *, /, %, <, >, <=, >=, ==, !=, &, |) and prefix operators (!, ~, -) with string return values
- Fix class name capitalization from `literals` to `Literals` and update comment formatting for consistency
- Modify unicode escape example string to include extra characters between code points
2015-06-27 05:14:32 +00:00
Bob Nystrom 846f2bb003 refactor: extract module lookup into getModule helper and simplify loadModule logic 2015-06-23 14:15:22 +00:00
Bob Nystrom a4f5ee0280 refactor: replace dedicated CODE_IS opcode with infix operator method call for "is" 2015-06-19 14:58:07 +00:00
Bob Nystrom 275b2ca4e4 refactor: remove redundant null checks before wrenMarkObj calls in compiler, value, and vm modules
The wrenMarkObj function already handles null pointers internally, making the explicit
`if (x != NULL)` guards unnecessary. This change removes three such checks in
wrenMarkCompiler, markFn, and collectGarbage, simplifying the code without changing
behavior.
2015-06-18 14:52:05 +00:00
Bob Nystrom 321a538be3 fix: repair Visual Studio 2013 project files for wren and wren_lib with corrected configurations and filter definitions 2015-06-18 14:37:58 +00:00
Bob Nystrom 57decb9165 fix: statically bind super calls to superclass at compile time in wren_compiler
Super calls were dynamically resolved by walking the receiver's class hierarchy at runtime, which broke when a method containing a super call was inherited by a subclass. This change stores a reference to the superclass in a constant table slot during compilation, and the interpreter reads that constant directly to find the correct superclass method table. Also fixes getNumArguments ordering for CODE_SUPER cases and adds two test cases verifying super calls work correctly in inherited methods and closures within inherited methods.
2015-06-02 14:33:48 +00:00
Bob Nystrom 1fd1c76661 fix: statically dispatch super() calls by binding superclass at compile time
The super() call resolution is changed from dynamic runtime lookup (walking the receiver's class hierarchy) to static binding at class definition time. This ensures correct method dispatch when a method containing a super call is inherited by another subclass.

Key changes:
- In `callSignature()`, when compiling a `CODE_SUPER_0` instruction, a constant slot is created and filled with NULL, to be populated with the superclass reference when the method is bound.
- In `getNumArguments()`, the `CODE_SUPER_0` through `CODE_SUPER_16` cases are moved after the newly added 2-argument opcodes (`CODE_JUMP`, `CODE_LOOP`, etc.) to maintain correct ordering.
- In `dumpInstruction()`, the debug output now prints the superclass constant index alongside the method symbol.
- In `runInterpreter()`, the super call execution reads the superclass directly from the function's constant table instead of deriving it from the receiver's class at runtime.
2015-06-02 14:33:39 +00:00
Bob Nystrom 1b4d7d404d fix: correct NaN tagging diagrams in wren_value.h comment formatting
The ASCII diagrams in the NaN tagging documentation had misaligned
brackets and inconsistent dash counts that made the bit layout
confusing. Updated the exponent/mantissa separator from parentheses
to brackets, fixed the NaN bits indicator alignment, and corrected
the highest mantissa bit marker position to match the actual bit
positions in the IEEE 754 double representation.
2015-06-02 14:14:19 +00:00
Bob Nystrom 067199657e feat: add test build target and refactor CLI VM creation to accept foreign method bindings
- Add test executable build target in Makefile and wren.mk with new TEST_SOURCES variable
- Refactor createVM() and runFile() to accept WrenBindForeignMethodFn parameter
- Remove deprecated safeToString_ method from String class and simplify toString implementations
- Delete example/set.wren and add example/syntax.wren with syntax highlighting examples
- Refactor test runner script with color helper functions and add TEST_APP path
- Remove .DELETE_ON_ERROR from Makefile and add test dependency in test target
2015-05-27 13:57:20 +00:00
Bob Nystrom 3297642b65 feat: add api tests for returning double and null values from foreign functions
Introduce two new test suites under test/api/: return_double exercises wrenReturnDouble with integer and floating-point values, and return_null verifies that a foreign function returning nothing yields null. Refactor bindForeign dispatch in main.c to use a REGISTER_TEST macro, rename returnBoolBindForeign to return_boolBindForeign for consistency, and add an exit(1) on unknown foreign methods to prevent silent NULL returns.
2015-05-24 17:04:24 +00:00
Bob Nystrom 2961318302 feat: show number of expectations in test output
Add a global `expectations` counter and increment it each time an `EXPECT_PATTERN` match is found in test scripts. Display the total count alongside existing Passed/Failed/Skipped stats in the test runner output.
2015-05-24 16:45:52 +00:00
Bob Nystrom a8cb321063 feat: add C test harness and build infrastructure for embedding API tests
Add a new test runner under `test/api/` that compiles C test cases against the Wren VM, along with Makefile and Python test script changes to build and execute them. The first test (`return_bool`) exercises `wrenReturnBool` via foreign methods. The CLI's `createVM` and `runFile` now accept an optional `WrenBindForeignMethodFn` callback to support custom bindings in tests.
2015-05-24 16:29:25 +00:00
Bob Nystrom 3901ab57e7 feat: add C API test infrastructure with foreign method binding support
Add a new test framework for exercising the Wren C embedding API directly from C code, including a Makefile target, test runner modifications, and the first API test case for boolean return values. The build system now compiles test sources from `test/api/` into a separate test executable, and the CLI's `createVM` and `runFile` functions accept an optional `WrenBindForeignMethodFn` callback to enable foreign method binding in tests. The test runner (`script/test.py`) is refactored to support both script and API test types, passing the test name instead of the full path for API tests. The initial `return_bool` test verifies that `wrenReturnBool` correctly returns `true` and `false` from foreign methods.
2015-05-24 16:23:30 +00:00
Bob Nystrom 6d2bafc211 feat: add example directory test runner and ignore support to walk function
Add a `run_example` function that invokes `run_test` with `example=True`, which suppresses output comparison for example files. Extend the `walk` function with an `ignored` parameter to skip directories like `benchmark`. Update the test script to walk both `test` and `example` directories, enabling example files to be executed as tests to catch regressions like #266.
2015-05-23 15:32:33 +00:00
Bob Nystrom 38125a9cfe fix: remove outdated Set example from example/set.wren to resolve issue #266 2015-05-20 14:07:47 +00:00
Bob Nystrom df146953cd feat: add syntax highlighting example file for wren language constructs
Add a comprehensive example file `example/syntax.wren` that demonstrates all major syntactic constructs of the wren programming language, including class definitions, constructors, methods, control flow, literals, and reserved words. This file is primarily intended for testing syntax highlighters and covers nested comments, field declarations, static methods, setters, inheritance with `is`, and various control structures like `while`, `for`, `if`/`else`, and `break`.
2015-05-19 14:00:57 +00:00
Bob Nystrom 520b60c33f chore: remove unused .DELETE_ON_ERROR target for wren.c from Makefile 2015-05-19 14:00:44 +00:00
Bob Nystrom 057a59e1d3 feat: add syntax example file for Wren language highlighting
Add a comprehensive example file `example/syntax.wren` demonstrating syntactic constructs of the Wren programming language, including class definitions, constructors, methods, reserved words, literals, and control flow structures. This file is primarily intended for testing syntax highlighters and covers nested comments, field declarations, static methods, setters, inheritance with `is`, and various keyword usage patterns.
2015-05-19 13:58:12 +00:00
Bob Nystrom 701cffbe69 revert: remove safeToString_ and recursive toString handling due to memory leak on runtime errors
The safeToString_ mechanism introduced in 40897f33 used per-fiber maps and lists to detect recursive toString calls, but leaked memory when runtime errors occurred before cleanup. This reverts to direct toString implementations for List and Map, removing the recursive detection logic and updating tests to mark self-referencing containers as TODO.
2015-05-19 13:50:17 +00:00
Bob Nystrom 50de0dc5a8 feat: add failing tests for super calls in closures and inherited methods
Add two new test files covering super behavior in Wren's class inheritance:
- super_in_closure_in_inherited_method.wren tests super.toString inside a closure
  within an inherited method, expecting "instance of B" output.
- super_in_inherited_method.wren tests direct super.toString call in an inherited
  method, also expecting "instance of B". Both tests are currently expected to fail.
2015-05-19 13:47:42 +00:00
Bob Nystrom 13f63e0d04 feat: add wrenByteBufferFill and wrenMethodBufferFill for bulk buffer growth
Replace the loop-based single-element writes in readUnicodeEscape and wrenBindMethod with a new BufferFill macro that grows the buffer by a specified count in one allocation. The macro doubles capacity until it fits the requested count, then fills the new slots with the given data. The existing BufferWrite is reimplemented as a call to BufferFill with count=1.
2015-05-05 13:54:13 +00:00
Bob Nystrom 898ac53f4f fix: prevent stack overflow on recursive toString for List and Map
Add `String.safeToString_` static method that tracks objects currently being
converted to string per fiber, returning "..." when recursion is detected.
Wrap List.toString and Map.toString with this guard to handle self-referential
and mutually recursive structures without crashing.
2015-05-03 18:13:05 +00:00
Bob Nystrom cd1cc07c6f feat: allow fibers as map keys by adding unique fiber IDs and hash support
Add a unique numeric ID to each fiber allocation, enabling fibers to be used as map keys. This includes updating the hash function for OBJ_FIBER to return the fiber's ID, modifying key validation to accept fibers, updating documentation to describe the new capability, and adjusting all relevant test expectations and error messages.
2015-05-03 18:10:31 +00:00
Bob Nystrom 332f570a1a feat: add Object.same static method for reliable built-in equality
Introduce a new static method `Object.same(obj1, obj2)` that exposes the VM's
built-in equality semantics (`wrenValuesEqual`) directly, bypassing any
user-defined `==` overrides. This required creating a dedicated metaclass for
Object (subclass of Class) to host the static method without polluting every
class with a `same` method. The implementation wires up a new `Object metaclass`
in the core initialization sequence, adjusts the class hierarchy setup order,
and adds comprehensive tests covering value types, identity comparison, and
verification that `Object.same` ignores custom `==` operators.
2015-05-01 14:55:28 +00:00
Bob Nystrom cbfbb3a4cd test: add test for lowercase class name reference inside class body
Add a new test file `lowercase_name_inside_body.wren` that verifies a class can correctly reference its own lowercase name from both static and instance methods. The test ensures that `foo` resolves to the class itself in static context and to the instance method `foo` in instance context, addressing issue #251.
2015-04-25 17:47:55 +00:00
Bob Nystrom b496f02746 feat: add Evan Hahn to AUTHORS file with email contact
Append Evan Hahn's name and email address to the project's AUTHORS file, recognizing their contribution to the repository.
2015-04-25 16:34:57 +00:00
Bob Nystrom 24fabf1301 docs: copy-edit community page for clarity and consistency
- Shorten "wren bird" to "bird" to avoid redundancy
- Change "User groups" to "User group" for singular accuracy
- Rephrase "embedding APIs for Wren" to "Wren bindings for other languages"
- Add call-to-action for pull requests at the end of the page
2015-04-25 15:48:06 +00:00
Bob Nystrom 6a62c9aacc feat: add community page with user groups, third-party libraries, and editor integrations
Add a new community.markdown page to the documentation site that provides
information about Wren's user groups, third-party libraries written in Wren,
embedding API bindings for Rust, and editor integrations for Vim and Emacs.
Also update the site navigation template to include a link to the new
community page.
2015-04-25 15:39:43 +00:00
Bob Nystrom 39cb27c3f8 chore: update reserved words list in syntax documentation to include 'import'
The diff shows the reserved words list in the syntax markdown documentation was updated to include 'import' and reorder the words, moving 'new' to the second line.
2015-04-25 15:39:04 +00:00
Bob Nystrom 21ea9c788c chore: redirect amalgamation output to build/wren.c and add dedicated make target
The Makefile now defines an explicit `amalgamation` target that writes the combined source into `build/wren.c` instead of the default `wren.c` in the project root. The `generate_amalgamation.py` script is updated with whitespace formatting improvements for readability. The `.PHONY` list is extended to include the new `amalgamation` target.
2015-04-25 15:38:45 +00:00
Bob Nystrom 82bf33c6f4 feat: add amalgamation build target and rename libSource variables for consistency
Add a Makefile target to generate a single-file amalgamation of all Wren library sources using a new Python script. Rename the static `libSource` variables in core, io, and meta modules to `coreLibSource`, `ioLibSource`, and `metaLibSource` respectively to avoid name collisions in the amalgamated output. Update the `callFunction` helper to `callFn` and fix the regex pattern in `generate_builtins.py` to match the renamed constant.
2015-04-23 14:27:32 +00:00
Bob Nystrom 2a2b74a2e3 fix: add missing "import" keyword to reserved words list in syntax docs
The "import" keyword was omitted from the reserved words list in the syntax documentation. This commit adds it between "if" and "in" in the alphabetically ordered list, ensuring the documentation accurately reflects all language keywords.
2015-04-22 14:46:13 +00:00
Bob Nystrom 0bab23280a docs: rename sequence list method to toList and fix typo in wren.h comment 2015-04-22 14:45:39 +00:00
Bob Nystrom 2d2f083072 docs: clarify fiber call/resume semantics, fn arity error, and list insert negative index behavior 2015-04-22 14:45:20 +00:00
Bob Nystrom 6c66ce0e04 docs: add documentation for Fiber.call, Fn.call, and List.insert methods 2015-04-22 14:22:42 +00:00
Bob Nystrom daea0a8394 fix: correct typo in wren.h comment from "orde" to "order" 2015-04-22 14:21:13 +00:00
Bob Nystrom 6eefc06865 docs: replace deprecated .list with .toList in sequence documentation and move method definition 2015-04-22 14:19:00 +00:00
Bob Nystrom 706fa35049 chore: add Patricio Mac Adden to AUTHORS file for project contributions 2015-04-06 13:53:59 +00:00
Bob Nystrom 4b3b967674 chore: remove double space in finishParameterList and rephrase static method comment 2015-04-06 13:53:53 +00:00
Bob Nystrom abc7a9f692 docs: add Patricio Mac Adden to AUTHORS file
Add Patricio Mac Adden <patriciomacadden@gmail.com> to the list of project
contributors in the AUTHORS file, placed after Thorbjørn Lindeijer entry.
2015-04-06 13:45:11 +00:00
Bob Nystrom 10a6a1d23f fix: restore parent compiler before freeing on compile error
When a compile error occurs, the compiler's code is freed but the parent compiler
was not restored as the active compiler. This could cause the garbage collector
to operate on a dangling compiler pointer if a collection happens after the error.
The fix calls wrenSetCompiler to restore the parent compiler before freeing,
ensuring the GC always sees a valid compiler state.
2015-04-04 06:12:14 +00:00
Bob Nystrom d92a8f1c93 fix: replace foreign Meta.eval with primitive and suppress compile errors in wrenCompile 2015-04-04 04:22:58 +00:00
Bob Nystrom 103b9a133b fix: correct broken link to wren.h in embedding-api documentation
The link previously pointed to the old path `include/wren.h` which no longer exists. Updated the URL to the correct location at `src/include/wren.h` in the repository.
2015-04-04 01:51:21 +00:00
Bob Nystrom 734a415999 fix: cast subtraction result to int before abs to suppress clang -Wabsolute-value warning 2015-04-04 01:38:10 +00:00
Bob Nystrom 446e8b2ca9 feat: rename Sequence.list method to toList and update all call sites
The `.list` method on Sequence was renamed to `.toList` to better reflect its
purpose of converting a sequence into a List object. This change updates the
method definition in `builtin/core.wren` and `src/vm/wren_core.c`, along with
all test files that called `.list` on sequences, maps, ranges, and custom
sequence implementations. The test file `test/core/sequence/list.wren` was also
renamed to `test/core/sequence/to_list.wren` to match the new method name.
2015-04-03 18:22:34 +00:00
Bob Nystrom b6e2229b58 feat: move primitive class definitions from C into core.wren library source
Move the definitions of Bool, Fiber, Fn, Null, and Num classes from hardcoded C code in wren_core.c into the core.wren library source, allowing them to be parsed and created during library initialization. Simplify defineClass to always use wrenNewSingleClass, remove redundant root pushing in wrenNewClass, and adjust the class creation in the interpreter to use a Value instead of ObjClass*.
2015-04-03 15:00:55 +00:00
Bob Nystrom 17c6f277b2 refactor: merge patriciomacadden's refactoring branch into mainline
Consolidate the refactoring branch changes from patriciomacadden's fork into the main repository, incorporating the updated class definition logic in wren_core.c that replaces the separate defineSingleClass function with a unified defineClass function capable of handling both raw and subclassed class creation.
2015-04-03 14:19:17 +00:00
Bob Nystrom 7884d89165 docs: rename MapSequence and WhereSequence fields and parameters for clarity, expand map(_) and where(_) docs with lazy semantics and examples 2015-04-01 14:31:15 +00:00
Bob Nystrom 85a889e49f feat: replace eager map/where with lazy MapSequence and WhereSequence classes
Refactor Sequence.map and Sequence.where to return lazy MapSequence and WhereSequence wrappers instead of eagerly building a List. Add new MapSequence and WhereSequence classes that delegate iteration and apply the transformation or predicate on-the-fly. Update documentation to reflect lazy semantics and the need to call .list to materialize results. Adjust all existing tests to call .list on map/where results. Add new tests in test/core/sequence/ verifying lazy behavior with infinite Fibonacci iterators.
2015-04-01 14:22:02 +00:00
Bob Nystrom 7d7be7361e feat: add Sequence.each method to iterate over elements with a function
Add a new `each` method to the Sequence class in the Wren programming language,
allowing iteration over sequence elements by passing each element to a provided
function. This replaces the previous pattern of using `map` with `Fiber.yield`
in examples, providing a more direct and idiomatic way to perform side effects
per element. The implementation includes a core library method in `core.wren`,
a C source string in `wren_core.c`, documentation in the Sequence markdown file,
and three test cases covering normal iteration, empty sequences, and non-function
argument error handling.
2015-04-01 14:10:21 +00:00
Bob Nystrom 0cdbe8bc5a fix: prevent local variables from being in scope during their own initializer 2015-04-01 14:05:40 +00:00
Bob Nystrom 07de6fca9e fix: remove extraneous space inside isspace cast in num_fromString 2015-04-01 13:43:44 +00:00
Bob Nystrom 79db06c6a5 fix: cast char to unsigned char in isspace call to fix char-subscripts warning 2015-04-01 13:42:38 +00:00
Bob Nystrom a018470b47 fix: rename wrenDebugPrintCode to wrenDumpCode in endCompiler debug dump
The debug dump macro in endCompiler was calling the old function name
wrenDebugPrintCode, which has been renamed to wrenDumpCode. This change
updates the call site to match the new function name, fixing a potential
compilation error when WREN_DEBUG_DUMP_COMPILED_CODE is enabled.
2015-03-30 14:39:37 +00:00
Bob Nystrom 26a466b8a1 fix: flush stdout after each benchmark trial dot in run_benchmark_language 2015-03-30 14:39:21 +00:00
Bob Nystrom 133ed97dcf fix: correct debug function call from wrenDebugPrintCode to wrenDumpCode in endCompiler
The WREN_DEBUG_DUMP_COMPILED_CODE block in endCompiler() was calling the
nonexistent function wrenDebugPrintCode instead of the actual function
wrenDumpCode, causing a compilation error when debug dumping was enabled.
2015-03-29 01:08:51 +00:00
Bob Nystrom abe7a8d4b6 chore: remove outdated comment about instruction order matching Code enum in wren_vm.h 2015-03-28 17:19:38 +00:00