public object ReadObject() { while (_myBytes.MoveNext()) { byte cur = _myBytes.Current; object res; switch ((char)cur) { case '(': PushStack(StackType.Tuple); break; case '[': PushStack(StackType.List); break; case '{': PushStack(StackType.Dict); break; case '<': PushStack(StackType.Set); break; case '>': PushStack(StackType.FrozenSet); break; case '0': // end of dictionary if (_stack == null || _stack.Count == 0) { throw PythonOps.ValueError("bad marshal data"); } _stack.Peek().StackCount = 0; break; // case 'c': break; default: res = YieldSimple(); if (_stack == null) { return(res); } do { res = UpdateStack(res); } while (res != null && _stack.Count > 0); if (_stack.Count == 0) { return(_result); } continue; } // handle empty lists/tuples... if (_stack != null && _stack.Count > 0 && _stack.Peek().StackCount == 0) { ProcStack ps = _stack.Pop(); res = ps.StackObj; if (ps.StackType == StackType.Tuple) { res = PythonTuple.Make(res); } else if (ps.StackType == StackType.FrozenSet) { res = FrozenSetCollection.Make(TypeCache.FrozenSet, res); } if (_stack.Count > 0) { // empty list/tuple do { res = UpdateStack(res); } while (res != null && _stack.Count > 0); if (_stack.Count == 0) { break; } } else { _result = res; break; } } } return(_result); }
private object UpdateStack(object res) { ProcStack curStack = _stack.Peek(); switch (curStack.StackType) { case StackType.Dict: PythonDictionary od = curStack.StackObj as PythonDictionary; if (curStack.HaveKey) { od[curStack.Key] = res; curStack.HaveKey = false; } else { curStack.HaveKey = true; curStack.Key = res; } break; case StackType.Tuple: List <object> objs = curStack.StackObj as List <object>; objs.Add(res); curStack.StackCount--; if (curStack.StackCount == 0) { _stack.Pop(); object tuple = PythonTuple.Make(objs); if (_stack.Count == 0) { _result = tuple; } return(tuple); } break; case StackType.List: PythonList ol = curStack.StackObj as PythonList; ol.AddNoLock(res); curStack.StackCount--; if (curStack.StackCount == 0) { _stack.Pop(); if (_stack.Count == 0) { _result = ol; } return(ol); } break; case StackType.Set: SetCollection os = curStack.StackObj as SetCollection; os.add(res); curStack.StackCount--; if (curStack.StackCount == 0) { _stack.Pop(); if (_stack.Count == 0) { _result = os; } return(os); } break; case StackType.FrozenSet: List <object> ofs = curStack.StackObj as List <object>; ofs.Add(res); curStack.StackCount--; if (curStack.StackCount == 0) { _stack.Pop(); object frozenSet = FrozenSetCollection.Make(TypeCache.FrozenSet, ofs); if (_stack.Count == 0) { _result = frozenSet; } return(frozenSet); } break; } return(null); }
public FrozenSetCollection intersection([NotNull] FrozenSetCollection set) { return(Make(SetStorage.Intersection(_items, set._items))); }
public bool issuperset([NotNull] FrozenSetCollection set) { return(set._items.IsSubset(_items)); }
public bool isdisjoint([NotNull] FrozenSetCollection set) { return(_items.IsDisjoint(set._items)); }
public FrozenSetCollection union([NotNone] FrozenSetCollection set) { return(Make(SetStorage.Union(_items, set._items))); }
public bool issubset([NotNone] FrozenSetCollection set) { return(_items.IsSubset(set._items)); }