| Crates.io | swamp-code-gen |
| lib.rs | swamp-code-gen |
| version | 0.2.27 |
| created_at | 2025-03-29 15:45:22.718736+00 |
| updated_at | 2025-09-22 09:24:20.708229+00 |
| description | generates swamp-vm opcodes |
| homepage | |
| repository | https://github.com/swamp/swamp |
| max_upload_size | |
| id | 1611410 |
| size | 458,028 |
Translates the type-checked, resolved Abstract Semantic Graph (ASG) from swamp-semantic into
executable bytecode (BinaryInstruction from swamp-vm-types) for the Swamp Virtual Machine (VM).
This crate represents the code generation phase of the Swamp compiler pipeline. It takes the high-level, semantically rich representation of the program (where types are known, names are resolved, etc.) and lowers it into a sequence of simple, low-level instructions that the Swamp VM can directly execute.
swamp_vm_types::opcode::OpCode)
for each operation in the semantic tree (e.g., selecting AddI32 for an integer addition).swamp_vm_types::FrameMemoryAddress) for local variables, function arguments, and temporary
intermediate values.if, match,
loops) into sequences of conditional and unconditional jump instructions (Bz, Bnz, Jmp).Call,
Enter, Ret), including setting up arguments and handling return values according to the VM's
calling convention.LdConst,
StringFromConstantSlice) to load them into registers or memory at runtime.This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) Peter Bjorklund. All rights reserved. https://github.com/swamp/swamp