content: package com.annimon.ownlang.parser.ast;
  
  import com.annimon.ownlang.lib.Function;
  import com.annimon.ownlang.lib.FunctionValue;
  import com.annimon.ownlang.lib.NumberValue;
  import com.annimon.ownlang.lib.StringValue;
  import com.annimon.ownlang.lib.Types;
  import com.annimon.ownlang.lib.Value;
  
  /**
   *
   * @author aNNiMON
   */
  public final class ValueExpression extends InterruptableNode {
      
      public final Value value;
      
      public ValueExpression(Number value) {
          this.value = NumberValue.of(value);
      }
      
      public ValueExpression(String value) {
          this.value = new StringValue(value);
      }
      
      public ValueExpression(Function value) {
          this.value = new FunctionValue(value);
      }
      
      public ValueExpression(Value value) {
          this.value = value;
      }
  
      @Override
      public Value eval() {
          super.interruptionCheck();
          return value;
      }
      
      @Override
      public void accept(Visitor visitor) {
          visitor.visit(this);
      }
  
      @Override
      public <R, T> R accept(ResultVisitor<R, T> visitor, T t) {
          return visitor.visit(this, t);
      }
  
      @Override
      public String toString() {
          if (value.type() == Types.STRING) {
              return "\"" + value.asString() + "\"";
          }
          return value.toString();
      }
  }
  