func (r *Resolver) resolveLocal(name token.Token, expr ast.Expr) {
	if r.Locals == nil {
		r.Locals = make(map[ast.Expr]int)
	}
	for i := len(r.scopes) - 1; i >= 0; i-- {
		if _, ok := r.scopes[i][name.StringValue]; ok {
			r.scopes[i][name.StringValue].tkns = append(r.scopes[i][name.StringValue].tkns, name)
			// start from inner scope, work way outwards, if found variable
			// in current scope, pass 0, else 1, 2, 3...
			// This number is the number of "jumps" upwards
			distance := len(r.scopes) - i - 1
			r.Locals[expr] = distance
			return
		}
	}
}
// resolveLocal checks from the innermost scope outwards for the given name / expression
// If it resolved, add the name's expression to the Locals map, where the expression
// points to the exact env to lookup for the value
resolveLocal checks from the innermost scope outwards for the given name / expression
If it resolved, add the name's expression to the Locals map, where the expression
points to the exact env to lookup for the value
// resolveLocal checks from the innermost scope outwards for the given name / expression // If it resolved add the name ' s expression to the Locals map where the expression // points to the exact env to lookup for the value
func (r *Resolver) resolveLocal(name token.Token, expr ast.Expr) {
	if r.Locals == nil {
		r.Locals = make(map[ast.Expr]int)
	}
	for i := len(r.scopes) - 1; i >= 0; i-- {
		if _, ok := r.scopes[i][name.StringValue]; ok {
			r.scopes[i][name.StringValue].tkns = append(r.scopes[i][name.StringValue].tkns, name)
			distance := len(r.scopes) - i - 1
			r.Locals[expr] = distance
			return
		}
	}
}
func ( r * Resolver ) resolveLocal ( name token . Token , expr ast . Expr ) { if r . Locals == nil { r . Locals = make ( map [ ast . Expr ] int ) } for i := len ( r . scopes ) - 1 ; i >= 0 ; i -- { if _ , ok := r . scopes [ i ] [ name . StringValue ] ; ok { r . scopes [ i ] [ name . StringValue ] . tkns = append ( r . scopes [ i ] [ name . StringValue ] . tkns , name ) distance := len ( r . scopes ) - i - 1 r . Locals [ expr ] = distance return } } }
resolveLocal checks from the innermost scope outwards for the given name / expression
If it resolved, add the name's expression to the Locals map, where the expression
points to the exact env to lookup for the value
resolveLocal checks from the innermost scope outwards for the given name / expression If it resolved add the name ' s expression to the Locals map where the expression points to the exact env to lookup for the value
// start from inner scope, work way outwards, if found variable // in current scope, pass 0, else 1, 2, 3... // This number is the number of "jumps" upwards