public object VisitAssignExpression(Expression.Assign expression)
        {
            object value = Evaluate(expression.value);

            bool distance_exists = locals.TryGetValue(expression, out int distance);

            if (distance_exists)
            {
                environment.AssignAt(distance, expression.name, value);
            }
            else
            {
                globals.Assign(expression.name, value);
            }

            return(value);
        }
Example #2
0
        public object VisitAssignExpr(Expression.Assign expr)
        {
            object value = Evaluate(expr);

            /* Statements and State visit-assign < Resolving and Binding resolved-assign
             *  environment.assign(expr.name, value);
             */
            //> Resolving and Binding resolved-assign

            locals.TryGetValueEx(expr, out int?distance);
            if (distance != null)
            {
                environment.AssignAt(distance.Value, expr.name, value);
            }
            else
            {
                globals.Assign(expr.name, value);
            }

            //< Resolving and Binding resolved-assign
            return(value);
        }
Example #3
0
 public string VisitAssignExpression(Expression.Assign expression)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public object VisitAssignExpression(Expression.Assign expression)
 {
     Resolve(expression.value);
     ResolveLocal(expression, expression.name);
     return(null);
 }
Example #5
0
 public object VisitAssignExpr(Expression.Assign expr)
 {
     throw new NotImplementedException("Resolver assign is not implemented");
 }