public static bool Invoke_Constructor(string name, parse_tree.parameter_list parameters) { int count = parse_tree_pkg.count_parameters(parameters); NClass.Core.ClassType theClass = Runtime.parent.projectCore.findClass(name); while (theClass != null) { foreach (NClass.Core.Operation op in theClass.Operations) { if (op is NClass.Core.Constructor) { if ((op as NClass.Core.Constructor).numberArguments == count) { Procedure_Chart sc = (op as NClass.Core.Constructor).raptorTab as Procedure_Chart; if (sc != null) { Runtime.Set_Running(sc); Runtime.Variable this_value = Runtime.getContext(); Runtime.setContext(null); // we stored the "this" parameter in the context // but need to set it to null before entering the // method Invoke_Tab_Procedure_Enter(parameters, sc, this_value); CallStack.setContext(Runtime.getContext()); return(true); } } } } theClass = theClass.BaseClass; } if (count == 0) { return(false); } else { throw new System.Exception("could not find constructor for " + name + " with " + count + " parameter(s)."); } }
public static void Invoke_Method(string name, parse_tree.parameter_list parameters) { Procedure_Chart sc = Runtime.Find_Method_Set_Running(name, parse_tree_pkg.count_parameters(parameters)); if (state == State_Enum.Entering) { Runtime.Variable this_value = Runtime.getContext(); Runtime.setContext(null); // we stored the "this" parameter in the context // but need to set it to null before entering the // method Invoke_Tab_Procedure_Enter(parameters, sc, this_value); // this used to be a call to getContext, but I'm not // at all sure why. CallStack.setContext(this_value); } else { Invoke_Tab_Procedure_Exit(parameters, sc); } }
internal static Component Step_Once(Component currentObj, Visual_Flow_Form form) { Component next; if (currentObj.need_to_decrease_scope) { Runtime.Decrease_Scope(); currentObj.need_to_decrease_scope = false; if (parse_tree_pkg.did_function_call) { if (Runtime.method_return_value != null) { currentObj.values.Add(Runtime.method_return_value); } Runtime.method_return_value = null; } } while (currentObj.number_method_expressions_run < currentObj.method_expressions.Count) { CallStack.Push(currentObj, (Subchart)form.running_tab); Step_Helpers.Set_State_Entering(); bool b = interpreter_pkg.run_expon( currentObj.method_expressions[currentObj.number_method_expressions_run] as parse_tree.expon, currentObj.Text, currentObj); currentObj.number_method_expressions_run++; if (b) { currentObj.need_to_decrease_scope = true; form.Possible_Tab_Update(form.running_tab); form.currentObj = ((Subchart)form.running_tab).Start; form.currentObj.running = true; return(form.currentObj); } else { CallStack.Pop(); } } if (currentObj.Name == "Oval") { if (currentObj.Successor != null) { next = currentObj.Successor.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { return(null); } } else if (currentObj.Name == "Return") { numbers.value v = interpreter_pkg.run_return_value(currentObj.parse_tree, currentObj.Text); Runtime.method_return_value = v; return(null); } else if (currentObj.Name == "Rectangle") { // when running belownormal, upgrade priority to close graphics window if (currentObj.Text.ToLower() == "close_graph_window") { System.Threading.ThreadPriority p = System.Threading.Thread.CurrentThread.Priority; System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.AboveNormal; interpreter_pkg.run_assignment(currentObj.parse_tree, currentObj.Text); System.Threading.Thread.CurrentThread.Priority = p; } else { interpreter_pkg.run_assignment(currentObj.parse_tree, currentObj.Text); } next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } else if (currentObj.Name == "IF_Control") { bool choice = interpreter_pkg.run_boolean( currentObj.parse_tree, currentObj.Text); if (choice == true) { // go to left child if possible, otherwise // go to the successor of the if if (((IF_Control)currentObj).yes_child != null) { next = ((IF_Control)currentObj). yes_child.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } } else { if (((IF_Control)currentObj).no_child != null) { next = ((IF_Control)currentObj). no_child.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } } } else if (currentObj.Name == "Parallelogram") { if (((Parallelogram)currentObj).is_input) { interpreter_pkg.run_input(currentObj.parse_tree, currentObj.Text, ((Parallelogram)currentObj).prompt, ((Parallelogram)currentObj).input_is_expression, ((Parallelogram)currentObj).prompt_tree); } else { interpreter_pkg.run_output(currentObj.parse_tree, currentObj.Text); } next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } else if ((currentObj.Name == "Loop") && (((Loop)currentObj).light_head)) { ((Loop)currentObj).light_head = false; if (((Loop)currentObj).before_Child != null) { next = ((Loop)currentObj).before_Child.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { return(currentObj); } } else if (currentObj.Name == "Loop") { bool choice = interpreter_pkg.run_boolean( currentObj.parse_tree, currentObj.Text); // keep going on yes if loop logic reversed, no if not if ((!choice && !Component.reverse_loop_logic) || (choice && Component.reverse_loop_logic)) { // on false, go to first of after_child if // we can, otherwise back to the top of the loop! if (((Loop)currentObj).after_Child != null) { next = ((Loop)currentObj).after_Child.First_Of(); next.reset_this_method_expressions_run(); return(next); } else { next = currentObj.First_Of(); next.reset_this_method_expressions_run(); return(next); } } else { // on true, go to successor of loop next = Find_Successor(currentObj); next.reset_this_method_expressions_run(); return(next); } } else { throw new System.Exception("unrecognized object: " + currentObj.Name); } }