예제 #1
0
        public object Visit(Expr.Set _set)
        {
            Resolve(_set.value);
            Resolve(_set.target);

            return(null);
        }
예제 #2
0
        public object VisitSetExpr(Expr.Set expr)
        {
            var obj = Evaluate(expr.Obj);

            if (obj is LoxInstance li)
            {
                var value = Evaluate(expr.Value);
                li.Set(expr.Name, value);
                return(value);
            }

            throw new RuntimeError(expr.Name, "Only instances have fields.");
        }
예제 #3
0
        public object VisitSetExpr(Expr.Set expr)
        {
            object obj = Evaluate(expr.obj);

            if (obj is LoxInstance instance)
            {
                object value = Evaluate(expr.value);
                instance[expr.name] = value;
                return(value);
            }

            throw new RuntimeError(expr.name, "Only instances have fields.");
        }
예제 #4
0
        public object visitSetExpr(Expr.Set set)
        {
            Object _object = evaluate(set._object);

            if (!(_object is LoxInstance) || (_object is LoxClass))
            {
                throw new Exceptions.RuntimeError(set.name, "Only instances have fields.");
            }

            Object value = evaluate(set.value);

            ((LoxInstance)_object).set(set.name, value);
            return(value);
        }
예제 #5
0
        object Expr.IVisitor <object> .Visit(Expr.Set _set)
        {
            object target = Evaluate(_set.target);

            if (!(target is LoxInstance))
            {
                throw new RuntimeError(_set.name, "Only instances have fields.");
            }

            object value = Evaluate(_set.value);

            ((LoxInstance)target).Set(_set.name, value);

            return(value);
        }
예제 #6
0
 string Expr.IVisitor <string> .Visit(Expr.Set _set)
 {
     throw new NotImplementedException();
 }
예제 #7
0
 public object visitSetExpr(Expr.Set set)
 {
     resolve(set.value);
     resolve(set._object);
     return(null);
 }
예제 #8
0
 public object VisitSetExpr(Expr.Set expr)
 {
     Resolve(expr.value);
     Resolve(expr.obj);
     return(null);
 }
예제 #9
0
 public string visitSetExpr(Expr.Set set)
 {
     return("(= " + set._object.accept(this) + "." + set.name.lexeme + " " + set.value.accept(this) + ")");
 }
예제 #10
0
 public Void VisitSetExpr(Expr.Set expr)
 {
     Resolve(expr.Value);
     Resolve(expr.Obj);
     return(null);
 }
예제 #11
0
 public string VisitSetExpr(Expr.Set expr)
 {
     return($"({expr.obj.Accept(this)}{expr.name} <- {expr.value.Accept(this)})");
 }