Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
0
        internal MondValue(Closure closure)
        {
            _type        = MondValueType.Function;
            _numberValue = 0;

            ObjectValue   = null;
            ArrayValue    = null;
            _stringValue  = null;
            FunctionValue = closure;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }