From 97e97222ee632aaa4432ec5c4dd82edce6cc841b Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 18 Jul 2019 14:02:22 +0300 Subject: [PATCH] live reload: All of the [live] functions are reloaded now, not just the first one. --- compiler/fn.v | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/compiler/fn.v b/compiler/fn.v index 15c47005e4..9ad6aed655 100644 --- a/compiler/fn.v +++ b/compiler/fn.v @@ -319,11 +319,25 @@ fn (p mut Parser) fn_decl() { if is_sig || p.first_run() || is_live || is_fn_header || skip_main_in_test { // First pass? Skip the body for now [BIG] if !is_sig && !is_fn_header { + mut opened_scopes := 0 + mut closed_scopes := 0 for { + if p.tok == .lcbr { + opened_scopes++ + } + if p.tok == .rcbr { + closed_scopes++ + } p.next() if p.tok.is_decl() && !(p.prev_tok == .dot && p.tok == .key_type) { break } + //fn body ended, and a new fn attribute declaration like [live] is starting? + if closed_scopes > opened_scopes && p.prev_tok == .rcbr { + if p.tok == .lsbr { + break + } + } } } // Live code reloading? Load all fns from .so