public void NewThread(string Name) { vThread t = new vThread(Name, this); t.startingInstruction = 0; threads.Add(t); }
public void Run(vThread from) { vArray array = from.getArg(0) as vArray; int index = (int)from.getArg(1); from.stack.Push(array.array[index]); }
public void Run(vThread from) { int len = (int)from.stack.Pop(); vArray a = new vArray(len, from); from.stack.Push(a); }
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; }
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); }
internal Instance CreateInstance(vThread p) { Instance i = new Instance(this, p); foreach (Field str in fields) { i.AddVar(str.name, null); } return(i); }
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); } } }
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()); } } }
public void Run(vThread from) { if (from.callstack.Count > 0) { from.instructionIndex = from.callstack.Pop().retaddress; from.RestoreGlobalVars(); } else { from.End(); } }
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)); } } }
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)); } } }
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); }
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); } }
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"); } }
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); } }
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); } }
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); } }
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); } }
internal void AddThread(vThread t) { threads.Add(t); }
public void Run(vThread from) { Instance i = from.GetClass(type).CreateInstance(from); from.getStack().Push(i); }
internal Instance CreateInstance(vThread p) { Instance i = new Instance(this,p); foreach (Field str in fields) { i.AddVar(str.name, null); } return i; }
public void Run(vThread from) { Console.WriteLine(from.getStack().Pop()); }
public void Run(vThread from) { from.callstack.Peek().getMethod().RestoreStack(from); }
public void Run(vThread from) { from.CALL(method); from.End(); }
public void Run(vThread from) { from.stack.Push(from.parent.PopError()); }
public void Run(vThread from) { from.getVM().Error(title, msg); }
public void Run(vThread from) { from.getStack().Pop(); }
public void Run(vThread from) { }
public void Run(vThread from) { from.Interupt(n); }
public void Run(vThread from) { from.Jmp(label); }
public void Run(vThread from) { from.stack.Push(from.getArg(ind)); }
public void Run(vThread from) { from.CALLSTATIC(method); }
public void Run(vThread from) { from.getStack().Push(Console.ReadLine()); }
internal void RestoreStack(vThread from) { from.stack = currentstack; }
public void Run(vThread from) { from.getStack().Push(val); }
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); }
public void Run(vThread from) { string s = from.stack.Pop() as string; Console.Title = s; }
public void Run(vThread from) { Console.Write(from.stack.Pop()); }
internal void Run(vThread f) { f.instructionIndex = startaddress - 1; }
public vArray(int size, vThread parent) { array = new object[size]; this.parent = parent; }
public void Run(vThread from) { from.stack.Push(from.GetVar(name)); }
internal Instance(vClass b, vThread p) { type = b; fields = new Dictionary<string, object>(); parent = p; }
internal void SaveStack(vThread from) { currentstack = new Stack<object>(from.stack); }