public int YieldToCurrentContinuation() { RuntimeLabel label = this.Interpreter._labels[this._continuations[this._continuationIndex - 1]]; this.SetStackDepth(label.StackDepth); return(label.Index - this.InstructionIndex); }
static InstructionList() { InstructionList._loadFields = new Dictionary <FieldInfo, Instruction>(); InstructionList._factories = new Dictionary <Type, Func <CallSiteBinder, Instruction> >(); RuntimeLabel[] runtimeLabel = new RuntimeLabel[1]; runtimeLabel[0] = new RuntimeLabel(0x7fffffff, 0, 0); InstructionList.EmptyRuntimeLabels = runtimeLabel; }
internal InstructionArray(int maxStackDepth, int maxContinuationDepth, Instruction[] instructions, object[] objects, RuntimeLabel[] labels, List<KeyValuePair<int, object>> debugCookies) { this.MaxStackDepth = maxStackDepth; this.MaxContinuationDepth = maxContinuationDepth; this.Instructions = instructions; this.DebugCookies = debugCookies; this.Objects = objects; this.Labels = labels; }
public int Goto(int labelIndex, object value, bool gotoExceptionHandler) { RuntimeLabel label = this.Interpreter._labels[labelIndex]; if (this._continuationIndex == label.ContinuationStackDepth) { this.SetStackDepth(label.StackDepth); if (value != System.Management.Automation.Interpreter.Interpreter.NoValue) { this.Data[this.StackIndex - 1] = value; } return(label.Index - this.InstructionIndex); } this._pendingContinuation = labelIndex; this._pendingValue = value; return(this.YieldToCurrentContinuation()); }
public int YieldToPendingContinuation() { RuntimeLabel label = this.Interpreter._labels[this._pendingContinuation]; if (label.ContinuationStackDepth < this._continuationIndex) { RuntimeLabel label2 = this.Interpreter._labels[this._continuations[this._continuationIndex - 1]]; this.SetStackDepth(label2.StackDepth); return(label2.Index - this.InstructionIndex); } this.SetStackDepth(label.StackDepth); if (this._pendingValue != System.Management.Automation.Interpreter.Interpreter.NoValue) { this.Data[this.StackIndex - 1] = this._pendingValue; } this._pendingContinuation = -1; this._pendingValue = System.Management.Automation.Interpreter.Interpreter.NoValue; return(label.Index - this.InstructionIndex); }
private RuntimeLabel[] BuildRuntimeLabels() { if (_runtimeLabelCount == 0) { return(s_emptyRuntimeLabels); } var result = new RuntimeLabel[_runtimeLabelCount + 1]; foreach (BranchLabel label in _labels) { if (label.HasRuntimeLabel) { result[label.LabelIndex] = label.ToRuntimeLabel(); } } // "return and rethrow" label: result[result.Length - 1] = new RuntimeLabel(Interpreter.RethrowOnReturn, 0, 0); return(result); }
private RuntimeLabel[] BuildRuntimeLabels() { if (this._runtimeLabelCount != 0) { RuntimeLabel[] runtimeLabel = new RuntimeLabel[this._runtimeLabelCount + 1]; foreach (BranchLabel _label in this._labels) { if (!_label.HasRuntimeLabel) { continue; } runtimeLabel[_label.LabelIndex] = _label.ToRuntimeLabel(); } runtimeLabel[(int)runtimeLabel.Length - 1] = new RuntimeLabel(0x7fffffff, 0, 0); return(runtimeLabel); } else { return(InstructionList.EmptyRuntimeLabels); } }
public int Goto(int labelIndex, object value, bool gotoExceptionHandler) { // TODO: we know this at compile time (except for compiled loop): RuntimeLabel target = Interpreter._labels[labelIndex]; Debug.Assert(!gotoExceptionHandler || (gotoExceptionHandler && _continuationIndex == target.ContinuationStackDepth), "When it's time to jump to the exception handler, all previous finally blocks should already be processed"); if (_continuationIndex == target.ContinuationStackDepth) { SetStackDepth(target.StackDepth); if (value != Interpreter.NoValue) { Data[StackIndex - 1] = value; } return(target.Index - InstructionIndex); } // if we are in the middle of executing jump we forget the previous target and replace it by a new one: _pendingContinuation = labelIndex; _pendingValue = value; return(YieldToCurrentContinuation()); }
/// <summary> /// Get called from the LeaveFinallyInstruction /// </summary> public int YieldToPendingContinuation() { Debug.Assert(_pendingContinuation >= 0); RuntimeLabel pendingTarget = Interpreter._labels[_pendingContinuation]; // the current continuation might have higher priority (continuationIndex is the depth of the current continuation): if (pendingTarget.ContinuationStackDepth < _continuationIndex) { RuntimeLabel currentTarget = Interpreter._labels[_continuations[_continuationIndex - 1]]; SetStackDepth(currentTarget.StackDepth); return(currentTarget.Index - InstructionIndex); } SetStackDepth(pendingTarget.StackDepth); if (_pendingValue != Interpreter.NoValue) { Data[StackIndex - 1] = _pendingValue; } // Set the _pendingContinuation and _pendingValue to the default values if we finally gets to the Goto target _pendingContinuation = -1; _pendingValue = Interpreter.NoValue; return(pendingTarget.Index - InstructionIndex); }