Skip to content

Add call frames and function-call bytecode semantics #43

@synapticvoid

Description

@synapticvoid

Summary

Add VM call-frame support and compiler lowering for user function declarations/calls, including proper return semantics.

Scope (MVP)

  • VM call model:
    • call frames stack
    • per-frame instruction pointer and base slot
    • argument passing and return value handling
  • Bytecode/compiler support for:
    • function declaration objects
    • call instruction with arity checks
    • return instruction semantics
  • Integrate builtin call path with VM call convention

Out of Scope

  • Closures/upvalues
  • Methods/receiver injection for struct methods
  • Tail-call optimization
  • try/catch propagation through frames (follow-up issue)

Acceptance Criteria

  • User-defined functions compile and execute through VM call frames
  • Nested calls return correct values and preserve caller locals
  • Arity mismatch and invalid-call runtime errors are reported clearly
  • Tests cover declaration, call, nested call, and return behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions