Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
                        }

                        Cell c = current.body.firstAdded;
                        while (c != null)
                        {
                            string s = c.name;
                            if (!undefined.Contains(s))
                            {
                                object val = c.value;
                                if (val == runtime.nul)
                                {
                                    undefined.Add(s);
                                }
                                else
                                {
                                    object x = runtime.GetSymbol(s);
                                    if (!cells.Contains(x))
                                    {
                                        cells[x] = val;
                                    }
                                }
                            }
                            c = c.orderedNext;
                        }
                    }
                }
            }
            else
            {
                Cell c = IokeObject.As(on, context).body.firstAdded;
                while (c != null)
                {
                    string s = c.name;
                    if (c.value != runtime.nul)
                    {
                        cells[runtime.GetSymbol(s)] = c.value;
                    }
                    c = c.orderedNext;
                }
            }
            return(runtime.NewDict(cells));
        }
Exemple #5
0
        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));
            }
        }