/// <summary>Perform one step forward and return the regular branch</summary> public static State SimpleStep_Forward(string line, State state) { if (state == null) { Console.WriteLine("WARNING: Runner:SimpleStep_Forward: provided state is null"); return(null); } try { Tools tools = state.Tools; string nextKey = Tools.CreateKey(tools.Rand); string nextKeyBranch = "DUMMY_NOT_USED"; (string Label, Mnemonic Mnemonic, string[] Args, string Remark)content = AsmSourceTools.ParseLine(line); using (OpcodeBase opcodeBase = InstantiateOpcode(content.Mnemonic, content.Args, (state.HeadKey, nextKey, nextKeyBranch), tools)) { if (opcodeBase == null) { return(null); } if (opcodeBase.IsHalted) { Console.WriteLine("WARNING: Runner:SimpleStep_Forward: line: " + line + " is halted. Message: " + opcodeBase.SyntaxError); return(null); } opcodeBase.Execute(); State stateOut = new State(state); stateOut.Update_Forward(opcodeBase.Updates.Regular); stateOut.Frozen = true; opcodeBase.Updates.Regular?.Dispose(); opcodeBase.Updates.Branch?.Dispose(); if (!tools.Quiet) { Console.WriteLine("INFO: Runner:SimpleStep_Forward: after \"" + line + "\" we know:"); } if (!tools.Quiet) { Console.WriteLine(stateOut); } return(stateOut); } } catch (Exception e) { Console.WriteLine("WARNING: Runner:SimpleStep_Forward: Exception at line: " + line + "; e=" + e.Message); return(new State(state)); } }
/// <summary>Perform one step forward and return states for both branches</summary> public static (State regular, State branch) Step_Forward(string line, State state) { Contract.Requires(state != null); try { string nextKey = Tools.CreateKey(state.Tools.Rand); string nextKeyBranch = nextKey + "!BRANCH"; (string label, Mnemonic mnemonic, string[] args, string remark)content = AsmSourceTools.ParseLine(line); using (OpcodeBase opcodeBase = InstantiateOpcode(content.mnemonic, content.args, (state.HeadKey, nextKey, nextKeyBranch), state.Tools)) { if (opcodeBase == null) { return(regular : null, branch : null); } if (opcodeBase.IsHalted) { return(regular : null, branch : null); } opcodeBase.Execute(); State stateRegular = null; if (opcodeBase.Updates.regular != null) { stateRegular = new State(state); stateRegular.Update_Forward(opcodeBase.Updates.regular); opcodeBase.Updates.regular.Dispose(); } State stateBranch = null; if (opcodeBase.Updates.branch != null) { stateBranch = new State(state); stateBranch.Update_Forward(opcodeBase.Updates.branch); opcodeBase.Updates.branch.Dispose(); } return(regular : stateRegular, branch : stateBranch); } } catch (Exception e) { Console.WriteLine("WARNING: Runner:Step_Forward: Exception at line: " + line + "; e=" + e.Message); return(regular : null, branch : null); } }