github.com/ontio/ontology@v1.14.4/vm/neovm/opcode_exec.go (about)

     1  /*
     2   * Copyright (C) 2018 The ontology Authors
     3   * This file is part of The ontology library.
     4   *
     5   * The ontology is free software: you can redistribute it and/or modify
     6   * it under the terms of the GNU Lesser General Public License as published by
     7   * the Free Software Foundation, either version 3 of the License, or
     8   * (at your option) any later version.
     9   *
    10   * The ontology is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU Lesser General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU Lesser General Public License
    16   * along with The ontology.  If not, see <http://www.gnu.org/licenses/>.
    17   */
    18  
    19  package neovm
    20  
    21  type OpInfo struct {
    22  	Opcode OpCode
    23  	Name   string
    24  }
    25  
    26  var (
    27  	OpExecList = [256]OpInfo{
    28  		// control flow
    29  		PUSH0:       {Opcode: PUSH0, Name: "PUSH0"},
    30  		PUSHBYTES1:  {Opcode: PUSHBYTES1, Name: "PUSHBYTES1"},
    31  		PUSHBYTES75: {Opcode: PUSHBYTES75, Name: "PUSHBYTES75"},
    32  		PUSHDATA1:   {Opcode: PUSHDATA1, Name: "PUSHDATA1"},
    33  		PUSHDATA2:   {Opcode: PUSHDATA2, Name: "PUSHDATA2"},
    34  		PUSHDATA4:   {Opcode: PUSHDATA4, Name: "PUSHDATA4"},
    35  		PUSHM1:      {Opcode: PUSHM1, Name: "PUSHM1"},
    36  		PUSH1:       {Opcode: PUSH1, Name: "PUSH1"},
    37  		PUSH2:       {Opcode: PUSH2, Name: "PUSH2"},
    38  		PUSH3:       {Opcode: PUSH3, Name: "PUSH3"},
    39  		PUSH4:       {Opcode: PUSH4, Name: "PUSH4"},
    40  		PUSH5:       {Opcode: PUSH5, Name: "PUSH5"},
    41  		PUSH6:       {Opcode: PUSH6, Name: "PUSH6"},
    42  		PUSH7:       {Opcode: PUSH7, Name: "PUSH7"},
    43  		PUSH8:       {Opcode: PUSH8, Name: "PUSH8"},
    44  		PUSH9:       {Opcode: PUSH9, Name: "PUSH9"},
    45  		PUSH10:      {Opcode: PUSH10, Name: "PUSH10"},
    46  		PUSH11:      {Opcode: PUSH11, Name: "PUSH11"},
    47  		PUSH12:      {Opcode: PUSH12, Name: "PUSH12"},
    48  		PUSH13:      {Opcode: PUSH13, Name: "PUSH13"},
    49  		PUSH14:      {Opcode: PUSH14, Name: "PUSH14"},
    50  		PUSH15:      {Opcode: PUSH15, Name: "PUSH15"},
    51  		PUSH16:      {Opcode: PUSH16, Name: "PUSH16"},
    52  
    53  		//Control
    54  		NOP:      {Opcode: NOP, Name: "NOP"},
    55  		JMP:      {Opcode: JMP, Name: "JMP"},
    56  		JMPIF:    {Opcode: JMPIF, Name: "JMPIF"},
    57  		JMPIFNOT: {Opcode: JMPIFNOT, Name: "JMPIFNOT"},
    58  		CALL:     {Opcode: CALL, Name: "CALL"},
    59  		RET:      {Opcode: RET, Name: "RET"},
    60  		APPCALL:  {Opcode: APPCALL, Name: "APPCALL"},
    61  		//TAILCALL: {Opcode: TAILCALL, Name: "TAILCALL"},
    62  		SYSCALL: {Opcode: SYSCALL, Name: "SYSCALL"},
    63  		DCALL:   {Opcode: DCALL, Name: "DCALL"},
    64  
    65  		//Stack ops
    66  		DUPFROMALTSTACK: {Opcode: DUPFROMALTSTACK, Name: "DUPFROMALTSTACK"},
    67  		TOALTSTACK:      {Opcode: TOALTSTACK, Name: "TOALTSTACK"},
    68  		FROMALTSTACK:    {Opcode: FROMALTSTACK, Name: "FROMALTSTACK"},
    69  		XDROP:           {Opcode: XDROP, Name: "XDROP"},
    70  		XSWAP:           {Opcode: XSWAP, Name: "XSWAP"},
    71  		XTUCK:           {Opcode: XTUCK, Name: "XTUCK"},
    72  		DEPTH:           {Opcode: DEPTH, Name: "DEPTH"},
    73  		DROP:            {Opcode: DROP, Name: "DROP"},
    74  		DUP:             {Opcode: DUP, Name: "DUP"},
    75  		NIP:             {Opcode: NIP, Name: "NIP"},
    76  		OVER:            {Opcode: OVER, Name: "OVER"},
    77  		PICK:            {Opcode: PICK, Name: "PICK"},
    78  		ROLL:            {Opcode: ROLL, Name: "ROLL"},
    79  		ROT:             {Opcode: ROT, Name: "ROT"},
    80  		SWAP:            {Opcode: SWAP, Name: "SWAP"},
    81  		TUCK:            {Opcode: TUCK, Name: "TUCK"},
    82  
    83  		//Splice
    84  		CAT:    {Opcode: CAT, Name: "CAT"},
    85  		SUBSTR: {Opcode: SUBSTR, Name: "SUBSTR"},
    86  		LEFT:   {Opcode: LEFT, Name: "LEFT"},
    87  		RIGHT:  {Opcode: RIGHT, Name: "RIGHT"},
    88  		SIZE:   {Opcode: SIZE, Name: "SIZE"},
    89  
    90  		//Bitwiase logic
    91  		INVERT: {Opcode: INVERT, Name: "INVERT"},
    92  		AND:    {Opcode: AND, Name: "AND"},
    93  		OR:     {Opcode: OR, Name: "OR"},
    94  		XOR:    {Opcode: XOR, Name: "XOR"},
    95  		EQUAL:  {Opcode: EQUAL, Name: "EQUAL"},
    96  
    97  		//Arithmetic
    98  		INC:         {Opcode: INC, Name: "INC"},
    99  		DEC:         {Opcode: DEC, Name: "DEC"},
   100  		SIGN:        {Opcode: SIGN, Name: "SIGN"},
   101  		NEGATE:      {Opcode: NEGATE, Name: "NEGATE"},
   102  		ABS:         {Opcode: ABS, Name: "ABS"},
   103  		NOT:         {Opcode: NOT, Name: "NOT"},
   104  		NZ:          {Opcode: NZ, Name: "NZ"},
   105  		ADD:         {Opcode: ADD, Name: "ADD"},
   106  		SUB:         {Opcode: SUB, Name: "SUB"},
   107  		MUL:         {Opcode: MUL, Name: "MUL"},
   108  		DIV:         {Opcode: DIV, Name: "DIV"},
   109  		MOD:         {Opcode: MOD, Name: "MOD"},
   110  		SHL:         {Opcode: SHL, Name: "SHL"},
   111  		SHR:         {Opcode: SHR, Name: "SHR"},
   112  		BOOLAND:     {Opcode: BOOLAND, Name: "BOOLAND"},
   113  		BOOLOR:      {Opcode: BOOLOR, Name: "BOOLOR"},
   114  		NUMEQUAL:    {Opcode: NUMEQUAL, Name: "NUMEQUAL"},
   115  		NUMNOTEQUAL: {Opcode: NUMNOTEQUAL, Name: "NUMNOTEQUAL"},
   116  		LT:          {Opcode: LT, Name: "LT"},
   117  		GT:          {Opcode: GT, Name: "GT"},
   118  		LTE:         {Opcode: LTE, Name: "LTE"},
   119  		GTE:         {Opcode: GTE, Name: "GTE"},
   120  		MIN:         {Opcode: MIN, Name: "MIN"},
   121  		MAX:         {Opcode: MAX, Name: "MAX"},
   122  		WITHIN:      {Opcode: WITHIN, Name: "WITHIN"},
   123  
   124  		//Crypto
   125  		SHA1:    {Opcode: SHA1, Name: "SHA1"},
   126  		SHA256:  {Opcode: SHA256, Name: "SHA256"},
   127  		HASH160: {Opcode: HASH160, Name: "HASH160"},
   128  		HASH256: {Opcode: HASH256, Name: "HASH256"},
   129  		VERIFY:  {Opcode: VERIFY, Name: "VERIFY"},
   130  		//CHECKSIG:      {Opcode: CHECKSIG, Name: "CHECKSIG"},
   131  		//CHECKMULTISIG: {Opcode: CHECKMULTISIG, Name: "CHECKMULTISIG"},
   132  
   133  		//Array
   134  		ARRAYSIZE: {Opcode: ARRAYSIZE, Name: "ARRAYSIZE"},
   135  		PACK:      {Opcode: PACK, Name: "PACK"},
   136  		UNPACK:    {Opcode: UNPACK, Name: "UNPACK"},
   137  		PICKITEM:  {Opcode: PICKITEM, Name: "PICKITEM"},
   138  		SETITEM:   {Opcode: SETITEM, Name: "SETITEM"},
   139  		NEWARRAY:  {Opcode: NEWARRAY, Name: "NEWARRAY"},
   140  		NEWMAP:    {Opcode: NEWMAP, Name: "NEWMAP"},
   141  		NEWSTRUCT: {Opcode: NEWSTRUCT, Name: "NEWSTRUCT"},
   142  		APPEND:    {Opcode: APPEND, Name: "APPEND"},
   143  		REVERSE:   {Opcode: REVERSE, Name: "REVERSE"},
   144  		REMOVE:    {Opcode: REMOVE, Name: "REMOVE"},
   145  
   146  		HASKEY: {Opcode: HASKEY, Name: "HASKEY"},
   147  		KEYS:   {Opcode: KEYS, Name: "KEYS"},
   148  		VALUES: {Opcode: VALUES, Name: "VALUES"},
   149  
   150  		//Exceptions
   151  		THROW:      {Opcode: THROW, Name: "THROW"},
   152  		THROWIFNOT: {Opcode: THROWIFNOT, Name: "THROWIFNOT"},
   153  	}
   154  )