private void StandardTaggedObj(ushort tagId, Obj obj) { writer.Write(Cell.Runtime.SymbObj.IdxToStr(tagId)); if (!obj.IsNeRecord() && (!obj.IsNeSeq() || obj.GetSize() == 1)) { writer.Write('('); if (IsMultiline(obj)) { writer.IndentedNewLine(); obj.Visit(this); writer.UnindentedNewLine(); } else { obj.Visit(this); } writer.Write(')'); } else { obj.Visit(this); } }
////////////////////////////////////////////////////////////////////////////// public override int InternalOrder(Obj other) { Debug.Assert(GetSize() == other.GetSize()); Obj[] col, otherCol; int size = GetSize(); NeBinRelObj otherRel = (NeBinRelObj)other; if (other is RecordObj) { RecordObj otherRecord = (RecordObj)other; ushort[] otherFieldIds = otherRecord.fieldIds; if (fieldIds != otherFieldIds) { for (int i = 0; i < size; i++) { int res = SymbObj.CompSymbs(fieldIds[i], otherFieldIds[i]); if (res != 0) { return(res); } } } } else { BuildCol1(); col = col1; otherCol = otherRel.Col1(); for (int i = 0; i < size; i++) { int ord = col[i].QuickOrder(otherCol[i]); if (ord != 0) { return(ord); } } } col = col2; otherCol = otherRel.Col2(); for (int i = 0; i < size; i++) { int ord = col[i].QuickOrder(otherCol[i]); if (ord != 0) { return(ord); } } return(0); }
public static int[] ToIntArray(Obj obj) { int len = obj.GetSize(); int[] array = new int[len]; for (int i = 0; i < len; i++) { array[i] = (int)obj.GetLongAt(i); } return(array); }
public static byte[] ToByteArray(Obj obj) { int len = obj.GetSize(); byte[] array = new byte[len]; for (int i = 0; i < len; i++) { array[i] = (byte)obj.GetLongAt(i); } return(array); }
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); }
private void SyntacticSugaredString(Obj chars) { writer.Write('"'); int len = chars.GetSize(); for (int i = 0; i < len; i++) { int code = (char)chars.GetLongAt(i); if (code == '\n') { writer.Write("\\n"); } else if (code == '\t') { writer.Write("\\t"); } else if (code == '\\') { writer.Write("\\\\"); } else if (code == '"') { writer.Write("\\\""); } else if (code >= 32 & code <= 126) { writer.Write((char)code); } else { writer.Write('\\'); for (int j = 0; j < 4; j++) { int hexDigit = (code >> (12 - 4 * j)) % 16; char ch = (char)(hexDigit < 10 ? '0' + hexDigit : 'a' - 10 + hexDigit); writer.Write(ch); } } } writer.Write('"'); }