Skip to content

Conversation

jserv
Copy link
Collaborator

@jserv jserv commented Aug 24, 2025

This commit resolves fundamental array issues in shecc and implements complete support for multi-dimensional arrays with proper row-major indexing.

  1. Fix array value storage and retrieval
    • Arrays now correctly store and return values (was always 1)
    • Added spill_var call in register allocator to store base addresses
    • Arrays properly behave as pointers to their first element
  2. Implement full 2D array support with row-major indexing
    • Added array_dim1 and array_dim2 fields to track dimensions
    • Parser now preserves dimension information for multi-dimensional arrays
    • Fixed indexing calculation: matrix[i][j] correctly maps to base + i*cols + j

Summary by Bito

This pull request enhances the shecc compiler with full support for 2D arrays, resolving issues with value storage and retrieval. It implements row-major indexing and updates the parser and register allocator for better management of multi-dimensional arrays. Comprehensive tests have been added to validate the new functionality.

This commit resolves fundamental array issues in shecc and implements
complete support for multi-dimensional arrays with proper row-major
indexing.
1. Fix array value storage and retrieval
   - Arrays now correctly store and return values (was always 1)
   - Added spill_var call in register allocator to store base addresses
   - Arrays properly behave as pointers to their first element
2. Implement full 2D array support with row-major indexing
   - Added array_dim1 and array_dim2 fields to track dimensions
   - Parser now preserves dimension information for multi-dimensional
     arrays
   - Fixed indexing calculation: matrix[i][j] correctly maps to
     base + i*cols + j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant