Exemple #1
0
        private static MuftecStackItem[] MashDict(MuftecDict dictionary)
        {
            var items = new List<MuftecStackItem>(dictionary.Count * 2);

            foreach (var item in dictionary)
            {
                items.Add(item.Key);
                items.Add(item.Value);
            }

            return items.ToArray();
        }
Exemple #2
0
        public static void ArrayMatchVal(OpCodeData data)
        {
            var pattern = data.RuntimeStack.PopStr();
            var array = data.RuntimeStack.Pop(MuftecType.List, MuftecType.Dictionary);

            MuftecDict origDict;

            if (array.Type == MuftecType.List)
            {
                origDict = ((MuftecList)array.Item).ToDict();
            }
            else if (array.Type == MuftecType.Dictionary)
            {
                origDict = ((MuftecDict)array.Item);
            }
            else
            {
                throw new MuftecInvalidStackItemTypeException(data.RuntimeStack);
            }

            var newDict = new MuftecDict();

            foreach (var item in origDict)
            {
                if (SharedUtil.smatch(item.Value.ToString(), pattern))
                {
                    newDict.Add(item.Key, item.Value);
                }
            }

            data.RuntimeStack.Push(newDict);
        }
Exemple #3
0
        public static void ArrayMakeDict(OpCodeData data)
        {
            var count = data.RuntimeStack.PopInt();

            var dict = new MuftecDict(count);
            for (var i = 0; i < count; i++)
            {
                var key = data.RuntimeStack.Pop();
                var val = data.RuntimeStack.Pop();
                dict.Add(key, val);
            }

            data.RuntimeStack.Push(dict);
        }