Exemplo n.º 1
0
        public async Task <Dictionary <string, PropDesc> > InspectObject(KiRef handle, int start, int end)
        {
            var reply = await DoRequest(KiTag.REQ, KiRequest.InspectObject, handle, start, end);

            var props = new Dictionary <string, PropDesc>();
            int i     = 1;

            while (i < reply.Length)
            {
                string    key   = reply[i++].ToString();
                PropFlags flags = (PropFlags)(int)reply[i++];
                if (flags.HasFlag(PropFlags.Accessor))
                {
                    KiAtom   getter    = reply[i++];
                    KiAtom   setter    = reply[i++];
                    PropDesc propValue = new PropDesc(getter, setter, flags);
                    if (!flags.HasFlag(PropFlags.Internal))
                    {
                        props.Add(key, propValue);
                    }
                }
                else
                {
                    KiAtom   value     = reply[i++];
                    PropDesc propValue = new PropDesc(value, flags);
                    if (!flags.HasFlag(PropFlags.Internal))
                    {
                        props.Add(key, propValue);
                    }
                }
            }
            return(props);
        }
Exemplo n.º 2
0
 public PropDesc(KiAtom getter, KiAtom setter, PropFlags flags)
 {
     Value  = null;
     Getter = getter;
     Setter = setter;
     Flags  = flags;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a list of local values and their values. Note that objects
        /// are not evaluated and are listed simply as "{ obj: 'ClassName' }".
        /// </summary>
        /// <param name="stackOffset">The stack frame to get locals for, 0 being the current activation.</param>
        /// <returns></returns>
        public async Task <IReadOnlyDictionary <string, KiAtom> > GetLocals(int stackOffset = 0)
        {
            var reply = await DoRequest(KiTag.REQ, KiRequest.InspectLocals, stackOffset);

            var vars  = new Dictionary <string, KiAtom>();
            int count = (reply.Length - 1) / 3;

            for (int i = 0; i < count; ++i)
            {
                string name  = (string)reply[1 + i * 3];
                KiAtom value = reply[3 + i * 3];
                vars[name] = value;
            }
            return(vars);
        }
Exemplo n.º 4
0
        public static KiMessage Receive(Socket socket)
        {
            List <KiAtom> fields = new List <KiAtom>();
            KiAtom        value;

            do
            {
                if ((value = KiAtom.Receive(socket)) == null)
                {
                    return(null);
                }
                if (value.Tag != KiTag.EOM)
                {
                    fields.Add(value);
                }
            } while (value.Tag != KiTag.EOM);
            return(new KiMessage(fields.ToArray()));
        }
Exemplo n.º 5
0
        public KiMessage(params dynamic[] values)
        {
            List <KiAtom> fields = new List <KiAtom>();
            KiAtom        fieldValue;

            foreach (dynamic value in values)
            {
                if (value is KiAtom)
                {
                    fieldValue = value;
                }
                else if (value is KiRequest)
                {
                    fieldValue = new KiAtom((int)value);
                }
                else
                {
                    fieldValue = new KiAtom(value);
                }
                fields.Add(fieldValue);
            }
            m_words = fields.ToArray();
        }
Exemplo n.º 6
0
 public PropDesc(KiAtom value, PropFlags flags)
 {
     Value  = value;
     Getter = Setter = null;
     Flags  = flags;
 }