lua/lopcodes.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 18 Jun 2017 19:50:43 -0400
changeset 57 4974e5368a29
parent 0 d7ee4e2ed49d
permissions -rw-r--r--
Minor type cleanup ("unsigned char" -> "uint8_t").
icculus@0
     1
/*
icculus@0
     2
** $Id: lopcodes.c,v 1.49.1.1 2013/04/12 18:48:47 roberto Exp $
icculus@0
     3
** Opcodes for Lua virtual machine
icculus@0
     4
** See Copyright Notice in lua.h
icculus@0
     5
*/
icculus@0
     6
icculus@0
     7
icculus@0
     8
#define lopcodes_c
icculus@0
     9
#define LUA_CORE
icculus@0
    10
icculus@0
    11
icculus@0
    12
#include "lopcodes.h"
icculus@0
    13
icculus@0
    14
icculus@0
    15
/* ORDER OP */
icculus@0
    16
icculus@0
    17
LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
icculus@0
    18
  "MOVE",
icculus@0
    19
  "LOADK",
icculus@0
    20
  "LOADKX",
icculus@0
    21
  "LOADBOOL",
icculus@0
    22
  "LOADNIL",
icculus@0
    23
  "GETUPVAL",
icculus@0
    24
  "GETTABUP",
icculus@0
    25
  "GETTABLE",
icculus@0
    26
  "SETTABUP",
icculus@0
    27
  "SETUPVAL",
icculus@0
    28
  "SETTABLE",
icculus@0
    29
  "NEWTABLE",
icculus@0
    30
  "SELF",
icculus@0
    31
  "ADD",
icculus@0
    32
  "SUB",
icculus@0
    33
  "MUL",
icculus@0
    34
  "DIV",
icculus@0
    35
  "MOD",
icculus@0
    36
  "POW",
icculus@0
    37
  "UNM",
icculus@0
    38
  "NOT",
icculus@0
    39
  "LEN",
icculus@0
    40
  "CONCAT",
icculus@0
    41
  "JMP",
icculus@0
    42
  "EQ",
icculus@0
    43
  "LT",
icculus@0
    44
  "LE",
icculus@0
    45
  "TEST",
icculus@0
    46
  "TESTSET",
icculus@0
    47
  "CALL",
icculus@0
    48
  "TAILCALL",
icculus@0
    49
  "RETURN",
icculus@0
    50
  "FORLOOP",
icculus@0
    51
  "FORPREP",
icculus@0
    52
  "TFORCALL",
icculus@0
    53
  "TFORLOOP",
icculus@0
    54
  "SETLIST",
icculus@0
    55
  "CLOSURE",
icculus@0
    56
  "VARARG",
icculus@0
    57
  "EXTRAARG",
icculus@0
    58
  NULL
icculus@0
    59
};
icculus@0
    60
icculus@0
    61
icculus@0
    62
#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
icculus@0
    63
icculus@0
    64
LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
icculus@0
    65
/*       T  A    B       C     mode		   opcode	*/
icculus@0
    66
  opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_MOVE */
icculus@0
    67
 ,opmode(0, 1, OpArgK, OpArgN, iABx)		/* OP_LOADK */
icculus@0
    68
 ,opmode(0, 1, OpArgN, OpArgN, iABx)		/* OP_LOADKX */
icculus@0
    69
 ,opmode(0, 1, OpArgU, OpArgU, iABC)		/* OP_LOADBOOL */
icculus@0
    70
 ,opmode(0, 1, OpArgU, OpArgN, iABC)		/* OP_LOADNIL */
icculus@0
    71
 ,opmode(0, 1, OpArgU, OpArgN, iABC)		/* OP_GETUPVAL */
icculus@0
    72
 ,opmode(0, 1, OpArgU, OpArgK, iABC)		/* OP_GETTABUP */
icculus@0
    73
 ,opmode(0, 1, OpArgR, OpArgK, iABC)		/* OP_GETTABLE */
icculus@0
    74
 ,opmode(0, 0, OpArgK, OpArgK, iABC)		/* OP_SETTABUP */
icculus@0
    75
 ,opmode(0, 0, OpArgU, OpArgN, iABC)		/* OP_SETUPVAL */
icculus@0
    76
 ,opmode(0, 0, OpArgK, OpArgK, iABC)		/* OP_SETTABLE */
icculus@0
    77
 ,opmode(0, 1, OpArgU, OpArgU, iABC)		/* OP_NEWTABLE */
icculus@0
    78
 ,opmode(0, 1, OpArgR, OpArgK, iABC)		/* OP_SELF */
icculus@0
    79
 ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_ADD */
icculus@0
    80
 ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_SUB */
icculus@0
    81
 ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_MUL */
icculus@0
    82
 ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_DIV */
icculus@0
    83
 ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_MOD */
icculus@0
    84
 ,opmode(0, 1, OpArgK, OpArgK, iABC)		/* OP_POW */
icculus@0
    85
 ,opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_UNM */
icculus@0
    86
 ,opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_NOT */
icculus@0
    87
 ,opmode(0, 1, OpArgR, OpArgN, iABC)		/* OP_LEN */
icculus@0
    88
 ,opmode(0, 1, OpArgR, OpArgR, iABC)		/* OP_CONCAT */
icculus@0
    89
 ,opmode(0, 0, OpArgR, OpArgN, iAsBx)		/* OP_JMP */
icculus@0
    90
 ,opmode(1, 0, OpArgK, OpArgK, iABC)		/* OP_EQ */
icculus@0
    91
 ,opmode(1, 0, OpArgK, OpArgK, iABC)		/* OP_LT */
icculus@0
    92
 ,opmode(1, 0, OpArgK, OpArgK, iABC)		/* OP_LE */
icculus@0
    93
 ,opmode(1, 0, OpArgN, OpArgU, iABC)		/* OP_TEST */
icculus@0
    94
 ,opmode(1, 1, OpArgR, OpArgU, iABC)		/* OP_TESTSET */
icculus@0
    95
 ,opmode(0, 1, OpArgU, OpArgU, iABC)		/* OP_CALL */
icculus@0
    96
 ,opmode(0, 1, OpArgU, OpArgU, iABC)		/* OP_TAILCALL */
icculus@0
    97
 ,opmode(0, 0, OpArgU, OpArgN, iABC)		/* OP_RETURN */
icculus@0
    98
 ,opmode(0, 1, OpArgR, OpArgN, iAsBx)		/* OP_FORLOOP */
icculus@0
    99
 ,opmode(0, 1, OpArgR, OpArgN, iAsBx)		/* OP_FORPREP */
icculus@0
   100
 ,opmode(0, 0, OpArgN, OpArgU, iABC)		/* OP_TFORCALL */
icculus@0
   101
 ,opmode(0, 1, OpArgR, OpArgN, iAsBx)		/* OP_TFORLOOP */
icculus@0
   102
 ,opmode(0, 0, OpArgU, OpArgU, iABC)		/* OP_SETLIST */
icculus@0
   103
 ,opmode(0, 1, OpArgU, OpArgN, iABx)		/* OP_CLOSURE */
icculus@0
   104
 ,opmode(0, 1, OpArgU, OpArgN, iABC)		/* OP_VARARG */
icculus@0
   105
 ,opmode(0, 0, OpArgU, OpArgU, iAx)		/* OP_EXTRAARG */
icculus@0
   106
};
icculus@0
   107