bool StepVm() { if (this.IsLive ()) { this.CheckVmWithoutError (); this.CheckQuotas (); try { var instruction = this.CurrentInstruction(); //TraceInstruction(instruction); Vm.handlers[instruction.NumericOpcode](this); this.executedTicks++; this.executedTicksSinceLastNap++; return true; } catch (ShovelException ex) { this.programmingError = ex; throw; } } else { return false; } }
void RaiseErrorAt(string message, int? startPosition, int? endPosition) { Position pos = startPosition != null ? this.GetPosition(startPosition.Value) : null; string fileName = pos != null ? pos.FileName : null; bool atEof = startPosition == null && endPosition == null; string errorMessage; if (pos != null) { var startPos = pos; var endPos = this.GetPosition(endPosition.Value); var lines = Utils.ExtractRelevantSource(GetSourceFile().Content.Split('\n'), startPos, endPos); errorMessage = String.Format("{0}\n{1}\n{2}", message, lines[0], lines[1]); } else { errorMessage = message; } var error = new ShovelException(); error.ShovelMessage = errorMessage; if (pos != null) { error.Line = pos.Line; error.Column = pos.Column; } else { error.AtEof = atEof; } error.FileName = fileName; throw error; }
void RaiseError(string message) { var token = this.CurrentToken (); Position pos = token != null ? this.GetPosition (token.StartPos) : null; string fileName = pos != null ? pos.FileName : null; bool atEof = token == null; string errorMessage; if (pos != null) { var startPos = pos; var endPos = this.GetPosition (token.EndPos); var lines = Utils.ExtractRelevantSource (GetSourceFile ().Content.Split ('\n'), startPos, endPos); errorMessage = String.Format ("{0}\n{1}\n{2}", message, lines [0], lines [1]); } else { errorMessage = message; } var error = new ShovelException (); error.Message = errorMessage; if (pos != null) { error.Line = pos.Line; error.Column = pos.Column; } else { error.AtEof = atEof; } error.FileName = fileName; throw error; }
bool StepVm() { if (this.IsLive ()) { this.CheckVmWithoutError (); this.CheckQuotas (); try { if (this.runs [this.programCounter] == null) { this.runs [this.programCounter] = this.GenRun (); } this.runs [this.programCounter] (this); // var instruction = this.CurrentInstruction (); // Console.WriteLine ("*****"); // Console.WriteLine (instruction.ToString ()); // for (var i = 0; i < this.stack.Count; i++) { // Console.WriteLine (DumpShovelValue (this.api, this.stack.Storage [i])); // } // Vm.handlers [instruction.NumericOpcode] (this); return true; } catch (ShovelException ex) { this.programmingError = ex; throw; } } else { return false; } }