Esempio n. 1
0
        private bool IsEmpty(long slot)
        {
            long tag = Miscellanea.UnsignedLeftShift64(slot, 62);

            Debug.Assert(tag == 0 | tag == 1 | tag == 2);
            return(tag == 2);
        }
Esempio n. 2
0
        private long ReindexedSlot(long slot, int next)
        {
            int tag = (int)Miscellanea.UnsignedLeftShift64(slot, 62);

            Debug.Assert(tag == 0 | tag == 1);
            return(tag == 0 ? FilledValueSlot((int)slot, next) : FilledIdxSlot((int)slot, next));
        }
Esempio n. 3
0
        private long Value(long slot)
        {
            Debug.Assert(!IsEmpty(slot));
            int tag = (int)Miscellanea.UnsignedLeftShift64(slot, 62);

            Debug.Assert(tag == 0 | tag == 1);
            return(tag == 0 ? (int)slot : largeInts.Get((int)slot));
        }
Esempio n. 4
0
        public Obj ReadString()
        {
            Debug.Assert(NextIs('"'));

            int len = 0;

            char[] chars = new char[32];

            Read();
            for ( ; ;)
            {
                int ch = Read();
                Check(Miscellanea.IsBMPCodePoint(ch));

                if (ch == '\\')
                {
                    ch = Read();
                    if (ch == '\\' | ch == '"')
                    {
                        // Nothing to do here
                    }
                    else if (ch == 'n')
                    {
                        ch = '\n';
                    }
                    else if (ch == 't')
                    {
                        ch = '\t';
                    }
                    else
                    {
                        Check(IsHex(ch)); //## THIS ACTUALLY FAILS ONE CHARACTER AHEAD
                        int d3 = HexDigitValue(ch);
                        int d2 = HexDigitValue(ReadHex());
                        int d1 = HexDigitValue(ReadHex());
                        int d0 = HexDigitValue(ReadHex());
                        ch = (char)(4096 * d3 + 256 * d2 + 16 * d1 + d0);
                    }
                }
                else if (ch == '"')
                {
                    break;
                }

                if (len >= chars.Length)
                {
                    chars = Array.Extend(chars, 2 * chars.Length);
                }
                chars[len++] = (char)ch;
            }

            return(Builder.CreateString(chars, len));
        }
Esempio n. 5
0
        public static int CompSymbs(int id1, int id2)
        {
            if (id1 == id2)
            {
                return(0);
            }
            int len = embeddedSymbols.Length;

            if (id1 < len | id2 < len)
            {
                return(id1 < id2 ? 1 : -1);
            }
            string str1 = symbTable[id1];
            string str2 = symbTable[id2];

            return(Miscellanea.Order(str1, str2));
        }
Esempio n. 6
0
        private bool IsSyntacticSugaredString(TaggedObj tagObj)
        {
            Obj obj = tagObj.GetInnerObj();

            if (tagObj.GetTagId() != Cell.Runtime.SymbObj.StringSymbId | !obj.IsIntSeq())
            {
                return(false);
            }
            int len = obj.GetSize();

            for (int i = 0; i < len; i++)
            {
                if (!Miscellanea.IsBMPCodePoint(obj.GetLongAt(i)))
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 7
0
 public Obj Printed()
 {
     return(Miscellanea.StrToObj(ToString()));
 }
Esempio n. 8
0
 protected static ulong FloatObjData(double value)
 {
     return(Miscellanea.DoubleBitsToULongBits(value));
 }
Esempio n. 9
0
 public double GetDouble()
 {
     return(Miscellanea.ULongBitsToDoubleBits(data));
 }
Esempio n. 10
0
 public static ushort BytesToIdx(byte[] bytes, int len)
 {
     return(StrToIdx(Miscellanea.AsciiString(bytes, len)));
 }
Esempio n. 11
0
 public static long Bits(double x)
 {
     return(Miscellanea.DoubleBitsToLongBits(x));
 }
Esempio n. 12
0
 public static uint Hashcode(double x)
 {
     return(Hashing.Hashcode64(Miscellanea.DoubleBitsToULongBits(x)));
 }
Esempio n. 13
0
 private int Next(long slot)
 {
     Debug.Assert(!IsEmpty(slot));
     return((int)(Miscellanea.UnsignedLeftShift64(slot, 32) & 0x3FFFFFFF));
 }
Esempio n. 14
0
        //////////////////////////////////////////////////////////////////////////////

        private int HashIdx(long value)
        {
            int hashcode = (int)(value ^ (value >> 32));

            return(Miscellanea.UnsignedRemaider(hashcode, hashtable.Length));
        }
Esempio n. 15
0
 public static Obj StringToObj(string str)
 {
     //## THIS ONE IS REAL BAD TOO. IT SHOULD USE THE MINIMUM SIZE ARRAY POSSIBLE!
     int[] cps = Miscellanea.CodePoints(str);
     return(Builder.CreateTaggedObj(SymbObj.StringSymbId, Builder.CreateSeq(cps)));
 }