예제 #1
0
        public static bool NextDouble(WamMachine machine, WamReferenceTarget[] arguments)
        {
            Debug.Assert(arguments.Length == 1);

            var operand = arguments[0];
            var value   = WamValueDouble.Create(s_random.NextDouble());

            return(machine.Unify(operand, value));
        }
예제 #2
0
        /// <remarks>
        /// See also CodeValue.Create.
        /// </remarks>
        public static WamValue Create(CodeValue value)
        {
            if (value == null)
            {
                return(WamValueObject.Create(null));
            }

            if (value is CodeValueBoolean)
            {
                return(WamValueBoolean.Create(((CodeValueBoolean)value).Value));
            }
            if (value is CodeValueDateTime)
            {
                return(WamValueDateTime.Create(((CodeValueDateTime)value).Value));
            }
            if (value is CodeValueDouble)
            {
                return(WamValueDouble.Create(((CodeValueDouble)value).Value));
            }
            if (value is CodeValueException)
            {
                return(WamValueException.Create(((CodeValueException)value).Value));
            }
            if (value is CodeValueInteger)
            {
                return(WamValueInteger.Create(((CodeValueInteger)value).Value));
            }
            if (value is CodeValueString)
            {
                return(WamValueString.Create(((CodeValueString)value).Value));
            }
            if (value is CodeValueType)
            {
                return(WamValueType.Create(((CodeValueType)value).Value));
            }

            return(WamValueObject.Create(value.Object));
        }