public static object CellNames(IokeObject context, IokeObject message, object on, bool includeMimics, object cutoff) { if(includeMimics) { var visited = IdentityHashTable.Create(); var names = new SaneArrayList(); var visitedNames = new SaneHashSet<object>(); var undefined = new SaneHashSet<string>(); Runtime runtime = context.runtime; var toVisit = new SaneArrayList(); toVisit.Add(on); while(toVisit.Count > 0) { IokeObject current = IokeObject.As(toVisit[0], context); toVisit.RemoveAt(0); if(!visited.Contains(current)) { visited[current] = null; if(cutoff != current) { foreach(IokeObject o in current.GetMimics()) toVisit.Add(o); } Cell c = current.body.firstAdded; while(c != null) { string s = c.name; if(!undefined.Contains(s)) { if(c.value == runtime.nul) { undefined.Add(s); } else { object x = runtime.GetSymbol(s); if(!visitedNames.Contains(x)) { visitedNames.Add(x); names.Add(x); } } } c = c.orderedNext; } } } return runtime.NewList(names); } else { var names = new SaneArrayList(); Runtime runtime = context.runtime; Cell c = IokeObject.As(on, context).body.firstAdded; while(c != null) { string s = c.name; if(c.value != runtime.nul) { names.Add(runtime.GetSymbol(s)); } c = c.orderedNext; } return runtime.NewList(names); } }
public static object CellNames(IokeObject context, IokeObject message, object on, bool includeMimics, object cutoff) { if(includeMimics) { var visited = IdentityHashTable.Create(); var names = new SaneArrayList(); var visitedNames = new SaneHashSet<object>(); var undefined = new SaneHashSet<string>(); Runtime runtime = context.runtime; var toVisit = new SaneArrayList(); toVisit.Add(on); while(toVisit.Count > 0) { IokeObject current = IokeObject.As(toVisit[0], context); toVisit.RemoveAt(0); if(!visited.Contains(current)) { visited[current] = null; if(cutoff != current) { foreach(IokeObject o in current.GetMimics()) toVisit.Add(o); } var mso = current.Cells; foreach(string s in mso.Keys) { if(!undefined.Contains(s)) { if(mso[s] == runtime.nul) { undefined.Add(s); } else { object x = runtime.GetSymbol(s); if(!visitedNames.Contains(x)) { visitedNames.Add(x); names.Add(x); } } } } } } return runtime.NewList(names); } else { var mso = IokeObject.As(on, context).Cells; var names = new SaneArrayList(); Runtime runtime = context.runtime; foreach(string s in mso.Keys) { if(mso[s] != runtime.nul) { names.Add(runtime.GetSymbol(s)); } } return runtime.NewList(names); } }
private IList parseExpressionChain() { ArrayList chain = new SaneArrayList(); IokeObject curr = parseExpressions(); while(curr != null) { chain.Add(curr); readWhiteSpace(); int rr = peek(); if(rr == ',') { read(); curr = parseExpressions(); if(curr == null) { fail("Expected expression following comma"); } } else { if(curr != null && Message.IsTerminator(curr) && Message.GetNext(curr) == null) { chain.RemoveAt(chain.Count-1); } curr = null; } } return chain; }
public static object Cells(IokeObject context, IokeObject message, object on, bool includeMimics) { var cells = new SaneOrderedDictionary(); Runtime runtime = context.runtime; if(includeMimics) { var visited = IdentityHashTable.Create(); var undefined = new SaneHashSet<string>(); var toVisit = new SaneArrayList(); toVisit.Add(on); while(toVisit.Count > 0) { IokeObject current = IokeObject.As(toVisit[0], context); toVisit.RemoveAt(0); if(!visited.Contains(current)) { visited[current] = null; foreach(IokeObject o in current.GetMimics()) toVisit.Add(o); var mso = current.Cells; foreach(string s in mso.Keys) { if(!undefined.Contains(s)) { object val = mso[s]; if(val == runtime.nul) { undefined.Add(s); } else { object x = runtime.GetSymbol(s); if(!cells.Contains(x)) { cells[x] = val; } } } } } } } else { var mso = IokeObject.As(on, context).Cells; foreach(string s in mso.Keys) { object val = mso[s]; if(val != runtime.nul) { cells[runtime.GetSymbol(s)] = val; } } } return runtime.NewDict(cells); }