Skip to content

Function calls support#137

Merged
0xGeorgii merged 4 commits intomainfrom
136-function-calls-support
Feb 23, 2026
Merged

Function calls support#137
0xGeorgii merged 4 commits intomainfrom
136-function-calls-support

Conversation

@0xGeorgii
Copy link
Contributor

Closes #136

@0xGeorgii 0xGeorgii self-assigned this Feb 23, 2026
@0xGeorgii 0xGeorgii requested a review from Copilot February 23, 2026 01:59
@0xGeorgii 0xGeorgii added inf2wasm Inference to WASM converting codegen Bytecode emitting labels Feb 23, 2026
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 55.95238% with 74 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
core/wasm-codegen/src/compiler.rs 55.15% 74 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements function call support for the WebAssembly code generator, enabling the compiler to emit WASM call instructions for plain identifier-based function calls. The implementation includes function parameter lowering, forward reference support, and proper handling of void vs. value-returning functions in expression contexts.

Changes:

  • Function parameters are mapped to WASM local indices 0..n, with body locals starting at n
  • Pre-scan builds a function name-to-index map for forward reference resolution
  • Function calls are lowered to WASM call instructions with positional arguments
  • Drop instruction emission is correctly handled based on whether expressions produce values and context

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/wasm-codegen/src/lib.rs Adds pre-scan call to build function name-to-index map before compilation
core/wasm-codegen/src/errors.rs Introduces CodegenError enum for function call lowering errors
core/wasm-codegen/src/compiler.rs Implements function parameter lowering, call instruction emission, and Drop logic refinement
core/wasm-codegen/Cargo.toml Adds thiserror dependency for error types
tests/src/codegen/wasm/validation.rs Adds 18 validation tests covering parameters, calls, Drop logic, and edge cases
tests/src/codegen/wasm/base.rs Adds integration tests with execution validation for parameters and calls
tests/test_data/codegen/wasm/base/fn_params/ Test data for function parameter tests
tests/test_data/codegen/wasm/base/fn_calls/ Test data for function call tests
CHANGELOG.md Documents new functionality and links PR #136

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@0xGeorgii 0xGeorgii merged commit a611230 into main Feb 23, 2026
9 of 10 checks passed
@0xGeorgii 0xGeorgii deleted the 136-function-calls-support branch February 23, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen Bytecode emitting inf2wasm Inference to WASM converting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function calls support

2 participants