public ProgramState Execute(ProgramState ps) { ExecutionStack executionStack = ps.GetExecutionStack(); executionStack.Push(right); executionStack.Push(left); return(ps); }
public ProgramState Execute(ProgramState ps) { SymbolTable symbolTable = ps.GetSymbolTable(); ExecutionStack executionStack = ps.GetExecutionStack(); int result = expression.Evaluate(symbolTable); if (result == 0) { executionStack.Push(selse); } else { executionStack.Push(sthen); } return(ps); }
public static EXECUTION_RESULT?EQ_VERIFY(ref ExecutionStack stack) { if (EQUALS(ref stack) != null) { stack.Push(false); } return(Verify.VERIFY(ref stack)); }
public static EXECUTION_RESULT?CHECKLOCKTIME_VERIFY(ref ExecutionStack stack) { if (CHECKLOCKTIME(ref stack) != null) { stack.Push(false); } return(VERIFY(ref stack)); }
public static EXECUTION_RESULT?EQUALS(ref ExecutionStack stack) { if (stack.Count < 2) { return(EXECUTION_RESULT.INVALID_STACK); } stack.Push(System.Linq.Enumerable.SequenceEqual(stack.Pop(), stack.Pop())); return(null); }
public static EXECUTION_RESULT?DUP(ref ExecutionStack stack) { if (!stack.Any()) { return(EXECUTION_RESULT.INVALID_STACK); } var item = stack.Pop(); stack.Push(item, item); return(null); }
protected override void Run(CancellationToken cancellationToken) { IOperation next; OperationCollection coll; IAtomicOperation operation; while (ExecutionStack.Count > 0) { cancellationToken.ThrowIfCancellationRequested(); next = ExecutionStack.Pop(); if (next is OperationCollection) { coll = (OperationCollection)next; for (int i = coll.Count - 1; i >= 0; i--) { if (coll[i] != null) { ExecutionStack.Push(coll[i]); } } } else if (next is IAtomicOperation) { operation = (IAtomicOperation)next; try { next = operation.Operator.Execute((IExecutionContext)operation, cancellationToken); } catch (Exception ex) { ExecutionStack.Push(operation); if (ex is OperationCanceledException) { throw ex; } else { throw new OperatorExecutionException(operation.Operator, ex); } } if (next != null) { ExecutionStack.Push(next); } if (operation.Operator.Breakpoint) { Log.LogMessage(string.Format("Breakpoint: {0}", operation.Operator.Name != string.Empty ? operation.Operator.Name : operation.Operator.ItemName)); Pause(); } } } }
public static EXECUTION_RESULT?CHECKSIG(ref ExecutionStack stack) { if (stack.Transaction == null) { return(EXECUTION_RESULT.NO_TRANSACTION_GIVEN); } if (stack.Count < 2) { return(EXECUTION_RESULT.INVALID_STACK); } //Verify if signature is valid stack.Push(new CryptoRSA(stack.Pop()).Verify(stack.Transaction.Hash(), stack.Pop())); return(null); }
protected override void Run(CancellationToken cancellationToken) { IOperation next; OperationCollection coll; IAtomicOperation operation; while (ExecutionStack.Count > 0) { cancellationToken.ThrowIfCancellationRequested(); next = ExecutionStack.Pop(); if (next is OperationCollection) { coll = (OperationCollection)next; for (int i = coll.Count - 1; i >= 0; i--) { if (coll[i] != null) { ExecutionStack.Push(coll[i]); } } } else if (next is IAtomicOperation) { operation = (IAtomicOperation)next; try { next = operation.Operator.Execute((IExecutionContext)operation, cancellationToken); } catch (Exception ex) { ExecutionStack.Push(operation); if (ex is OperationCanceledException) { throw; } else { throw new OperatorExecutionException(operation.Operator, ex); } } if (next != null) { ExecutionStack.Push(next); } } } }
public static EXECUTION_RESULT?CHECKLOCKTIME(ref ExecutionStack stack) { if (stack.Transaction == null) { return(EXECUTION_RESULT.NO_TRANSACTION_GIVEN); } if (stack.Count() < 1) { return(EXECUTION_RESULT.INVALID_STACK); } if (stack.Peek().Length != 4) { return(EXECUTION_RESULT.INVALID_BYTE_SIZE); } uint size = stack.PopUInt(); stack.Push(stack.Transaction.lockTime >= size); return(null); }
public static void MIN(ref ExecutionStack stack) => stack.Push(System.Math.Min(stack.PopShort(), stack.PopShort()));
public static void ABS(ref ExecutionStack stack) => stack.Push(System.Math.Abs(stack.PopShort()));
public static void PUBKEY_HASH(ref ExecutionStack stack) => stack.Push(stack.Script.DequeueRange(Script.AddressSize));
public static void SIGNATURE(ref ExecutionStack stack) => stack.Push(stack.Script.DequeueRange(Script.SignatureSize));
public static void PUBKEY(ref ExecutionStack stack) => stack.Push(stack.Script.DequeueRange(Script.PubKeySize));
public static void PUSH_SHORT(ref ExecutionStack stack) => stack.Push(System.BitConverter.ToInt16(stack.Script.DequeueRange(2)));
public static void EQ_NUM(ref ExecutionStack stack) => stack.Push(stack.PopShort() == stack.PopShort());
public static void GREATERTHAN(ref ExecutionStack stack) => stack.Push(stack.PopShort() > stack.PopShort());
public static void LESSTHAN(ref ExecutionStack stack) => stack.Push(stack.PopShort() < stack.PopShort());
public static void ADD(ref ExecutionStack stack) => stack.Push((short)(stack.PopShort() + stack.PopShort()));
public static EXECUTION_RESULT?HASH_160(ref ExecutionStack stack) { stack.Push(Hash.HASH160(stack.Pop())); return(null); }
public static EXECUTION_RESULT?RIPEMD_160(ref ExecutionStack stack) { stack.Push(Hash.RIPEMD160(stack.Pop())); return(null); }
public static void SUBSTRACT(ref ExecutionStack stack) => stack.Push((short)(stack.PopShort() - stack.PopShort()));
public static void OP_9(ref ExecutionStack stack) => stack.Push((short)9);
public static void LESSOREQUAL(ref ExecutionStack stack) => stack.Push(stack.PopShort() <= stack.PopShort());
public static void OP_16(ref ExecutionStack stack) => stack.Push((short)16);
public static void GREATEROREQUAL(ref ExecutionStack stack) => stack.Push(stack.PopShort() >= stack.PopShort());
public static void PUSHDATA_1(ref ExecutionStack stack) => stack.Push(stack.Script.DequeueRange(stack.Script.Dequeue()));
public static EXECUTION_RESULT?EQ_VERIFY_NUM(ref ExecutionStack stack) { stack.Push(stack.PopShort() == stack.PopShort()); return(Verify.VERIFY(ref stack)); }
public static void PUSH_UINT(ref ExecutionStack stack) => stack.Push(System.BitConverter.ToUInt32(stack.Script.DequeueRange(4)));