From 673d20a63deb3777edc056ef027b6af0742d6470 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Wed, 11 Dec 2024 10:28:26 -0300 Subject: [PATCH] better --- docs/src/workshop_p6.md | 3 +++ docs/src/workshop_p8.md | 2 ++ 2 files changed, 5 insertions(+) diff --git a/docs/src/workshop_p6.md b/docs/src/workshop_p6.md index 9688be8..dc352b1 100644 --- a/docs/src/workshop_p6.md +++ b/docs/src/workshop_p6.md @@ -5,6 +5,9 @@ With this dialect you don't need to add extra blocks, since the control flow wil The only limitation is that we can't do early returns this way, but for this simple language it won't matter. +> You will need to clone the `locals` HashMap inside the created regions to avoid lifetime issues. But since any variable created +inside the if or else block only live for that scope, it works good. + ```rust // src/codegen/ifelse_stmt.rs pub fn compile_if<'ctx, 'parent>( diff --git a/docs/src/workshop_p8.md b/docs/src/workshop_p8.md index 561b8d7..ab6e1f7 100644 --- a/docs/src/workshop_p8.md +++ b/docs/src/workshop_p8.md @@ -4,6 +4,8 @@ Now to wrap up the function itself needs to be created, using the `func` dialect You also need to allocate space for the arguments, and store the value there. You can get the value from the block arguments. +Remember that in this language functions always return a i64 value. + Some useful types you will need: `Type`, `IntegerAttribute`, `IntegerType`, `FunctionType`, `TypeAttribute`, `StringAttribute`. ```rust