TritonVM / tasm-lang

Writing tasm with Rust syntax
15 stars 2 forks source link

Add support for structs living on stack #44

Closed Sword-Smith closed 8 months ago

Sword-Smith commented 1 year ago

We currently only support structs with named fields living in memory (RAM), whereas tuple structs can live both in memory (via the Box) and on the stack. We should add the option of having structs with named fields on the stack such that this code compiles

struct FourVector {
    t: u64,
    x: u64,
    y: u64,
    z: u64,
}
let m: u64 = 1;
let c: u64 = 1;
let a: FourVector = FourVector {
    t: m * c * c,
    x: 0,
    y: 0,
    z: 0,
};
let f: u64 = a.t;

We already have support for methods and associated functions, so no change should be needed there.

Sword-Smith commented 8 months ago

Closed by 132229a6ef548a91d76184f939937dc7d50d6440