Exemple #1
0
        public void NewThread(string Name)
        {
            vThread t = new vThread(Name, this);

            t.startingInstruction = 0;
            threads.Add(t);
        }
Exemple #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]);
        }
Exemple #3
0
        public void Run(vThread from)
        {
            int    len = (int)from.stack.Pop();
            vArray a   = new vArray(len, from);

            from.stack.Push(a);
        }
Exemple #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;
 }
Exemple #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;
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
         }
     }
 }
Exemple #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());
         }
     }
 }
Exemple #10
0
 public void Run(vThread from)
 {
     if (from.callstack.Count > 0)
     {
         from.instructionIndex = from.callstack.Pop().retaddress;
         from.RestoreGlobalVars();
     }
     else
     {
         from.End();
     }
 }
Exemple #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));
                }
            }
        }
Exemple #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));
                }
            }
        }
Exemple #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);
        }
Exemple #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);
            }
        }
Exemple #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");
            }
        }
Exemple #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");
            }
        }
Exemple #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);
            }
        }
Exemple #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);
            }
        }
Exemple #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);
            }
        }
Exemple #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);
            }
        }
Exemple #21
0
 internal void AddThread(vThread t)
 {
     threads.Add(t);
 }
Exemple #22
0
 public void Run(vThread from)
 {
     Instance i = from.GetClass(type).CreateInstance(from);
     from.getStack().Push(i);
 }
Exemple #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;
 }
Exemple #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);
         }
     }
 }
Exemple #25
0
 public void Run(vThread from)
 {
     Console.WriteLine(from.getStack().Pop());
 }
Exemple #26
0
 public void Run(vThread from)
 {
     from.callstack.Peek().getMethod().RestoreStack(from);
 }
Exemple #27
0
 public void Run(vThread from)
 {
     from.CALL(method);
     from.End();
 }
Exemple #28
0
 public void Run(vThread from)
 {
     from.stack.Push(from.parent.PopError());
 }
Exemple #29
0
 public void Run(vThread from)
 {
     from.getVM().Error(title, msg);
 }
Exemple #30
0
 public void Run(vThread from)
 {
     from.getStack().Pop();
 }
Exemple #31
0
 public void Run(vThread from)
 {
 }
Exemple #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]);
 }
Exemple #33
0
 public void Run(vThread from)
 {
     from.Interupt(n);
 }
Exemple #34
0
 public void Run(vThread from)
 {
     from.Jmp(label);
 }
Exemple #35
0
 public void Run(vThread from)
 {
     from.stack.Push(from.getArg(ind));
 }
Exemple #36
0
 public void Run(vThread from)
 {
     from.CALLSTATIC(method);
 }
Exemple #37
0
 public void Run(vThread from)
 {
     from.getStack().Pop();
 }
Exemple #38
0
 public void Run(vThread from)
 {
     from.getVM().Error(title, msg);
 }
Exemple #39
0
 public void Run(vThread from)
 {
     from.Jmp(label);
 }
Exemple #40
0
 public void Run(vThread from)
 {
     from.getStack().Push(Console.ReadLine());
 }
Exemple #41
0
 internal void RestoreStack(vThread from)
 {
     from.stack = currentstack;
 }
Exemple #42
0
 public void Run(vThread from)
 {
     from.getStack().Push(val);
 }
Exemple #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);
        }
Exemple #44
0
 public void Run(vThread from)
 {
     Console.WriteLine(from.getStack().Pop());
 }
Exemple #45
0
 public void Run(vThread from)
 {
     string s = from.stack.Pop() as string;
     Console.Title = s;
 }
Exemple #46
0
 public void Run(vThread from)
 {
     Console.Write(from.stack.Pop());
 }
Exemple #47
0
 public void Run(vThread from)
 {
     from.stack.Push(from.parent.PopError());
 }
Exemple #48
0
 internal void Run(vThread f)
 {
     f.instructionIndex = startaddress - 1;
 }
Exemple #49
0
 public void Run(vThread from)
 {
     from.getStack().Push(Console.ReadLine());
 }
Exemple #50
0
 public void Run(vThread from)
 {
     int len = (int)from.stack.Pop();
     vArray a = new vArray(len, from);
     from.stack.Push(a);
 }
Exemple #51
0
 public vArray(int size, vThread parent)
 {
     array = new object[size];
     this.parent = parent;
 }
Exemple #52
0
        public void Run(vThread from)
        {
            string s = from.stack.Pop() as string;

            Console.Title = s;
        }
Exemple #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);
     }
 }
Exemple #54
0
 public void Run(vThread from)
 {
     from.stack.Push(from.GetVar(name));
 }
Exemple #55
0
 public void NewThread(string Name)
 {
     vThread t = new vThread(Name, this);
     t.startingInstruction = 0;
     threads.Add(t);
 }
Exemple #56
0
 public void Run(vThread from)
 {
     from.getStack().Push(val);
 }
Exemple #57
0
 internal Instance(vClass b, vThread p)
 {
     type = b;
     fields = new Dictionary<string, object>();
     parent = p;
 }
Exemple #58
0
 public void Run(vThread from)
 {
     from.stack.Push(from.GetVar(name));
 }
Exemple #59
0
 internal void SaveStack(vThread from)
 {
     currentstack = new Stack<object>(from.stack);
 }
Exemple #60
0
 public void Run(vThread from)
 {
     Console.Write(from.stack.Pop());
 }