1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v2: handle var decl & assign stmt together 1st step combining

This commit is contained in:
Joe Conigliaro
2020-02-28 23:29:04 +11:00
parent 8c43644301
commit c4b9ef388f
7 changed files with 124 additions and 99 deletions

View File

@ -63,6 +63,14 @@ pub fn (s mut Scope) override_var(var VarDecl) {
s.vars[var.name] = var
}
pub fn (s &Scope) outermost() &Scope {
mut sc := s
for !isnil(sc.parent) {
sc = sc.parent
}
return sc
}
// returns the innermost scope containing pos
pub fn (s &Scope) innermost(pos int) ?&Scope {
if s.contains(pos) {