Exemplo n.º 1
0
        public override DreamValue OperatorSubtract(DreamValue a, DreamValue b)
        {
            DreamList list     = a.GetValueAsDreamList();
            DreamList listCopy = list.CreateCopy();

            if (b.Type == DreamValue.DreamValueType.DreamObject)
            {
                if (b.TryGetValueAsDreamList(out DreamList bList))
                {
                    foreach (DreamValue value in bList.GetValues())
                    {
                        listCopy.RemoveValue(value);
                    }
                }
                else
                {
                    listCopy.RemoveValue(b);
                }
            }
            else
            {
                listCopy.RemoveValue(b);
            }

            return(new DreamValue(listCopy));
        }
Exemplo n.º 2
0
        public DreamValue OperatorMask(DreamValue a, DreamValue b)
        {
            DreamList list = a.GetValueAsDreamList();

            if (b.TryGetValueAsDreamList(out DreamList bList))
            {
                for (int i = 1; i <= list.GetLength(); i++)
                {
                    if (!bList.ContainsValue(list.GetValue(new DreamValue(i))))
                    {
                        list.Cut(i, i + 1);
                        i--;
                    }
                }
            }
            else
            {
                for (int i = 1; i <= list.GetLength(); i++)
                {
                    if (list.GetValue(new DreamValue(i)) != b)
                    {
                        list.Cut(i, i + 1);
                        i--;
                    }
                }
            }

            return(a);
        }
Exemplo n.º 3
0
        public override DreamValue OperatorCombine(DreamValue a, DreamValue b)
        {
            DreamList list = a.GetValueAsDreamList();

            if (b.Type == DreamValue.DreamValueType.DreamObject)
            {
                if (b.TryGetValueAsDreamList(out DreamList bList))
                {
                    foreach (DreamValue value in bList.GetValues())
                    {
                        if (!list.ContainsValue(value))
                        {
                            list.AddValue(value);
                        }
                    }
                }
                else if (!list.ContainsValue(b))
                {
                    list.AddValue(b);
                }
            }
            else if (!list.ContainsValue(b))
            {
                list.AddValue(b);
            }

            return(a);
        }
Exemplo n.º 4
0
        public override DreamValue OperatorRemove(DreamValue a, DreamValue b)
        {
            DreamList list = a.GetValueAsDreamList();

            if (b.Type == DreamValue.DreamValueType.DreamObject)
            {
                if (b.TryGetValueAsDreamList(out DreamList bList))
                {
                    foreach (DreamValue value in bList.GetValues())
                    {
                        list.RemoveValue(value);
                    }
                }
                else
                {
                    list.RemoveValue(b);
                }
            }
            else
            {
                list.RemoveValue(b);
            }

            return(a);
        }
Exemplo n.º 5
0
        public DreamValue OperatorOr(DreamValue a, DreamValue b)
        {
            DreamList list = a.GetValueAsDreamList();

            if (b.TryGetValueAsDreamList(out DreamList bList))      // List | List
            {
                list = list.Union(bList);
            }
            else                                                    // List | x
            {
                list = list.CreateCopy();
                list.AddValue(b);
            }

            return(new DreamValue(list));
        }
Exemplo n.º 6
0
        public DreamValue OperatorAppend(DreamValue a, DreamValue b)
        {
            DreamList list = a.GetValueAsDreamList();

            if (b.TryGetValueAsDreamList(out DreamList bList))
            {
                foreach (DreamValue value in bList.GetValues())
                {
                    list.AddValue(value);
                }
            }
            else
            {
                list.AddValue(b);
            }

            return(a);
        }
Exemplo n.º 7
0
        public DreamValue OperatorAdd(DreamValue a, DreamValue b)
        {
            DreamList list     = a.GetValueAsDreamList();
            DreamList listCopy = list.CreateCopy();

            if (b.TryGetValueAsDreamList(out DreamList bList))
            {
                foreach (DreamValue value in bList.GetValues())
                {
                    listCopy.AddValue(value);
                }
            }
            else
            {
                listCopy.AddValue(b);
            }

            return(new DreamValue(listCopy));
        }
Exemplo n.º 8
0
        public DreamValue OperatorRemove(DreamValue a, DreamValue b)
        {
            DreamList list = a.GetValueAsDreamList();

            if (b.TryGetValueAsDreamList(out DreamList bList))
            {
                DreamValue[] values = bList.GetValues().ToArray();

                foreach (DreamValue value in values)
                {
                    list.RemoveValue(value);
                }
            }
            else
            {
                list.RemoveValue(b);
            }

            return(a);
        }