Skip to content

Tags: marcobambini/gravity

Tags

0.9.7

Toggle 0.9.7's commit message
Bump version to 0.9.7 — bug fixes for float precision, optional modul…

…es, and build system

0.9.6

Toggle 0.9.6's commit message
Mark 0.9.6 as released in CHANGELOG

v0.9.5

Toggle v0.9.5's commit message
Bump version to 0.9.5 — extensive bug fixes, memory safety improvemen…

…ts, and documentation

## Compiler

- Lexer: fix off-by-one in PEEK_NEXT/PEEK_NEXT2 boundary checks
- Parser: fix memory leaks in parse_file_expression, parse_variable_declaration,
  and string interpolation handling; fix undersized buffer for escaped strings
- Semacheck2: fix wrong constant in upvalue limit error message (MAX_LOCALS → MAX_UPVALUES)
- Codegen: fix wrong variable name in for-loop register allocation (temp2 → temp3);
  replace multiple early-return paths in visit_postfix_expr with goto cleanup to
  prevent leaking self_list/args arrays; fix register clobbering in
  LOCATION_CLASS_IVAR_OUTER assignment; remove unnecessary NOP for empty statements;
  add VISIT_MOVE_OPT macro to consolidate pragma patterns
- Optimizer: fix constant folding checking wrong register (inst2->p2 → inst2->p1);
  fix NEG optimization writing to wrong destination register (inst->p2 → inst->p1);
  fix OPCODE_SET_FOUR8bit macro missing opcode field
- IR code: convert register allocation from bool[256] array to compact bitmask
  (32 bytes), improving cache efficiency; add bounds checks on empty label stacks;
  add assertion after inst_new allocation

## Runtime / VM

- Fix boolean fast-path comparison incorrectly applied to ordered comparisons
  (LT, GT, LEQ, GEQ) — now restricted to EQ/NEQ only
- Fix crash in gravity_vm_setslot/gravity_vm_getslot when no frames exist
- Fix OPCODE_GET_FOUR8bit macro inconsistency with encoder
- Fix list_iterator_next out-of-bounds read (add bounds check)
- Fix list_storeat duplicate marray_set after resize
- Fix range_contains not handling reversed ranges correctly
- Fix function_exec default-arg filling using wrong index formula
- Fix int_random truncation from gravity_int_t to int
- Fix string_count broken partial-match logic (rewrite using string_strnstr)
- Fix string_upper/string_lower off-by-one (iterated one byte past end)
- Fix string_loadat UTF-8 corruption when reversing multi-byte sequences
- Fix string_loop iterating byte-by-byte instead of by UTF-8 character
- Fix string_iterator/string_iterator_next missing bounds checks
- Fix fiber_abort wrong nargs check (args[0] is self, not the message)
- Fix system_input blindly stripping last char instead of checking for newline
- Fix convert_map2string/convert_list2string losing original pointer on realloc failure
- Fix gravity_class_grow discarding existing ivar values when growing
- Add overflow guard to gravity_function_cpool_add (uint16_t limit)

## Optional Modules

- Math: fix atan2 → atan2f for float builds; use POW macro consistently in
  math_xrt and math_round; fix division-by-zero in math_logx when base=1;
  fix integer overflow in math_random when range endpoint is GRAVITY_INT_MAX;
  fix pointer arithmetic bugs in math_round string truncation
- File: fix memory leak in file_buildpath (result string not freed); fix leak
  in scan_directory recursive path; fix wrong nargs check in file_open; fix
  leaked FILE* when instance creation fails; fix crash on negative read size;
  fix swapped fread/fwrite arguments (size vs count); fix integer overflow
  in read buffer resize; fix typo "enought" → "enough"
- JSON: rewrite string escaping in JSON.stringify to properly escape backslashes,
  quotes, control characters, and handle large strings
- ENV: add Windows compatibility for environ access; simplify key-length loop

## Utilities

- Debug: add buffer overflow protection in DUMP_VM macros; add bounds check in
  opcode_name; fix memory leak in gravity_disassemble
- JSON serializer: fix escape buffer too small (len*2 → len*6+1); add control
  character escaping (\uXXXX); add overflow check
- Utils: fix uninitialized fd in file_read; fix swapped PathCombineA arguments on
  Windows; fix file_name_frompath returning NULL when no separator found; add NULL
  check in string_dup; fix signed arithmetic and missing digit validation in
  number_from_bin

## Shared / Core Data Structures

- gravity_array.h: fix marray_push updating capacity before confirming realloc
  succeeded; add bounds check before write; fix marray_resize/marray_resize0 to
  check realloc result
- gravity_hash.c: fix gravity_hash_memsize counting buckets as nodes; improve
  float hashing precision (%f → %.17g)

## CLI

- Fix memory leaks in unittest_scan (full_path not freed on skip/recurse)
- Fix inline execution buffer leak

## Documentation

- Add comprehensive ARCHITECTURE.md covering the full compilation pipeline, VM
  internals, value system, garbage collector, instruction set, and embedding API
- Add CLAUDE.md with project conventions for Claude Code
- Update README.md: add Building, Usage, and Project Structure sections; update
  line counts to reflect current codebase size; enhance Features list; add links
  to ARCHITECTURE.md

## Tests

- Add 30 new unit tests covering all major bug fixes: bool comparison, string
  operations (count, upper/lower, UTF-8 iteration/reversal), math functions
  (round, logx, xrt, random), file I/O, JSON escaping, range operations,
  list bounds, fiber abort, optimizer constant folding, and more

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

0.9.0

Toggle 0.9.0's commit message
Several leaks and bugs fixed (added new unit test)

0.8.5

Toggle 0.8.5's commit message
Fixed a setter issue that affects some unit tests too

0.8.4

Toggle 0.8.4's commit message
Fixed #379

0.8.3

Toggle 0.8.3's commit message
Fixed an issue due to the introduction of lazy loading a superclass f…

…rom a class.

0.8.2

Toggle 0.8.2's commit message
Added a way to lazy loading extern superclass at runtime

0.8.1

Toggle 0.8.1's commit message
Minor typo fixed

0.8.0

Toggle 0.8.0's commit message
Improved error handling and detection