Пример #1
0
        public object visitAssignmentExpr(Expr.Assignment expr)
        {
            object value = Evaluate(expr.value);

            if (locals.TryGetValue(expr, out var exprLocation))
            {
                environment.AssignAt(exprLocation.depth, exprLocation.index, value);
            }
            else
            {
                globals.Assign(globalIndices[expr], value);
            }
            return(value);
        }
Пример #2
0
 public object visitAssignmentExpr(Expr.Assignment expr)
 {
     Resolve(expr.value);
     ResolveLocal(expr, expr.name.lexeme, AccessType.LHS);
     return(null);
 }
Пример #3
0
 public string visitAssignmentExpr(Expr.Assignment expr)
 {
     return(parenthesize(expr.name.lexeme + "=", expr.value));
 }