Beispiel #1
0
        public object VisitSetExpr(Expr.Set expr)
        {
            var @object = Evaluate(expr.Object);

            if (!(@object is LoxInstance instance))
            {
                throw new RuntimeError(expr.Name, "Only instances have fields.");
            }

            var value = Evaluate(expr.Value);

            instance.Set(expr.Name, value);
            return(value);
        }
Beispiel #2
0
 public string VisitSetExpr(Expr.Set expr)
 {
     return(Parenthesize2("=", expr.Object, expr.Name.Lexeme, expr.Value));
 }
Beispiel #3
0
 public object VisitSetExpr(Expr.Set expr)
 {
     Resolve(expr.Value);
     Resolve(expr.Object);
     return(null);
 }