Skip to content

Transpiler: HandleLdelemU1 requires array in tracked local variable #273

@jonathanpeppers

Description

@jonathanpeppers

Problem

The transpiler's HandleLdelemU1ComplexIndex throws when the array being accessed is not stored in a tracked local variable. The error occurs during transpilation of the crypto sample after closure inlining.

TranspileException: Array element access requires the array to be stored in a local variable.
   at IL2NESWriter.HandleLdelemU1ComplexIndex() in IL2NESWriter.ArrayHandling.cs:line 530
   at IL2NESWriter.HandleLdelemU1() in IL2NESWriter.ArrayHandling.cs:line 368

Expected behavior

The transpiler should handle ldelem.u1 when the array reference comes from patterns other than a simple ldloc, such as when the compiler reuses a register or optimizes array access in inlined code.

Context

  • Blocking: crypto sample (PR Port 8bitworkshop crypto.c dungeon crawler sample #211)
  • This error surfaced after inlining all local functions to eliminate closure captures
  • The inlined code produces IL patterns where array references may not follow the expected ldloc+ldloc+ldelem sequence

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions