Example #1
0
        public static FObject NewString(string str)
        {
            var o = new FObject {
                Type = FObjectType.String, PTR = VirtualMachine.Heap.Add(str)
            };

            return(o);
        }
Example #2
0
        public static FObject NewArray(FArray array)
        {
            var o = new FObject {
                Type = FObjectType.Array, PTR = VirtualMachine.Heap.Add(array)
            };

            ;
            return(o);
        }
Example #3
0
        /// <summary>
        /// Make the FObject negative
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        public static FObject operator -(FObject r)
        {
            switch (r.Type)
            {
            case FObjectType.Float:
                return(FObject.NewF64(-r.F64));

            case FObjectType.Int:
                return(FObject.NewI64(-r.I64));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #4
0
        /// <summary>
        /// Negate the FObject
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        public static FObject operator !(FObject r)
        {
            switch (r.Type)
            {
            case FObjectType.Bool:
                return(FObject.NewBool(!r.BOOL));

            case FObjectType.Nil:
                return(FObject.NewBool(true));

            case FObjectType.Float:
            case FObjectType.Int:
            case FObjectType.Array:
            case FObjectType.String:
                return(FObject.NewBool(!r.True()));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }