27 Commits
Author SHA1 Message Date
Gavin Schulz 55e98a3b7c docs: correct fn.call argument count docs and list.insert example output
- Fix fn.call documentation to clarify that extra arguments are discarded
  rather than causing a runtime error
- Correct list.insert example output from "[a, e, c, d]" to "[a, e, b, c, d]"
  to accurately reflect insertion behavior
2015-04-19 20:32:15 +00:00
Gavin Schulz eec9632372 docs: add documentation and usage examples for fiber.call() and fiber.call(value) 2015-04-04 23:50:40 +00:00
Gavin Schulz 97ece178ec docs: add documentation for Fn.call method with example and arity error note 2015-04-04 22:29:10 +00:00
Gavin Schulz aadfa61923 docs: add documentation for list.insert method with examples and error notes 2015-04-04 22:23:16 +00:00
Gavin Schulz ab52c46a28 chore: remove unused stdio, wren_value, and wren_vm includes from wren_meta.h
The wren_meta.h header included <stdio.h>, "wren_value.h", and "wren_vm.h"
which were not required for its declarations. These headers are already
included transitively through "wren.h" and "wren_common.h", making the
explicit includes redundant. Removing them reduces unnecessary
dependencies and potential circular inclusion issues.
2015-03-25 06:30:53 +00:00
Gavin Schulz c8fa7e619f feat: add Meta library with eval function for inline code interpretation 2015-03-22 21:16:53 +00:00
Gavin Schulz 1374797192 feat: fall back to loading module package when module file not found
Extract file path construction into `wrenFilePath` helper and modify `readModule` to first attempt loading the module as a `.wren` file. If that fails, treat the module name as a package directory and try to load `module.wren` from within it. Add test files `module_package/module.wren` and `package_module.wren` to verify the new package resolution behavior.
2015-03-21 23:05:02 +00:00
Gavin Schulz a0e7e1fc67 fix: correct comment about name mangling in new_ function
The comment previously stated that a leading space prevents direct calls,
but the actual mechanism uses angle brackets in the method name "<instantiate>"
to make it inaccessible from user code.
2015-03-09 01:22:17 +00:00
Gavin Schulz 6c36816245 fix: correct spelling of "Unknown" in ASSERT message for argument type validation 2015-03-09 00:44:24 +00:00
Gavin Schulz 3dcffddbd5 feat: add ERANGE error handling for oversized number literals in lexer and Num.fromString
Replace TODO stubs with actual errno checks in readHexNumber, readNumber, and num_fromString to emit a "Number literal is too large." error when strtol/strtod overflow. Add three test files (literal_too_large.wren, hex_too_large.wren, from_string_too_large.wren) verifying compile-time and runtime error behavior for out-of-range numeric inputs.
2015-03-03 08:06:34 +00:00
Gavin Schulz 8278701635 test: add edge-case tests for Num.fromString with whitespace, prefix, and non-string args
Add test cases for Num.fromString covering leading/trailing whitespace (" 12 "),
numeric prefix with trailing non-numeric characters ("1.2prefix"), empty string,
non-numeric prefix ("prefix1.2"), and a runtime error test for non-string argument
(Num.fromString(1)).
2015-02-25 07:44:03 +00:00
Gavin Schulz 87cc5fdbae feat: add Num.fromString static method to parse decimal string literals
Implements a new `fromString` static method on the `Num` class that attempts to parse a string as a decimal number literal using `strtod`. Returns the parsed `Num` value on success, or `null` if the string does not represent a valid number. Includes runtime validation that the argument is a string, and adds test coverage for positive, negative, zero, and decimal inputs as well as non-numeric strings.
2015-02-23 04:06:17 +00:00
Gavin Schulz 4042cd6500 refactor: remove redundant string and range equality natives, delegate to wrenValuesEqual 2015-01-26 07:26:59 +00:00
Gavin Schulz b0b3256335 feat: add == and != operators to Range class with equality tests
Implement equality comparison for Range objects by defining `range_eqeq` and `range_bangeq` native methods that delegate to `wrenValuesEqual`. Register both operators on the Range class in `wrenInitializeCore` and add a comprehensive test suite in `test/range/equality.wren` covering inclusive/exclusive ranges and cross-type inequality checks.
2015-01-26 03:50:54 +00:00
Gavin Schulz 992a2aeb96 feat: add hexadecimal number literal parsing to wren compiler
Remove the TOKEN_HEXADECIMAL token type and isHexDigit helper, replacing them with a readHexDigit function and readHexNumber parser that directly converts hex literals to numeric values during lexing. Add a `number` field to the Parser struct to hold the parsed value, and include a test for invalid hex literal error handling.
2015-01-25 21:02:44 +00:00
Gavin Schulz b2c6dfce8d feat: add hexadecimal literal support to lexer and compiler
Add TOKEN_HEXADECIMAL token type and isHexDigit helper function to lexer.
Modify readNumber to detect 'x' prefix after '0' and lex hex digits.
Implement emitNumericConstant for hex values in compiler.
Add test file test/number/hex_literals.wren verifying basic hex parsing,
arithmetic, type checks, and negative hex literals.
2015-01-25 06:07:23 +00:00
Gavin Schulz 9e20b3935a feat: abstract List's toString into generic join method on Sequence
Add `join` and `join(sep)` methods to the `Sequence` class, allowing any sequence to produce a concatenated string of its elements with an optional separator. Refactor `List.toString` to delegate to `join(", ")` with bracket wrapping, removing the manual iteration logic from List. Include new test files for List, Range, and String join behavior, plus runtime error tests for non-string separators.
2015-01-24 04:45:23 +00:00
Gavin Schulz 2799fa6b58 feat: add range subscripting support for strings with CalculatedRange helper
Extract range validation logic from list_subscript into a reusable calculateRange function that handles inclusive/exclusive bounds, negative indices, and direction stepping. Add CalculatedRange struct to wren_core.h and implement string subscripting via the new helper, including comprehensive test coverage for forward, backward, negative, and half-negative ranges with proper error messages for out-of-bounds and non-integer values.
2015-01-17 07:20:56 +00:00
Gavin Schulz 1cb0e73bf0 docs: add Gavin Schulz to AUTHORS file with email contact 2015-01-16 03:06:24 +00:00
Gavin Schulz 221f89fec0 fix: replace overlooked 'forall' references with 'all' in core-library docs 2015-01-16 03:05:54 +00:00
Gavin Schulz adee8ac482 refactor: rename Sequence method forall to all across core lib, C source, and test files 2015-01-15 07:19:31 +00:00
Gavin Schulz cb1703409c test: add forall test for empty list and non-bool/non-function args
Add test case verifying that `forall` returns true for an empty list regardless of predicate, and add two new test files covering runtime errors when `forall` receives a non-boolean-returning function or a non-function argument. Also refactor the `forall` implementation to use logical negation (`!`) instead of explicit `!= true` comparison.
2015-01-15 06:42:15 +00:00
Gavin Schulz 580ca8cf27 feat: add forall method to Sequence class for testing all elements pass predicate
Implement a `forall` method on the Sequence class that takes a predicate function and returns true only if every element in the sequence satisfies the predicate. The method iterates through all elements, returning false immediately upon encountering any element where the predicate does not return exactly true. Includes core library documentation and a test file verifying behavior with numeric comparisons and non-boolean predicate returns.
2015-01-14 07:47:01 +00:00
Gavin Schulz de5e69aab0 docs: document String class methods and add startsWith, endsWith, indexOf natives 2015-01-10 22:45:14 +00:00
Gavin Schulz a0385b2b4c refactor: replace canonicalSymbol and methodArgumentsString with unified methodNotFound helper in wren_vm.c 2015-01-09 05:30:47 +00:00
Gavin Schulz 9fe43fec45 feat: include method arity in missing method runtime error messages
Add helper functions `canonicalSymbol` and `methodArgumentsString` to extract and format the argument count from symbol names. Update the runtime error message in `runInterpreter` to append the arity (e.g., "with 0 arguments", "with 2 arguments", "with 1 argument") when a class does not implement a method. Add new test cases for missing methods with one, two, and eleven arguments, and update all existing test expectations to include the arity suffix.
2015-01-04 19:42:11 +00:00
Gavin Schulz 7048facaa4 fix: skip wrenInterpret call when REPL input is empty line
Add a strcmp check against "\n" before invoking wrenInterpret in the
runRepl function, preventing an unnecessary interpretation attempt and
potential error handling for blank user input.
2015-01-03 19:25:10 +00:00