Beispiel #1
0
        public override DObject OpMOD(DObject other)
        {
            if (HasMember("mod"))
            {
                return(AssertType <DBool>(CLRCallFunction("mod", other)));
            }

            return(base.OpMOD(other));
        }
Beispiel #2
0
        public override DBool OpGR(DObject other)
        {
            if (HasMember("greaterThan"))
            {
                return(AssertType <DBool>(CLRCallFunction("greaterThan", other)));
            }

            return(base.OpGR(other));
        }
Beispiel #3
0
        public override DObject OpADD(DObject other)
        {
            if (HasMember("add"))
            {
                return(CLRCallFunction("add", other));
            }

            return(base.OpADD(other));
        }
Beispiel #4
0
        public override DObject OpSUB(DObject other)
        {
            if (HasMember("sub"))
            {
                return(CLRCallFunction("sub", other));
            }

            return(base.OpSUB(other));
        }
Beispiel #5
0
        public override DBool OpEQ(DObject other)
        {
            if (HasMember("equals"))
            {
                return(AssertType <DBool>(CLRCallFunction("equals", other)));
            }

            return(base.OpEQ(other));
        }
Beispiel #6
0
        public override DObject OpDIV(DObject other)
        {
            if (HasMember("divide"))
            {
                return(CLRCallFunction("divide", other));
            }

            return(base.OpDIV(other));
        }
Beispiel #7
0
        public override DObject OpMUL(DObject other)
        {
            if (HasMember("multiply"))
            {
                return(CLRCallFunction("multiply", other));
            }

            return(base.OpMUL(other));
        }
Beispiel #8
0
        public override DObject OpPOW(DObject other)
        {
            if (HasMember("exponent"))
            {
                return(AssertType <DBool>(CLRCallFunction("exponent", other)));
            }

            return(base.OpPOW(other));
        }
Beispiel #9
0
        public override Member OpINDEX(DObject other)
        {
            var key = pairs.Keys.ToList().Find(x => x.Equals(other));

            if (key == null)
            {
                throw new InterpreterException(Interpreter.current.CurrentToken, "No key exists: " + other.ToString());
            }

            return(pairs[key]);
        }
Beispiel #10
0
        public void Remove(DObject value)
        {
            Member m = null;

            foreach (var item in items)
            {
                if (item.Value.Equals(value))
                {
                    m = item;
                    break;
                }
            }

            if (m != null)
            {
                items.Remove(m);
            }
        }
Beispiel #11
0
 public void Write(DObject obj)
 {
     Console.Write(obj.ToString());
 }
Beispiel #12
0
 public override DObject OpMOD(DObject other)
 {
     return((value % AssertType <DNumber>(other).value).ToDNumber());
 }
Beispiel #13
0
 public void Print(DObject obj)
 {
     Console.WriteLine(obj.ToString());
 }
Beispiel #14
0
 public override DBool OpLS(DObject other)
 {
     return((value < AssertType <DNumber>(other).value).ToDBool());
 }
Beispiel #15
0
 public override DObject OpPOW(DObject other)
 {
     return(Math.Pow(value, AssertType <DNumber>(other).value).ToDNumber());
 }
Beispiel #16
0
 // EQUALITY OPERATORS
 public virtual DBool OpEQ(DObject other)
 {
     return(Equals(other).ToDBool());
 }
Beispiel #17
0
 public virtual Member OpINDEX(DObject other)
 {
     throw Interpreter.current.Exception("Type " + GetType() + " cannot be indexed");
 }
Beispiel #18
0
 public override Member OpINDEX(DObject other)
 {
     return(items[AssertType <DNumber>(other).ToInt()]);
 }
Beispiel #19
0
 public override Member OpINDEX(DObject other)
 {
     return(GetMember(other.ToString()));
     //throw new Exception("A table cannot be indexed. Instead, make getter and setter methods.");
 }
Beispiel #20
0
 public virtual DBool OpLS(DObject other)
 {
     throw OpException(GetType(), other.GetType());
 }
Beispiel #21
0
 public void Remove(DObject key)
 {
     pairs.Remove(key);
 }
Beispiel #22
0
 public virtual DBool OpNEQ(DObject other)
 {
     return(OpEQ(other).OpNOT());
 }
Beispiel #23
0
 public virtual DBool OpLEQ(DObject other)
 {
     return(OpLS(other).OpOR(OpEQ(other)));
 }
Beispiel #24
0
 public virtual DObject OpMUL(DObject other)
 {
     throw OpException(GetType(), other.GetType());
 }
Beispiel #25
0
 public void Add(DObject key, DObject value)
 {
     pairs.Add(key, new Member(value));
 }
Beispiel #26
0
 public override DObject OpADD(DObject other)
 {
     return(new DString(value + other.ToString()));
 }
Beispiel #27
0
 public DString(DSet charArray)
 {
     value = new string(charArray.items.Select(x => DObject.AssertType <DChar>(x.Value).value).ToArray());
 }
Beispiel #28
0
 public void Add(DObject value)
 {
     items.Add(new Member(value));
 }
Beispiel #29
0
        public override Member OpINDEX(DObject other)
        {
            int index = AssertType <DNumber>(other).ToInt();

            return(new StringChar(this, index));
        }
Beispiel #30
0
 public DObject Set(DNumber index, DObject value)
 {
     return(items[index.ToInt()].Value = value);
 }