From 7acc1632eccd91e64ce45051d53f82a281abb071 Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Sun, 17 Nov 2024 13:52:12 +0100 Subject: [PATCH] Simplify code --- src/server/analysis.odin | 65 ++++------------------------------------ 1 file changed, 6 insertions(+), 59 deletions(-) diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 189bf95..ec5dee5 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -3128,67 +3128,14 @@ get_locals_for_range_stmt :: proc( if ok { #partial switch v in symbol.value { case SymbolProcedureValue: - //This can only be custom iterators - if len(stmt.vals) >= 1 { - if ident, ok := unwrap_ident(stmt.vals[0]); ok { - expr: ^ast.Expr - - if v.return_types[0].type != nil { - expr = v.return_types[0].type - } else if v.return_types[0].default_value != nil { - expr = v.return_types[0].default_value - } - - store_local( - ast_context, - ident, - expr, - ident.pos.offset, - ident.name, - ast_context.local_id, - ast_context.non_mutable_only, - false, - true, - symbol.pkg, - false, - ) - } - } - - if len(stmt.vals) >= 2 { - if ident, ok := unwrap_ident(stmt.vals[1]); ok { - expr: ^ast.Expr - - if v.return_types[1].type != nil { - expr = v.return_types[1].type - } else if v.return_types[1].default_value != nil { - expr = v.return_types[1].default_value - } - - store_local( - ast_context, - ident, - expr, - ident.pos.offset, - ident.name, - ast_context.local_id, - ast_context.non_mutable_only, - false, - true, - symbol.pkg, - false, - ) - } - } - - if len(stmt.vals) >= 3 { - if ident, ok := unwrap_ident(stmt.vals[2]); ok { + for val, i in stmt.vals { + if ident, ok := unwrap_ident(val); ok { expr: ^ast.Expr - if v.return_types[2].type != nil { - expr = v.return_types[2].type - } else if v.return_types[2].default_value != nil { - expr = v.return_types[2].default_value + if v.return_types[i].type != nil { + expr = v.return_types[i].type + } else if v.return_types[i].default_value != nil { + expr = v.return_types[i].default_value } store_local(