////////////////////////////////////////////////////////////////////////////// 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 void NeBinRelObj(NeBinRelObj obj) { Obj[] col1 = obj.Col1(); Obj[] col2 = obj.Col2(); bool isMap = obj.IsNeMap(); bool isRec = obj.IsNeRecord(); int len = col1.Length; int size = (2 + (isMap & !isRec ? 4 : 2)) * len + ((!isMap & len == 1) ? 1 : 0); for (int i = 0; i < len; i++) { size += ObjSize(col1[i]) + ObjSize(col2[i]); } ConsumeSize(obj, size); }
private void StandardBinRelObj(NeBinRelObj obj) { Obj[] col1 = obj.Col1(); Obj[] col2 = obj.Col2(); int len = col1.Length; writer.Write('['); if (IsMultiline(obj)) { writer.Indent(); if (writer.IsNewLine()) { writer.Write(' '); } else { writer.NewLine(); } for (int i = 0; i < len; i++) { Obj arg1 = col1[i]; Obj arg2 = col2[i]; bool multiline = IsMultiline(arg1) || IsMultiline(arg2); arg1.Visit(this); writer.Write(","); if (multiline) { writer.NewLine(); } else { writer.Write(' '); } arg2.Visit(this); if (i == 0 | i < len - 1) { writer.Write(";"); } writer.NewLine(); } writer.UnindentedNewLine(); } else { for (int i = 0; i < len; i++) { if (i > 0) { writer.Write("; "); } col1[i].Visit(this); writer.Write(", "); col2[i].Visit(this); } if (len == 1) { writer.Write(';'); } } writer.Write(']'); }
private void Map(NeBinRelObj obj) { Obj[] col1 = obj.Col1(); Obj[] col2 = obj.Col2(); int len = col1.Length; writer.Write('['); if (IsMultiline(obj)) { writer.Indent(); if (writer.IsNewLine()) { writer.Write(' '); } else { writer.NewLine(); } for (int i = 0; i < len; i++) { Obj arg1 = col1[i]; Obj arg2 = col2[i]; arg1.Visit(this); writer.Write(" ->"); if (IsMultiline(arg2)) { writer.IndentedNewLine(); arg2.Visit(this); writer.Unindent(); } else { writer.Write(' '); arg2.Visit(this); } if (i < len - 1) { writer.Write(','); } else { writer.Unindent(); } writer.NewLine(); } } else { for (int i = 0; i < len; i++) { if (i > 0) { writer.Write(", "); } col1[i].Visit(this); writer.Write(" -> "); col2[i].Visit(this); } } writer.Write(']'); }
private void Record(NeBinRelObj obj) { Obj[] values = obj.Col2(); int len = values.Length; ushort[] labels; if (obj is RecordObj) { RecordObj recObj = (RecordObj)obj; labels = recObj.fieldIds; } else { labels = new ushort[len]; Obj[] fields = obj.Col1(); for (int i = 0; i < len; i++) { labels[i] = fields[i].GetSymbId(); } } writer.Write('('); if (IsMultiline(obj)) { int maxLabelLen = 0; for (int i = 0; i < len; i++) { int labelLen = Cell.Runtime.SymbObj.IdxToStr(labels[i]).Length; if (labelLen > maxLabelLen) { maxLabelLen = labelLen; } } int[] idxs = SortedIdxs(labels, values); writer.Indent(); if (writer.IsNewLine()) { writer.Write(' '); } else { writer.NewLine(); } for (int i = 0; i < len; i++) { int idx = idxs[i]; string label = Cell.Runtime.SymbObj.IdxToStr(labels[idx]); writer.Write(label); writer.Write(':'); Obj value = values[idx]; if (IsMultiline(value)) { writer.IndentedNewLine(); value.Visit(this); writer.Unindent(); } else { writer.WriteSpaces(maxLabelLen - label.Length + 1); value.Visit(this); } if (i < len - 1) { writer.Write(','); } else { writer.Unindent(); } writer.NewLine(); } } else { for (int i = 0; i < len; i++) { if (i > 0) { writer.Write(", "); } writer.Write(Cell.Runtime.SymbObj.IdxToStr(labels[i])); writer.Write(": "); values[i].Visit(this); } } writer.Write(')'); }