private bool IsEmpty(long slot) { long tag = Miscellanea.UnsignedLeftShift64(slot, 62); Debug.Assert(tag == 0 | tag == 1 | tag == 2); return(tag == 2); }
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)); }
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)); }
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)); }
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)); }
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); }
public Obj Printed() { return(Miscellanea.StrToObj(ToString())); }
protected static ulong FloatObjData(double value) { return(Miscellanea.DoubleBitsToULongBits(value)); }
public double GetDouble() { return(Miscellanea.ULongBitsToDoubleBits(data)); }
public static ushort BytesToIdx(byte[] bytes, int len) { return(StrToIdx(Miscellanea.AsciiString(bytes, len))); }
public static long Bits(double x) { return(Miscellanea.DoubleBitsToLongBits(x)); }
public static uint Hashcode(double x) { return(Hashing.Hashcode64(Miscellanea.DoubleBitsToULongBits(x))); }
private int Next(long slot) { Debug.Assert(!IsEmpty(slot)); return((int)(Miscellanea.UnsignedLeftShift64(slot, 32) & 0x3FFFFFFF)); }
////////////////////////////////////////////////////////////////////////////// private int HashIdx(long value) { int hashcode = (int)(value ^ (value >> 32)); return(Miscellanea.UnsignedRemaider(hashcode, hashtable.Length)); }
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))); }