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); }
public string VisitSetExpr(Expr.Set expr) { return(Parenthesize2("=", expr.Object, expr.Name.Lexeme, expr.Value)); }
public object VisitSetExpr(Expr.Set expr) { Resolve(expr.Value); Resolve(expr.Object); return(null); }