Beispiel #1
0
        public bool HasInheritedProperty(object ident)
        {
            var name = GetKey(ident);

            if (Dict.ContainsKey(name))
            {
                return(true);
            }

            return(Parents.Any(x => x.Dict.ContainsKey(name)));
        }
Beispiel #2
0
        //[Lisp( "get-lexical-variables-dictionary" )]
        public static Prototype GetLexicalVariablesDictionary(int pos)
        {
            Frame frame = GetFrameAt(pos);

            if (frame == null)
            {
                return(null);
            }

            var env = new PrototypeDictionary();

            for (; frame != null; frame = frame.Link)
            {
                if (frame.Names != null)
                {
                    for (var i = 0; i < frame.Names.Count; ++i)
                    {
                        var    key   = frame.Names[i].DiagnosticsName;
                        object value = null;
                        if (frame.Values != null && i < frame.Values.Count)
                        {
                            value = frame.Values[i];
                        }
                        if (key == Symbols.Tilde.Name)
                        {
                            if (frame == CurrentThreadContext.Frame)
                            {
                                env[key] = value;
                            }
                            else if (!env.ContainsKey(key))
                            {
                                env[key] = value;
                            }
                        }
                        else if (!env.ContainsKey(key))
                        {
                            env[key] = value;
                        }
                    }
                }
            }

            return(Prototype.FromDictionary(env));
        }
Beispiel #3
0
        //[Lisp( "get-dynamic-variables-dictionary" )]
        public static Prototype GetDynamicVariablesDictionary(int pos)
        {
            var env = new PrototypeDictionary();

            for (var entry = GetSpecialVariablesAt(pos); entry != null; entry = entry.Link)
            {
                var key = entry.Sym.DiagnosticsName;
                if (!env.ContainsKey(key))
                {
                    env[key] = entry.Value;
                }
            }

            return(Prototype.FromDictionary(env));
        }
Beispiel #4
0
        public void MergeInto(PrototypeDictionary dict)
        {
            foreach (var item in Dict)
            {
                if (!dict.ContainsKey(item.Key))
                {
                    dict[item.Key] = item.Value;
                }
            }

            foreach (var parent in Parents)
            {
                parent.MergeInto(dict);
            }
        }
Beispiel #5
0
        public PrototypeDictionary GetDictionary()
        {
            var dict = new PrototypeDictionary();

            for (var f = this; f != null; f = f.Link)
            {
                if (f.Names != null)
                {
                    for (var i = 0; i < f.Names.Count; ++i)
                    {
                        var n = f.Names[i];
                        var v = f.Values[i];

                        if (!n.IsReservedName && !dict.ContainsKey(n))
                        {
                            dict[n] = v;
                        }
                    }
                }
            }
            return(dict);
        }