コード例 #1
0
 public override int Run(InterpretedFrame frame)
 {
     object obj2 = frame.Pop();
     object obj3 = frame.Pop();
     frame.Push(ScriptingRuntimeHelpers.BooleanToObject((obj3 != null) && (obj3.GetType() == obj2)));
     return 1;
 }
コード例 #2
0
ファイル: FieldOperations.cs プロジェクト: 40a/PowerShell
 public override int Run(InterpretedFrame frame)
 {
     object value = frame.Pop();
     object self = frame.Pop();
     _field.SetValue(self, value);
     return +1;
 }
コード例 #3
0
 public override int Run(InterpretedFrame frame)
 {
     int index = frame.StackIndex - this._argumentCount;
     frame.Data[index] = this._site.Target(this._site, new ArgumentArray(frame.Data, index, this._argumentCount));
     frame.StackIndex = index + 1;
     return 1;
 }
コード例 #4
0
 public override int Run(InterpretedFrame frame)
 {
     object obj2 = frame.Pop();
     object obj3 = frame.Pop();
     this._field.SetValue(obj3, obj2);
     return 1;
 }
コード例 #5
0
ファイル: InterpretedFrame.cs プロジェクト: nickchal/pash
 internal System.Management.Automation.Interpreter.ThreadLocal<InterpretedFrame>.StorageInfo Enter()
 {
     var storageInfo = CurrentFrame.GetStorageInfo();
     this._parent = storageInfo.Value;
     storageInfo.Value = this;
     return storageInfo;
 }
コード例 #6
0
ファイル: SubInstruction.cs プロジェクト: 40a/PowerShell
 public override int Run(InterpretedFrame frame)
 {
     object l = frame.Data[frame.StackIndex - 2];
     object r = frame.Data[frame.StackIndex - 1];
     frame.Data[frame.StackIndex - 2] = ScriptingRuntimeHelpers.Int32ToObject(unchecked((Int32)l - (Int32)r));
     frame.StackIndex--;
     return +1;
 }
コード例 #7
0
ファイル: SubInstruction.cs プロジェクト: 40a/PowerShell
 public override int Run(InterpretedFrame frame)
 {
     object l = frame.Data[frame.StackIndex - 2];
     object r = frame.Data[frame.StackIndex - 1];
     frame.Data[frame.StackIndex - 2] = (UInt32)unchecked((UInt32)l - (UInt32)r);
     frame.StackIndex--;
     return +1;
 }
コード例 #8
0
ファイル: AddOvfInstruction.cs プロジェクト: nickchal/pash
 public override int Run(InterpretedFrame frame)
 {
     object obj2 = frame.Data[frame.StackIndex - 2];
     object obj3 = frame.Data[frame.StackIndex - 1];
     frame.Data[frame.StackIndex - 2] = ((double) obj2) + ((double) obj3);
     frame.StackIndex--;
     return 1;
 }
コード例 #9
0
ファイル: MulOvfInstruction.cs プロジェクト: nickchal/pash
 public override int Run(InterpretedFrame frame)
 {
     object obj2 = frame.Data[frame.StackIndex - 2];
     object obj3 = frame.Data[frame.StackIndex - 1];
     frame.Data[frame.StackIndex - 2] = (short) (((short) obj2) * ((short) obj3));
     frame.StackIndex--;
     return 1;
 }
コード例 #10
0
 public override int Run(InterpretedFrame frame)
 {
     if ((bool) frame.Pop())
     {
         return base._offset;
     }
     return 1;
 }
コード例 #11
0
ファイル: DivInstruction.cs プロジェクト: 40a/PowerShell
 public override int Run(InterpretedFrame frame)
 {
     object l = frame.Data[frame.StackIndex - 2];
     object r = frame.Data[frame.StackIndex - 1];
     frame.Data[frame.StackIndex - 2] = (UInt16)((UInt16)l / (UInt16)r);
     frame.StackIndex--;
     return 1;
 }
コード例 #12
0
 public override int Run(InterpretedFrame frame)
 {
     if (frame.Peek() != null)
     {
         return base._offset;
     }
     return 1;
 }
コード例 #13
0
 internal int GotoHandler(InterpretedFrame frame, object exception, out ExceptionHandler handler)
 {
     handler = this._handlers.FirstOrDefault<ExceptionHandler>(t => t.Matches(exception.GetType()));
     if (handler == null)
     {
         return 0;
     }
     return frame.Goto(handler.LabelIndex, exception, true);
 }
コード例 #14
0
ファイル: ThrowInstruction.cs プロジェクト: nickchal/pash
 public override int Run(InterpretedFrame frame)
 {
     Exception exception = (Exception) frame.Pop();
     if (this._rethrow)
     {
         throw new RethrowException();
     }
     throw exception;
 }
コード例 #15
0
ファイル: SwitchInstruction.cs プロジェクト: nickchal/pash
 public override int Run(InterpretedFrame frame)
 {
     int num;
     if (!this._cases.TryGetValue((int) frame.Pop(), out num))
     {
         return 1;
     }
     return num;
 }
コード例 #16
0
 public override int Run(InterpretedFrame frame)
 {
     frame.PopPendingContinuation();
     if (!frame.IsJumpHappened())
     {
         return 1;
     }
     return frame.YieldToPendingContinuation();
 }
コード例 #17
0
        public override int Run(InterpretedFrame frame)
        {
            int first = frame.StackIndex - _argumentCount;
            object ret = _site.Target(_site, new ArgumentArray(frame.Data, first, _argumentCount));
            frame.Data[first] = ret;
            frame.StackIndex = first + 1;

            return 1;
        }
コード例 #18
0
 public override int Run(InterpretedFrame frame)
 {
     IStrongBox[] boxes = new IStrongBox[this._count];
     for (int i = boxes.Length - 1; i >= 0; i--)
     {
         boxes[i] = (IStrongBox) frame.Pop();
     }
     frame.Push(System.Management.Automation.Interpreter.RuntimeVariables.Create(boxes));
     return 1;
 }
コード例 #19
0
ファイル: Interpreter.cs プロジェクト: nickchal/pash
 public void Run(InterpretedFrame frame)
 {
     Instruction[] instructions = this._instructions.Instructions;
     int instructionIndex = frame.InstructionIndex;
     while (instructionIndex < instructions.Length)
     {
         instructionIndex += instructions[instructionIndex].Run(frame);
         frame.InstructionIndex = instructionIndex;
     }
 }
コード例 #20
0
 public override int Run(InterpretedFrame frame)
 {
     if (!frame.IsJumpHappened())
     {
         frame.SetStackDepth(base.GetLabel(frame).StackDepth);
     }
     frame.PushPendingContinuation();
     frame.RemoveContinuation();
     return 1;
 }
コード例 #21
0
 public override int Run(InterpretedFrame frame)
 {
     int[] lengths = new int[this._rank];
     for (int i = this._rank - 1; i >= 0; i--)
     {
         lengths[i] = (int) frame.Pop();
     }
     Array array = Array.CreateInstance(this._elementType, lengths);
     frame.Push(array);
     return 1;
 }
コード例 #22
0
        public override int Run(InterpretedFrame frame)
        {
            Debug.Assert(_offset != Unknown);

            if (!(bool)frame.Pop())
            {
                return _offset;
            }

            return +1;
        }
コード例 #23
0
 public override int Run(InterpretedFrame frame)
 {
     FunctionContext functionContext = frame.FunctionContext;
     ExecutionContext executionContext = frame.ExecutionContext;
     functionContext._currentSequencePointIndex = this._sequencePoint;
     if (this._checkBreakpoints && (executionContext._debuggingMode > 0))
     {
         executionContext.Debugger.OnSequencePointHit(functionContext);
     }
     return 1;
 }
コード例 #24
0
ファイル: Interpreter.cs プロジェクト: nickchal/pash
 internal static void AbortThreadIfRequested(InterpretedFrame frame, int targetLabelIndex)
 {
     ExceptionHandler currentAbortHandler = frame.CurrentAbortHandler;
     int index = frame.Interpreter._labels[targetLabelIndex].Index;
     if (((currentAbortHandler != null) && !currentAbortHandler.IsInsideCatchBlock(index)) && !currentAbortHandler.IsInsideFinallyBlock(index))
     {
         frame.CurrentAbortHandler = null;
         Thread currentThread = Thread.CurrentThread;
         if ((currentThread.ThreadState & ThreadState.AbortRequested) != ThreadState.Running)
         {
             currentThread.Abort(AnyAbortException.ExceptionState);
         }
     }
 }
コード例 #25
0
ファイル: EnterLoopInstruction.cs プロジェクト: nickchal/pash
 public override int Run(InterpretedFrame frame)
 {
     if (this._compilationThreshold-- == 0)
     {
         if (frame.Interpreter.CompileSynchronously)
         {
             this.Compile(frame);
         }
         else
         {
             ThreadPool.QueueUserWorkItem(new WaitCallback(this.Compile), frame);
         }
     }
     return 1;
 }
コード例 #26
0
 public override int Run(InterpretedFrame frame)
 {
     StrongBox<object>[] boxArray;
     if (this.ConsumedStack > 0)
     {
         boxArray = new StrongBox<object>[this.ConsumedStack];
         for (int i = boxArray.Length - 1; i >= 0; i--)
         {
             boxArray[i] = (StrongBox<object>) frame.Pop();
         }
     }
     else
     {
         boxArray = null;
     }
     Delegate delegate2 = this._creator.CreateDelegate(boxArray);
     frame.Push(delegate2);
     return 1;
 }
コード例 #27
0
ファイル: NewInstruction.cs プロジェクト: nickchal/pash
 public override int Run(InterpretedFrame frame)
 {
     object obj2;
     object[] parameters = new object[this._argCount];
     for (int i = this._argCount - 1; i >= 0; i--)
     {
         parameters[i] = frame.Pop();
     }
     try
     {
         obj2 = this._constructor.Invoke(parameters);
     }
     catch (TargetInvocationException exception)
     {
         ExceptionHelpers.UpdateForRethrow(exception.InnerException);
         throw exception.InnerException;
     }
     frame.Push(obj2);
     return 1;
 }
コード例 #28
0
ファイル: DynamicInstructionN.cs プロジェクト: 40a/PowerShell
        public override int Run(InterpretedFrame frame)
        {
            int first = frame.StackIndex - _argumentCount;
            object[] args = new object[1 + _argumentCount];
            args[0] = _site;
            for (int i = 0; i < _argumentCount; i++)
            {
                args[1 + i] = frame.Data[first + i];
            }

            object ret = _target.InvokeInstance(_targetDelegate, args);
            if (_isVoid)
            {
                frame.StackIndex = first;
            }
            else
            {
                frame.Data[first] = ret;
                frame.StackIndex = first + 1;
            }

            return 1;
        }
コード例 #29
0
        public override int Run(InterpretedFrame frame)
        {
            int target;

            return(_cases.TryGetValue((int)frame.Pop(), out target) ? target : 1);
        }
コード例 #30
0
 public override int Run(InterpretedFrame frame)
 {
     // nop (the exception value is pushed by the interpreter in HandleCatch)
     return(1);
 }
コード例 #31
0
 public override int Run(InterpretedFrame frame)
 {
     // CLR rethrows ThreadAbortException when leaving catch handler if abort is requested on the current thread.
     Interpreter.AbortThreadIfRequested(frame, _labelIndex);
     return(GetLabel(frame).Index - frame.InstructionIndex);
 }
コード例 #32
0
 public RuntimeLabel GetLabel(InterpretedFrame frame)
 {
     Debug.Assert(_labelIndex != UnknownInstrIndex);
     return(frame.Interpreter._labels[_labelIndex]);
 }
コード例 #33
0
        public override int Run(InterpretedFrame frame)
        {
            Debug.Assert(_tryHandler != null, "the tryHandler must be set already");

            if (_hasFinally)
            {
                // Push finally.
                frame.PushContinuation(_labelIndex);
            }
            int prevInstrIndex = frame.InstructionIndex;

            frame.InstructionIndex++;

            // Start to run the try/catch/finally blocks
            var instructions = frame.Interpreter.Instructions.Instructions;

            try
            {
                // run the try block
                int index = frame.InstructionIndex;
                while (index >= _tryHandler.TryStartIndex && index < _tryHandler.TryEndIndex)
                {
                    index += instructions[index].Run(frame);
                    frame.InstructionIndex = index;
                }

                // we finish the try block and is about to jump out of the try/catch blocks
                if (index == _tryHandler.GotoEndTargetIndex)
                {
                    // run the 'Goto' that jumps out of the try/catch/finally blocks
                    Debug.Assert(instructions[index] is GotoInstruction, "should be the 'Goto' instruction that jumps out the try/catch/finally");
                    frame.InstructionIndex += instructions[index].Run(frame);
                }
            }
            catch (RethrowException)
            {
                // a rethrow instruction in the try handler gets to run
                throw;
            }
            catch (Exception exception)
            {
                frame.SaveTraceToException(exception);
                // rethrow if there is no catch blocks defined for this try block
                if (!_tryHandler.IsCatchBlockExist)
                {
                    throw;
                }

                // Search for the best handler in the TryCatchFinally block. If no suitable handler is found, rethrow
                ExceptionHandler exHandler;
                frame.InstructionIndex += _tryHandler.GotoHandler(frame, exception, out exHandler);
                if (exHandler == null)
                {
                    throw;
                }
#if !CORECLR // Thread.Abort and ThreadAbortException are not in CoreCLR.
                // stay in the current catch so that ThreadAbortException is not rethrown by CLR:
                var abort = exception as ThreadAbortException;
                if (abort != null)
                {
                    Interpreter.AnyAbortException = abort;
                    frame.CurrentAbortHandler     = exHandler;
                }
#endif
                bool rethrow = false;
                try
                {
                    // run the catch block
                    int index = frame.InstructionIndex;
                    while (index >= exHandler.HandlerStartIndex && index < exHandler.HandlerEndIndex)
                    {
                        index += instructions[index].Run(frame);
                        frame.InstructionIndex = index;
                    }

                    // we finish the catch block and is about to jump out of the try/catch blocks
                    if (index == _tryHandler.GotoEndTargetIndex)
                    {
                        // run the 'Goto' that jumps out of the try/catch/finally blocks
                        Debug.Assert(instructions[index] is GotoInstruction, "should be the 'Goto' instruction that jumps out the try/catch/finally");
                        frame.InstructionIndex += instructions[index].Run(frame);
                    }
                }
                catch (RethrowException)
                {
                    // a rethrow instruction in a catch block gets to run
                    rethrow = true;
                }

                if (rethrow)
                {
                    throw;
                }
            }
            finally
            {
                if (_tryHandler.IsFinallyBlockExist)
                {
                    // We get to the finally block in two paths:
                    //  1. Jump from the try/catch blocks. This includes two sub-routes:
                    //        a. 'Goto' instruction in the middle of try/catch block
                    //        b. try/catch block runs to its end. Then the 'Goto(end)' will be trigger to jump out of the try/catch block
                    //  2. Exception thrown from the try/catch blocks
                    // In the first path, the continuation mechanism works and frame.InstructionIndex will be updated to point to the first instruction of the finally block
                    // In the second path, the continuation mechanism is not involved and frame.InstructionIndex is not updated
#if DEBUG
                    bool isFromJump = frame.IsJumpHappened();
                    Debug.Assert(!isFromJump || _tryHandler.FinallyStartIndex == frame.InstructionIndex, "we should already jump to the first instruction of the finally");
#endif
                    // run the finally block
                    // we cannot jump out of the finally block, and we cannot have an immediate rethrow in it
                    int index = frame.InstructionIndex = _tryHandler.FinallyStartIndex;
                    while (index >= _tryHandler.FinallyStartIndex && index < _tryHandler.FinallyEndIndex)
                    {
                        index += instructions[index].Run(frame);
                        frame.InstructionIndex = index;
                    }
                }
            }

            return(frame.InstructionIndex - prevInstrIndex);
        }
コード例 #34
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[frame.StackIndex++] = frame.Data[_index];
     //frame.Push(frame.Data[_index]);
     return(+1);
 }
コード例 #35
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[frame.StackIndex - 2] = this._site.Target(this._site, (T0)frame.Data[frame.StackIndex - 2], (T1)frame.Data[frame.StackIndex - 1]);
     frame.StackIndex--;
     return(1);
 }
コード例 #36
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[frame.StackIndex++] = _value;
     return(+1);
 }
コード例 #37
0
 public override int Run(InterpretedFrame frame)
 {
     // nop
     return(1);
 }
コード例 #38
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[frame.StackIndex - 7] = this._site.Target(this._site, (T0)frame.Data[frame.StackIndex - 7], (T1)frame.Data[frame.StackIndex - 6], (T2)frame.Data[frame.StackIndex - 5], (T3)frame.Data[frame.StackIndex - 4], (T4)frame.Data[frame.StackIndex - 3], (T5)frame.Data[frame.StackIndex - 2], (T6)frame.Data[frame.StackIndex - 1]);
     frame.StackIndex -= 6;
     return(1);
 }
コード例 #39
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[frame.StackIndex++] = frame.Interpreter._objects[_index];
     return(+1);
 }
コード例 #40
0
 public override int Run(InterpretedFrame frame)
 {
     return(GetLabel(frame).Index - frame.InstructionIndex);
 }
コード例 #41
0
 public override int Run(InterpretedFrame frame)
 {
     // goto the target label or the current finally continuation:
     return(frame.Goto(_labelIndex, _hasValue ? frame.Pop() : Interpreter.NoValue, gotoExceptionHandler: false));
 }
コード例 #42
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[_index] = null;
     return(1);
 }
コード例 #43
0
 public override int Run(InterpretedFrame frame)
 {
     return(_compiledLoop(frame.Data, frame.Closure, frame));
 }
コード例 #44
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[frame.StackIndex - 14] = this._site.Target(this._site, (T0)frame.Data[frame.StackIndex - 14], (T1)frame.Data[frame.StackIndex - 13], (T2)frame.Data[frame.StackIndex - 12], (T3)frame.Data[frame.StackIndex - 11], (T4)frame.Data[frame.StackIndex - 10], (T5)frame.Data[frame.StackIndex - 9], (T6)frame.Data[frame.StackIndex - 8], (T7)frame.Data[frame.StackIndex - 7], (T8)frame.Data[frame.StackIndex - 6], (T9)frame.Data[frame.StackIndex - 5], (T10)frame.Data[frame.StackIndex - 4], (T11)frame.Data[frame.StackIndex - 3], (T12)frame.Data[frame.StackIndex - 2], (T13)frame.Data[frame.StackIndex - 1]);
     frame.StackIndex -= 13;
     return(1);
 }
コード例 #45
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Push(this.Convert(frame.Pop()));
     return(1);
 }
コード例 #46
0
        public override int Run(InterpretedFrame frame)
        {
            Debug.Assert(_offset != Unknown);

            return(_offset);
        }
コード例 #47
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[_index] = frame.Peek();
     return(+1);
 }
コード例 #48
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[frame.StackIndex - 6] = this._target((T0)frame.Data[frame.StackIndex - 6], (T1)frame.Data[frame.StackIndex - 5], (T2)frame.Data[frame.StackIndex - 4], (T3)frame.Data[frame.StackIndex - 3], (T4)frame.Data[frame.StackIndex - 2], (T5)frame.Data[frame.StackIndex - 1]);
     frame.StackIndex -= 5;
     return(1);
 }
コード例 #49
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[_index] = new StrongBox <object>(Activator.CreateInstance(_type));
     return(1);
 }
コード例 #50
0
 public override int Run(InterpretedFrame frame)
 {
     if (this._hasFinally)
     {
         frame.PushContinuation(base._labelIndex);
     }
     int instructionIndex = frame.InstructionIndex;
     frame.InstructionIndex++;
     Instruction[] instructions = frame.Interpreter.Instructions.Instructions;
     try
     {
         int index = frame.InstructionIndex;
         while ((index >= this._tryHandler.TryStartIndex) && (index < this._tryHandler.TryEndIndex))
         {
             index += instructions[index].Run(frame);
             frame.InstructionIndex = index;
         }
         if (index == this._tryHandler.GotoEndTargetIndex)
         {
             frame.InstructionIndex += instructions[index].Run(frame);
         }
     }
     catch (RethrowException)
     {
         throw;
     }
     catch (Exception exception)
     {
         ExceptionHandler handler;
         frame.SaveTraceToException(exception);
         if (!this._tryHandler.IsCatchBlockExist)
         {
             throw;
         }
         frame.InstructionIndex += this._tryHandler.GotoHandler(frame, exception, out handler);
         if (handler == null)
         {
             throw;
         }
         ThreadAbortException exception2 = exception as ThreadAbortException;
         if (exception2 != null)
         {
             System.Management.Automation.Interpreter.Interpreter.AnyAbortException = exception2;
             frame.CurrentAbortHandler = handler;
         }
         bool flag = false;
         try
         {
             int num3 = frame.InstructionIndex;
             while ((num3 >= handler.HandlerStartIndex) && (num3 < handler.HandlerEndIndex))
             {
                 num3 += instructions[num3].Run(frame);
                 frame.InstructionIndex = num3;
             }
             if (num3 == this._tryHandler.GotoEndTargetIndex)
             {
                 frame.InstructionIndex += instructions[num3].Run(frame);
             }
         }
         catch (RethrowException)
         {
             flag = true;
         }
         if (flag)
         {
             throw;
         }
     }
     finally
     {
         if (this._tryHandler.IsFinallyBlockExist)
         {
             int num4 = frame.InstructionIndex = this._tryHandler.FinallyStartIndex;
             while ((num4 >= this._tryHandler.FinallyStartIndex) && (num4 < this._tryHandler.FinallyEndIndex))
             {
                 num4 += instructions[num4].Run(frame);
                 frame.InstructionIndex = num4;
             }
         }
     }
     return (frame.InstructionIndex - instructionIndex);
 }
コード例 #51
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[_index] = new StrongBox <object>(frame.Data[_index]);
     return(1);
 }
コード例 #52
0
 public override int Run(InterpretedFrame frame)
 {
     this._target((T0)frame.Data[frame.StackIndex - 2], (T1)frame.Data[frame.StackIndex - 1]);
     frame.StackIndex -= 2;
     return(1);
 }
コード例 #53
0
        public override int Run(InterpretedFrame frame)
        {
            object exception = frame.Pop();

            throw new RethrowException();
        }
コード例 #54
0
 public override int Run(InterpretedFrame frame)
 {
     StrongBox<object> box = (StrongBox<object>) frame.Data[base._index];
     frame.Data[frame.StackIndex++] = box.Value;
     return 1;
 }
コード例 #55
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[_index] = frame.Data[--frame.StackIndex];
     //frame.Data[_index] = frame.Pop();
     return(+1);
 }
コード例 #56
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Push(frame.Pop() == frame.Pop());
     return(+1);
 }
コード例 #57
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[frame.StackIndex - 0] = _target();
     frame.StackIndex -= -1;
     return(1);
 }
コード例 #58
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Push(((Byte)frame.Pop()) == ((Byte)frame.Pop()));
     return(+1);
 }
コード例 #59
0
ファイル: LoadFieldInstruction.cs プロジェクト: nickchal/pash
 public override int Run(InterpretedFrame frame)
 {
     frame.Push(this._field.GetValue(frame.Pop()));
     return 1;
 }
コード例 #60
0
 public override int Run(InterpretedFrame frame)
 {
     frame.Data[_index] = _defaultValue;
     return(1);
 }