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); }
public PropDesc(KiAtom getter, KiAtom setter, PropFlags flags) { Value = null; Getter = getter; Setter = setter; Flags = flags; }
/// <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); }
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())); }
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(); }
public PropDesc(KiAtom value, PropFlags flags) { Value = value; Getter = Setter = null; Flags = flags; }