ptr write assignments

This commit is contained in:
2026-06-09 20:24:57 +02:00
parent 7a613e93e8
commit 1b6340e7a6
4 changed files with 30 additions and 20 deletions
+12 -4
View File
@@ -111,11 +111,19 @@ impl GenRust for Expression {
postfix.gen_rust(ctx, cg);
}
}
// Safely integrated to handle the tree structure built by the Pratt Parser
Expression::Binary { lhs, op, rhs } => {
lhs.gen_rust(ctx, cg);
cg.add(op);
rhs.gen_rust(ctx, cg);
if op == "->" {
cg.add("unsafe { std::ptr::write(&mut ");
lhs.gen_rust(ctx, cg);
cg.add(", ");
rhs.gen_rust(ctx, cg);
cg.add(") }");
} else {
lhs.gen_rust(ctx, cg);
cg.add(op);
rhs.gen_rust(ctx, cg);
}
}
Expression::Closure {
+1
View File
@@ -620,6 +620,7 @@ bin_op = {
| "!="
| "&&"
| "||"
| "->"
| "+"
| "-"
| "*"