Beispiel #1
0
        /// <summary>
        /// Construct a new MondValue. Should only be used for Object or Array.
        /// </summary>
        private MondValue(MondValueType type)
        {
            _type        = type;
            _numberValue = 0;

            switch (type)
            {
            case MondValueType.Undefined:
            case MondValueType.Null:
            case MondValueType.True:
            case MondValueType.False:
                ObjectValue   = null;
                ArrayValue    = null;
                _stringValue  = null;
                FunctionValue = null;
                break;

            case MondValueType.Object:
                ArrayValue    = null;
                _stringValue  = null;
                FunctionValue = null;
                ObjectValue   = new VirtualMachine.Object();
                break;

            case MondValueType.Array:
                ObjectValue   = null;
                _stringValue  = null;
                FunctionValue = null;
                ArrayValue    = new List <MondValue>();
                break;

            default:
                throw new MondException("Incorrect MondValue constructor use");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Construct a new Number MondValue with the specified value.
        /// </summary>
        private MondValue(double value)
        {
            _type        = MondValueType.Number;
            _numberValue = value;

            ObjectValue   = null;
            ArrayValue    = null;
            _stringValue  = null;
            FunctionValue = null;
        }
Beispiel #3
0
        internal MondValue(Closure closure)
        {
            _type        = MondValueType.Function;
            _numberValue = 0;

            ObjectValue   = null;
            ArrayValue    = null;
            _stringValue  = null;
            FunctionValue = closure;
        }
Beispiel #4
0
        /// <summary>
        /// Construct a new Function MondValue with the specified value. Instance functions will
        /// bind themselves to their parent object when being retrieved.
        /// </summary>
        private MondValue(MondInstanceFunction function)
        {
            if (ReferenceEquals(function, null))
            {
                throw new ArgumentNullException(nameof(function));
            }

            _type        = MondValueType.Function;
            _numberValue = 0;

            ObjectValue   = null;
            ArrayValue    = null;
            _stringValue  = null;
            FunctionValue = new Closure(function);
        }
Beispiel #5
0
        /// <summary>
        /// Construct a new String MondValue with the specified value.
        /// </summary>
        private MondValue(string value)
        {
            if (ReferenceEquals(value, null))
            {
                throw new ArgumentNullException(nameof(value));
            }

            _type        = MondValueType.String;
            _numberValue = 0;
            _stringValue = value;

            ObjectValue   = null;
            ArrayValue    = null;
            FunctionValue = null;
            _stringValue  = value;
        }