コード例 #1
0
        public object VisitSetExpr(Expr.Set expr)
        {
            switch (Evaluate(expr.obj))
            {
            case LoxInstance objectInstance:
                object value = Evaluate(expr.value);
                objectInstance.Set(expr.name, value);
                return(value);
            }

            throw new RuntimeError(expr.name, "Only instances have fields");
        }
コード例 #2
0
 public string VisitSetExpr(Expr.Set expr)
 {
     return("Printing set expression not implemeneted");
 }
コード例 #3
0
 public MyVoid VisitSetExpr(Expr.Set expr)
 {
     resolve(expr.value);
     resolve(expr.obj);
     return(null);
 }