# lvm.c File Reference

`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include "lua.h"`
`#include "ldebug.h"`
`#include "ldo.h"`
`#include "lfunc.h"`
`#include "lgc.h"`
`#include "lobject.h"`
`#include "lopcodes.h"`
`#include "lstate.h"`
`#include "lstring.h"`
`#include "ltable.h"`
`#include "ltm.h"`
`#include "lvm.h"`

## Defines
#define | lvm_c
#define | LUA_CORE
#define | MAXTAGLOOP 100
#define | runtime_check(L, c) { if (!(c)) break; }
#define | RA(i) (base+GETARG_A(i))
#define | RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
#define | RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
#define | RKB(i)
#define | RKC(i)
#define | KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i))
#define | dojump(L, pc, i) {(pc) += (i); luai_threadyield(L);}
#define | Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
#define | arith_op(op, tm)
## Functions
const TValue * | luaV_tonumber (const TValue *obj, TValue *n)
int | luaV_tostring (lua_State *L, StkId obj)
static void | traceexec (lua_State *L, const Instruction *pc)
static void | callTMres (lua_State *L, StkId res, const TValue *f, const TValue *p1, const TValue *p2)
static void | callTM (lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, const TValue *p3)
void | luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val)
void | luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val)
static int | call_binTM (lua_State *L, const TValue *p1, const TValue *p2, StkId res, TMS event)
static const TValue * | get_compTM (lua_State *L, Table *mt1, Table *mt2, TMS event)
static int | call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, TMS event)
static int | l_strcmp (const TString *ls, const TString *rs)
int | luaV_lessthan (lua_State *L, const TValue *l, const TValue *r)
static int | lessequal (lua_State *L, const TValue *l, const TValue *r)
int | luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2)
void | luaV_concat (lua_State *L, int total, int last)
static void | Arith (lua_State *L, StkId ra, const TValue *rb, const TValue *rc, TMS op)
void | luaV_execute (lua_State *L, int nexeccalls)

## Define Documentation

#define arith_op | ( | op,
|  | tm |  | ) |

Value:

    { \
            TValue *rb = RKB(i); \
            TValue *rc = RKC(i); \
            if (ttisnumber(rb) && ttisnumber(rc)) { \
              lua_Number nb = nvalue(rb), nc = nvalue(rc); \
              setnvalue(ra, op(nb, nc)); \
            } \
            else \
              Protect(Arith(L, ra, rb, rc, tm)); \
          }

#define dojump | ( | L,
|  | pc,
|  | i |  | ) | {(pc) += (i); luai_threadyield(L);}

#define KBx | ( | i |  | ) | check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i))

#define LUA_CORE

#define lvm_c

#define MAXTAGLOOP 100

#define Protect | ( | x |  | ) | { L->savedpc = pc; {x;}; base = L->base; }

#define RA | ( | i |  | ) | (base+GETARG_A(i))

#define RB | ( | i |  | ) | check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))

#define RC | ( | i |  | ) | check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))

#define RKB | ( | i |  | ) |

Value:

    check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
            ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))

#define RKC | ( | i |  | ) |

Value:

    check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
            ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))

#define runtime_check | ( | L,
|  | c |  | ) | { if (!(c)) break; }

## Function Documentation

static void Arith | ( | lua_State * | L,
|  | StkId | ra,
|  | const TValue * | rb,
|  | const TValue * | rc,
|  | TMS | op |
| ) |  |  | `[static]`

static int call_binTM | ( | lua_State * | L,
|  | const TValue * | p1,
|  | const TValue * | p2,
|  | StkId | res,
|  | TMS | event |
| ) |  |  | `[static]`

static int call_orderTM | ( | lua_State * | L,
|  | const TValue * | p1,
|  | const TValue * | p2,
|  | TMS | event |
| ) |  |  | `[static]`

static void callTM | ( | lua_State * | L,
|  | const TValue * | f,
|  | const TValue * | p1,
|  | const TValue * | p2,
|  | const TValue * | p3 |
| ) |  |  | `[static]`

static void callTMres | ( | lua_State * | L,
|  | StkId | res,
|  | const TValue * | f,
|  | const TValue * | p1,
|  | const TValue * | p2 |
| ) |  |  | `[static]`

static const TValue* get_compTM | ( | lua_State * | L,
|  | Table * | mt1,
|  | Table * | mt2,
|  | TMS | event |
| ) |  |  | `[static]`

static int l_strcmp | ( | const TString * | ls,
|  | const TString * | rs |
| ) |  |  | `[static]`

static int lessequal | ( | lua_State * | L,
|  | const TValue * | l,
|  | const TValue * | r |
| ) |  |  | `[static]`

void luaV_concat | ( | lua_State * | L,
|  | int | total,
|  | int | last |
| ) |  |  |

int luaV_equalval | ( | lua_State * | L,
|  | const TValue * | t1,
|  | const TValue * | t2 |
| ) |  |  |

void luaV_execute | ( | lua_State * | L,
|  | int | nexeccalls |
| ) |  |  |

void luaV_gettable | ( | lua_State * | L,
|  | const TValue * | t,
|  | TValue * | key,
|  | StkId | val |
| ) |  |  |

int luaV_lessthan | ( | lua_State * | L,
|  | const TValue * | l,
|  | const TValue * | r |
| ) |  |  |

void luaV_settable | ( | lua_State * | L,
|  | const TValue * | t,
|  | TValue * | key,
|  | StkId | val |
| ) |  |  |

const TValue* luaV_tonumber | ( | const TValue * | obj,
|  | TValue * | n |
| ) |  |  |

int luaV_tostring | ( | lua_State * | L,
|  | StkId | obj |
| ) |  |  |

static void traceexec | ( | lua_State * | L,
|  | const Instruction * | pc |
| ) |  |  | `[static]`