feat: advanced L-value parsing and robust LLVM codegen for structs, arrays, and inline asm #268
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR significantly enhances Wave's capability to handle complex data structures and low-level operations. By implementing recursive L-value parsing and a more robust LLVM backend, the compiler now supports chained memory access (e.g.,
obj.field[index].subfield), proper array literal initialization, and sophisticated type coercion for inline assembly and function calls.Key Changes
1. Advanced Parser & L-value Logic
parse_lvalue_tailto support recursive field access (.) and indexing ([]). This allows expressions likea.b[i].cto be treated as a single assignable target.parse_structto better handle whitespace, newlines, and improved field type detection.parse_type_from_streamto use a centralized collector for generic types, ensuring consistent handling of types likeptr<T>orptr<ptr<i32>>.is_assignablechecks during assignment parsing to prevent invalid operations on non-L-value expressions.2. LLVM Backend & Codegen Overhaul
generate_address_irinaddress.rs. It now recursively navigates through structs and arrays to calculate precise memory addresses for nested data structures.gen_array_literalto generate IR for array initializers and improvedIndexAccessto handle both pointer-based and value-based indexing seamlessly.gen_asm_stmt_irto support various output types. It now performs automatic bitcasting and coercion between integers, pointers, and floats to match assembly register requirements.nullkeyword as a native constant for null pointers across the backend.3. Tooling
run_tests.pywith specific configurations for new test cases and dependency tracking.