static void RunRepl() { WrenVM vm = new WrenVM(); LibraryLoader.LoadLibraries(vm); Console.WriteLine("-- wren v0.0.0"); string line = ""; for (; ;) { Console.Write("> "); line += Console.ReadLine() + "\n"; if (OpenBrackets(line) > 0) { continue; } // TODO: Handle failure. vm.Interpret("Prompt", "Prompt", line); line = ""; } }
static void RunRepl() { WrenVM vm = new WrenVM(null, null); LibraryLoader.LoadLibraries(vm); WrenScript.LoadLibrary <ScriptTest>(vm); Console.WriteLine("-- wren v0.0.0"); string line = ""; for (; ;) { Console.Write("> "); line += Console.ReadLine() + "\n"; if (OpenBrackets(line) > 0) { continue; } // TODO: Handle failure. var result = new WrenVM.ResultRef(); var coroutine = vm.InterpretCoroutines("Prompt", "Prompt", line, result); // quick and dirty sim of unity's coroutines Stack <IEnumerator> stack = new Stack <IEnumerator>(); stack.Push(coroutine); while (stack.Count > 0) { if (!stack.Peek().MoveNext()) { stack.Pop(); } else { if (stack.Peek().Current is IEnumerator) { stack.Push(stack.Peek().Current as IEnumerator); } else { Console.WriteLine("yielded " + stack.Peek().Current); } } } line = ""; } }
static int RunFile(string path) { if (!File.Exists(path)) { return(66); // File Not Found } _loadedFile = path; string source = File.ReadAllText(path); WrenVM vm = new WrenVM { LoadModuleFn = LoadModule }; LibraryLoader.LoadLibraries(vm); return((int)vm.Interpret("main", path, source)); }
private void LoadLibraries() { //Clear out menuItems from before menuButtonItem3.Items.Clear(); //Initialize our Library_Loader Library_Loader = new LibraryLoader(); //Initialize our Library List Library_Loader.Libraries = new List <LibraryLoader.LibraryClass>(); //Load our Libraries Library_Loader.LoadLibraries(Application.StartupPath + "\\Libraries\\"); //Loop through the Libraries foreach (LibraryLoader.LibraryClass Alteration_Library in Library_Loader.Libraries) { #region Determine Valid For this Tag bool invalidForThisTag = false; if (Alteration_Library.Library.TagClassFilter != "") { if (tvMetaTree.SelectedNode == null) { invalidForThisTag = true; } else { if (tvMetaTree.SelectedNode.Parent == null) { invalidForThisTag = true; } else { List <string> tagClasses = new List <string>(Alteration_Library.Library.TagClassFilter.Split(',')); if (tagClasses.Contains(tvMetaTree.SelectedNode.Parent.Tag.ToString()) == false && Alteration_Library.Library.TagClassFilter != "") { invalidForThisTag = true; } } } } //If the library isn't for this tag.. if (invalidForThisTag) { //Set the tag to be null Alteration_Library.Library.Selected_Tag_Index = -1; //Load the next library goto NextLibrary; } #endregion try { //Set our instance of the selected tag Alteration_Library.Library.Selected_Tag_Index = Map.GetTagIndexByClassAndName(tvMetaTree.SelectedNode.Parent.Tag.ToString(), tvMetaTree.SelectedNode.Text); } catch { //If it errored, the set our instance of a null Alteration_Library.Library.Selected_Tag_Index = -1; } //Set the instance of the map Alteration_Library.Library.Map_Location = Map.FileName; //Add the menu item for it using the Library Name menuButtonItem3.Items.Add(Alteration_Library.Library.LibraryName); //Set the function for when it is activated menuButtonItem3.Items[menuButtonItem3.Items.Count - 1].Activate += Library_Activate; //Set our EntryPoint for the next Library NextLibrary: ; } }