Пример #1
0
        public void NewThread(string Name)
        {
            vThread t = new vThread(Name, this);

            t.startingInstruction = 0;
            threads.Add(t);
        }
Пример #2
0
        public void Run(vThread from)
        {
            vArray array = from.getArg(0) as vArray;
            int    index = (int)from.getArg(1);

            from.stack.Push(array.array[index]);
        }
Пример #3
0
        public void Run(vThread from)
        {
            int    len = (int)from.stack.Pop();
            vArray a   = new vArray(len, from);

            from.stack.Push(a);
        }
Пример #4
0
 public void Run(vThread from)
 {
     vArray array = from.getArg(0) as vArray;
     object val = from.stack.Pop();
     int index = (int)from.getArg(1);
     array.array[index] = val;
 }
Пример #5
0
        public void Run(vThread from)
        {
            vArray array = from.getArg(0) as vArray;
            object val   = from.stack.Pop();
            int    index = (int)from.getArg(1);

            array.array[index] = val;
        }
Пример #6
0
        public void Run(vThread from)
        {
            string  function = from.stack.Pop() as string;
            vThread t        = new vThread(from.stack.Pop() as string, from.parent);

            t.startingInstruction = from.GetMethod(function).GetAddress();
            from.parent.AddThread(t);
            from.stack.Push(from.parent.ThreadCount - 1);
        }
Пример #7
0
        internal Instance CreateInstance(vThread p)
        {
            Instance i = new Instance(this, p);

            foreach (Field str in fields)
            {
                i.AddVar(str.name, null);
            }
            return(i);
        }
Пример #8
0
 public void Run(vThread from)
 {
     if (from.stack.Count > 0)
     {
         object o = from.stack.Pop();
         if (o is bool && ((bool)o) == false)
         {
             from.Jmp(label);
         }
     }
 }
Пример #9
0
 public void Run(vThread from)
 {
     if (from.stack.Count > 0)
     {
         object o = from.stack.Pop();
         if (o is string)
         {
             from.stack.Push((o as string).ToLower());
         }
     }
 }
Пример #10
0
 public void Run(vThread from)
 {
     if (from.callstack.Count > 0)
     {
         from.instructionIndex = from.callstack.Pop().retaddress;
         from.RestoreGlobalVars();
     }
     else
     {
         from.End();
     }
 }
Пример #11
0
        public void Run(vThread from)
        {
            if (from.stack.Count > 1)
            {
                object b = from.stack.Pop();
                object a = from.stack.Pop();

                if (a is string && b is string)
                {
                    from.stack.Push((a as string) + (b as string));
                }
            }
        }
Пример #12
0
        public void Run(vThread from)
        {
            if (from.stack.Count > 1)
            {
                object b = from.stack.Pop();
                object a = from.stack.Pop();

                if (a is string && b is int)
                {
                    from.stack.Push((a as string).Substring((int)b));
                }
            }
        }
Пример #13
0
        public void Run(vThread from)
        {
            char   c = (char)from.stack.Pop();
            string s = from.stack.Pop() as string;

            string[] arr = s.Split(c);

            vArray a = new vArray(arr.Length, from);

            a.array = arr;

            from.stack.Push(a);
        }
Пример #14
0
        internal void Call(string p, vThread from)
        {
            vMethod m = getMethod(p);

            if (m != null)
            {
                vCall c = new vCall();
                c.referance    = m;
                c.retaddress   = from.instructionIndex;
                c.startaddress = m.GetAddress();
                from.callstack.Push(c);
                from.callstack.Peek().Run(from);
            }
        }
Пример #15
0
        public void Run(vThread from)
        {
            if (from.stack.Count > 1)
            {
                object a = from.stack.Pop();
                object b = from.stack.Pop();

                if (a is int)
                {
                    int ai = (int)a;
                    if (b is int)
                    {
                        int bi = (int)b;
                        int c = ai + bi;
                        from.stack.Push(c);
                    }
                    else if (b is double)
                    {
                        double bd = (double)b;
                        double c = ai + bd;
                        from.stack.Push(c);
                    }
                }
                else if (a is double)
                {
                    double ai = (double)a;
                    if (b is int)
                    {
                        int bi = (int)b;
                        double c = ai + bi;
                        from.stack.Push(c);
                    }
                    else if (b is double)
                    {
                        double bd = (double)b;
                        double c = ai + bd;
                        from.stack.Push(c);
                    }
                }
                else if (a is string && b is string)
                {
                    from.stack.Push(((a as string) + (b as string)));
                }
            }
            else
            {
                from.parent.Error("Stack Empty", "Stack empty when trying to add");
            }
        }
Пример #16
0
        public void Run(vThread from)
        {
            if (from.stack.Count > 1)
            {
                object a = from.stack.Pop();
                object b = from.stack.Pop();

                if (a is int)
                {
                    int ai = (int)a;
                    if (b is int)
                    {
                        int bi = (int)b;
                        int c  = ai + bi;
                        from.stack.Push(c);
                    }
                    else if (b is double)
                    {
                        double bd = (double)b;
                        double c  = ai + bd;
                        from.stack.Push(c);
                    }
                }
                else if (a is double)
                {
                    double ai = (double)a;
                    if (b is int)
                    {
                        int    bi = (int)b;
                        double c  = ai + bi;
                        from.stack.Push(c);
                    }
                    else if (b is double)
                    {
                        double bd = (double)b;
                        double c  = ai + bd;
                        from.stack.Push(c);
                    }
                }
                else if (a is string && b is string)
                {
                    from.stack.Push(((a as string) + (b as string)));
                }
            }
            else
            {
                from.parent.Error("Stack Empty", "Stack empty when trying to add");
            }
        }
Пример #17
0
        public void Run(vThread from)
        {
            if (from.stack.Count > 1)
            {
                object a = from.stack.Pop();
                object b = from.stack.Pop();
                bool   r = false;

                if (a is string && b is string)
                {
                    r = (a as string) == (b as string);
                }

                from.stack.Push(r);
            }
        }
Пример #18
0
        public void Run(vThread from)
        {
            string state  = from.stack.Pop() as string;
            int    thread = (int)from.stack.Pop();

            if (state == "low")
            {
                from.parent.GetThread(thread).SetPriority(ThreadPriority.Lowest);
            }
            else if (state == "normal")
            {
                from.parent.GetThread(thread).SetPriority(ThreadPriority.Normal);
            }
            else if (state == "high")
            {
                from.parent.GetThread(thread).SetPriority(ThreadPriority.Highest);
            }
        }
Пример #19
0
        public void Run(vThread from)
        {
            if (from.stack.Count > 1)
            {
                object a = from.stack.Pop();
                object b = from.stack.Pop();
                bool   r = false;

                if (a is int)
                {
                    int ai = (int)a;
                    if (b is int)
                    {
                        int bi = (int)b;
                        r = ai == bi;
                    }
                    else if (b is double)
                    {
                        double bd = (double)b;
                        r = ai == bd;
                    }
                }
                else if (a is double)
                {
                    double ai = (double)a;
                    if (b is int)
                    {
                        int bi = (int)b;
                        r = ai == bi;
                    }
                    else if (b is double)
                    {
                        double bd = (double)b;
                        r = ai == bd;
                    }
                }
                else if ((a is string) && (b is string))
                {
                    r = (a as string) == (b as string);
                }
                from.stack.Push(r);
            }
        }
Пример #20
0
        public void Run(vThread from)
        {
            if (from.stack.Count > 1)
            {
                object b = from.stack.Pop();
                object a = from.stack.Pop();
                bool   r = false;

                if (a is int)
                {
                    int ai = (int)a;
                    if (b is int)
                    {
                        int bi = (int)b;
                        r = ai > bi;
                    }
                    else if (b is double)
                    {
                        double bd = (double)b;
                        r = ai > bd;
                    }
                }
                else if (a is double)
                {
                    double ai = (double)a;
                    if (b is int)
                    {
                        int bi = (int)b;
                        r = ai > bi;
                    }
                    else if (b is double)
                    {
                        double bd = (double)b;
                        r = ai > bd;
                    }
                }
                from.stack.Push(r);
            }
        }
Пример #21
0
 internal void AddThread(vThread t)
 {
     threads.Add(t);
 }
Пример #22
0
 public void Run(vThread from)
 {
     Instance i = from.GetClass(type).CreateInstance(from);
     from.getStack().Push(i);
 }
Пример #23
0
 internal Instance CreateInstance(vThread p)
 {
     Instance i = new Instance(this,p);
     foreach (Field str in fields)
     {
         i.AddVar(str.name, null);
     }
     return i;
 }
Пример #24
0
 public void Run(vThread from)
 {
     if (from.stack.Count > 0)
     {
         object o = from.stack.Pop();
         if (o is bool && ((bool)o) == false)
         {
             from.Jmp(label);
         }
     }
 }
Пример #25
0
 public void Run(vThread from)
 {
     Console.WriteLine(from.getStack().Pop());
 }
Пример #26
0
 public void Run(vThread from)
 {
     from.callstack.Peek().getMethod().RestoreStack(from);
 }
Пример #27
0
 public void Run(vThread from)
 {
     from.CALL(method);
     from.End();
 }
Пример #28
0
 public void Run(vThread from)
 {
     from.stack.Push(from.parent.PopError());
 }
Пример #29
0
 public void Run(vThread from)
 {
     from.getVM().Error(title, msg);
 }
Пример #30
0
 public void Run(vThread from)
 {
     from.getStack().Pop();
 }
Пример #31
0
 public void Run(vThread from)
 {
 }
Пример #32
0
 public void Run(vThread from)
 {
     vArray array = from.getArg(0) as vArray;
     int index = (int)from.getArg(1);
     from.stack.Push(array.array[index]);
 }
Пример #33
0
 public void Run(vThread from)
 {
     from.Interupt(n);
 }
Пример #34
0
 public void Run(vThread from)
 {
     from.Jmp(label);
 }
Пример #35
0
 public void Run(vThread from)
 {
     from.stack.Push(from.getArg(ind));
 }
Пример #36
0
 public void Run(vThread from)
 {
     from.CALLSTATIC(method);
 }
Пример #37
0
 public void Run(vThread from)
 {
     from.getStack().Pop();
 }
Пример #38
0
 public void Run(vThread from)
 {
     from.getVM().Error(title, msg);
 }
Пример #39
0
 public void Run(vThread from)
 {
     from.Jmp(label);
 }
Пример #40
0
 public void Run(vThread from)
 {
     from.getStack().Push(Console.ReadLine());
 }
Пример #41
0
 internal void RestoreStack(vThread from)
 {
     from.stack = currentstack;
 }
Пример #42
0
 public void Run(vThread from)
 {
     from.getStack().Push(val);
 }
Пример #43
0
        public void Run(vThread from)
        {
            string to = from.stack.Pop() as string;
            object f = from.stack.Pop();
            object r = 0;

            if (f is string)
            {
                if (to == "string")
                {
                    r = f as string;
                }
                else if (to == "int")
                {
                    r = Convert.ToInt32(f as string);
                }
                else if (to == "double")
                {
                    r = Convert.ToDouble(f as string);
                }
                else if (to == "bool")
                {
                    r = Convert.ToBoolean(f as string);
                }
                else if (to == "char")
                {
                    char[] ca = (f as string).ToCharArray();
                    vArray a = new vArray(ca.Length, from);
                    object[] oa = new object[ca.Length];
                    for (int i = 0; i < ca.Length; i++)
                    {
                        oa[i] = (object)ca[i];
                    }
                    a.array = oa;
                    r = a;
                }
            }
            else if (f is int)
            {
                if (to == "string")
                {
                    r = Convert.ToString((int)f);
                }
                else if (to == "int")
                {
                    r = (int)f;
                }
                else if (to == "double")
                {
                    r = Convert.ToDouble((int)f);
                }
                else if (to == "bool")
                {
                    r = Convert.ToBoolean((int)f);
                }
                else if (to == "char")
                {
                    r = (char)((int)f);
                }
            }
            else if (f is double)
            {
                if (to == "string")
                {
                    r = Convert.ToString((double)f);
                }
                else if (to == "int")
                {
                    r = Convert.ToInt32((double)f);
                }
                else if (to == "double")
                {
                    r = (double)f;
                }
                else if (to == "bool")
                {
                    r = Convert.ToBoolean((double)f);
                }
                else if (to == "char")
                {
                    r = (char)(Convert.ToInt32((double)f));
                }
            }
            else if (f is bool)
            {
                if (to == "string")
                {
                    r = Convert.ToString((bool)f);
                }
                else if (to == "int")
                {
                    r = Convert.ToInt32((bool)f);
                }
                else if (to == "double")
                {
                    r = Convert.ToDouble((bool)f);
                }
                else if (to == "bool")
                {
                    r = (bool)f;
                }
                else if (to == "char")
                {
                    r = Convert.ToChar((bool)f);
                }
            }
            else if (f is char)
            {
                if (to == "string")
                {
                    r = Convert.ToString((char)f);
                }
                else if (to == "int")
                {
                    r = Convert.ToInt32((char)f);
                }
                else if (to == "double")
                {
                    r = Convert.ToDouble((char)f);
                }
                else if (to == "bool")
                {
                    r = Convert.ToBoolean((char)f);
                }
                else if (to == "char")
                {
                    r = (char)f;
                }
            }
            else if (f is vArray)
            {
                if (to == "string")
                {
                    r = ((vArray)f).CSTring();
                }
                else if (to == "int")
                {
                    r = ((vArray)f).CInt();
                }
                else if (to == "double")
                {
                    r = ((vArray)f).CDouble();
                }
                else if (to == "bool")
                {
                    r = ((vArray)f).CBool();
                }
                else if (to == "char")
                {
                    r = ((vArray)f).CChar();
                }
            }
            from.stack.Push(r);
        }
Пример #44
0
 public void Run(vThread from)
 {
     Console.WriteLine(from.getStack().Pop());
 }
Пример #45
0
 public void Run(vThread from)
 {
     string s = from.stack.Pop() as string;
     Console.Title = s;
 }
Пример #46
0
 public void Run(vThread from)
 {
     Console.Write(from.stack.Pop());
 }
Пример #47
0
 public void Run(vThread from)
 {
     from.stack.Push(from.parent.PopError());
 }
Пример #48
0
 internal void Run(vThread f)
 {
     f.instructionIndex = startaddress - 1;
 }
Пример #49
0
 public void Run(vThread from)
 {
     from.getStack().Push(Console.ReadLine());
 }
Пример #50
0
 public void Run(vThread from)
 {
     int len = (int)from.stack.Pop();
     vArray a = new vArray(len, from);
     from.stack.Push(a);
 }
Пример #51
0
 public vArray(int size, vThread parent)
 {
     array = new object[size];
     this.parent = parent;
 }
Пример #52
0
        public void Run(vThread from)
        {
            string s = from.stack.Pop() as string;

            Console.Title = s;
        }
Пример #53
0
 internal void Call(string p, vThread from)
 {
     vMethod m = getMethod(p);
     if (m != null)
     {
         vCall c = new vCall();
         c.referance = m;
         c.retaddress = from.instructionIndex;
         c.startaddress = m.GetAddress();
         from.callstack.Push(c);
         from.callstack.Peek().Run(from);
     }
 }
Пример #54
0
 public void Run(vThread from)
 {
     from.stack.Push(from.GetVar(name));
 }
Пример #55
0
 public void NewThread(string Name)
 {
     vThread t = new vThread(Name, this);
     t.startingInstruction = 0;
     threads.Add(t);
 }
Пример #56
0
 public void Run(vThread from)
 {
     from.getStack().Push(val);
 }
Пример #57
0
 internal Instance(vClass b, vThread p)
 {
     type = b;
     fields = new Dictionary<string, object>();
     parent = p;
 }
Пример #58
0
 public void Run(vThread from)
 {
     from.stack.Push(from.GetVar(name));
 }
Пример #59
0
 internal void SaveStack(vThread from)
 {
     currentstack = new Stack<object>(from.stack);
 }
Пример #60
0
 public void Run(vThread from)
 {
     Console.Write(from.stack.Pop());
 }