Skip to content

v0.1.37

Choose a tag to compare

@gmpassos gmpassos released this 26 Jun 02:44
· 340 commits to master since this release
45fcf52

0.1.37

Language: C#

  • New self-contained C# language support (csharp, also accepting cs and
    c#) able to parse, run and translate, at the same level of compatibility as
    Dart and Java: classes, fields (incl. initial values), constructors, methods
    and modifiers (public/private/static/readonly/…), using directives,
    variable declarations (var and typed), the full expression set
    (arithmetic/comparison/logical operators, ternary ?:, ++/--, negation),
    string concatenation, if/else if/else, for, foreach (T x in coll),
    while, try/catch/finally, throw, lambdas (=>), and List<T> /
    Dictionary<K,V> collection initializers.
  • C# types map to the shared AST (int/long/short → int, double/float/
    decimal → double, bool, string, object, …) so code translates
    cleanly to/from every other supported language.
  • Registered in ApolloVM (getParser, createRunner, createCodeGenerator)
    and exported from apollovm.dart; .cs files resolve to the csharp
    language.
  • New golden tests under test/tests_definitions/csharp_*.test.xml.

Lambda / anonymous-function input parsing (Java, Kotlin, Lua)

  • Java: parse lambdas as expressions — (a, b) -> expr, (int a) -> { ... },
    x -> x * 2, () -> 0 (typed or untyped parameters).
  • Kotlin: parse lambdas { x -> x * 2 }, { x: Int, y: Int -> x + y },
    { 42 }; the last expression is the implicit return value.
  • Lua: parse anonymous functions function(x) ... end.
  • Closures now round-trip (parse → execute → regenerate) in these languages, not
    just generate.

Wasm: host imports no longer corrupt module-function call indices

  • A module-function call index is importCount + position, but host imports
    (env.print, env.int_to_str, …) are registered lazily while bodies are
    generated. A call emitted before an import was registered (e.g. calling a
    function and then print-ing, including across await points) got a stale
    index and produced invalid Wasm (type mismatch). The import-discovery pass
    that freezes importCount before the real pass now runs for all modules (it
    only touches idempotent state, so import-free modules stay byte-identical).
  • Fixes async/await functions that call other functions and print between
    awaits, which now run identically on the interpreter and Wasm.

Wasm: closures capture variables by reference

  • Captured variables are now "boxed" into shared heap cells: the closure
    environment holds pointers to the cells (not copied values), so a variable
    mutated after a closure is created — or mutated by the closure — is visible
    on both sides, matching the interpreter. Each closure instance still gets its
    own cell (e.g. two counters created from the same factory are independent).