Skip to content

Decompose vera/wasm/calls.py (8,337 lines) into subsystem mixins #418

@aallan

Description

@aallan

Background

vera/wasm/calls.py has grown to 8,337 lines with 118 methods in a single CallsMixin class. It covers every built-in function translation to WebAssembly — strings, arrays, parsing, encoding, math, containers, markup, and more — all in one file. This is the same problem that wasm.py had before it was decomposed into the vera/wasm/ subpackage in #100.

Proposed split

Each subsystem becomes its own mixin file under vera/wasm/, following the existing pattern (inference.py, data.py, etc.):

New file Content Approx. lines
vera/wasm/strings.py concat, length, repeat, strip, starts/ends_with, contains, upper/lower, index_of, replace, split, join, char_code, from_char_code ~1,500
vera/wasm/arrays.py array_length, array_append, array_range, array_concat, array_slice, array element inference helpers ~2,200
vera/wasm/containers.py map_new, map_insert, map_get, map_contains, map_remove, map_keys, map_values, set_new, set_insert, set_contains, set_remove, set_to_array ~1,200
vera/wasm/encoding.py base64_encode, base64_decode, url_encode, url_decode, url_parse, url_join ~1,400
vera/wasm/parsing.py parse_int, parse_nat, parse_bool, parse_float64 ~900
vera/wasm/conversions.py to_string, bool_to_string, byte_to_string, float_to_string, show, nat_to_int, int_to_nat, byte_to_int, int_to_byte, to_float, float_to_int ~600
vera/wasm/math.py abs, min, max, floor, ceil, round, sqrt, pow, is_nan, is_infinite, nan, infinity ~300
vera/wasm/markup.py json_parse, json_stringify, html_escape, md_to_html, regex_match, regex_replace ~400
vera/wasm/decimal.py decimal_new, decimal_add, decimal_sub, decimal_mul, decimal_div, decimal_to_string, decimal mapping utilities ~350

calls.py becomes a thin orchestrator that:

  • inherits all the new mixins
  • keeps the top-level _translate_call() dispatcher
  • keeps any shared WASM helper utilities that multiple mixins need

Acceptance criteria

  • All 3,157 tests pass after the split
  • mypy vera/ clean
  • No change to public API or generated WAT output
  • Each new file is under 2,500 lines

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode refactoring and structural improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions