w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

lj_parse.c File Reference
#include "lj_obj.h"
#include "lj_gc.h"
#include "lj_err.h"
#include "lj_debug.h"
#include "lj_buf.h"
#include "lj_str.h"
#include "lj_tab.h"
#include "lj_func.h"
#include "lj_state.h"
#include "lj_bc.h"
#include "lj_ctype.h"
#include "lj_strfmt.h"
#include "lj_lex.h"
#include "lj_parse.h"
#include "lj_vm.h"
#include "lj_vmevent.h"
Include dependency graph for lj_parse.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ExpDesc
 
struct  FuncScope
 
struct  FuncState
 
struct  LHSVarList
 

Macros

#define lj_parse_c
 
#define LUA_CORE
 
#define expr_hasjump(e)   ((e)->t != (e)->f)
 
#define expr_isk(e)   ((e)->k <= VKLAST)
 
#define expr_isk_nojump(e)   (expr_isk(e) && !expr_hasjump(e))
 
#define expr_isnumk(e)   ((e)->k == VKNUM)
 
#define expr_isnumk_nojump(e)   (expr_isnumk(e) && !expr_hasjump(e))
 
#define expr_isstrk(e)   ((e)->k == VKSTR)
 
#define expr_numtv(e)   check_exp(expr_isnumk((e)), &(e)->u.nval)
 
#define expr_numberV(e)   numberVnum(expr_numtv((e)))
 
#define FSCOPE_LOOP   0x01 /* Scope is a (breakable) loop. */
 
#define FSCOPE_BREAK   0x02 /* Break used in scope. */
 
#define FSCOPE_GOLA   0x04 /* Goto or label used in scope. */
 
#define FSCOPE_UPVAL   0x08 /* Upvalue in scope. */
 
#define FSCOPE_NOCLOSE   0x10 /* Do not close upvalues. */
 
#define NAME_BREAK   ((GCstr *)(uintptr_t)1)
 
#define LJ_MAX_VSTACK   (65536 - LJ_MAX_UPVAL)
 
#define VSTACK_VAR_RW   0x01 /* R/W variable. */
 
#define VSTACK_GOTO   0x02 /* Pending goto. */
 
#define VSTACK_LABEL   0x04 /* Label. */
 
#define checklimit(fs, v, l, m)   if ((v) >= (l)) err_limit(fs, l, m)
 
#define checklimitgt(fs, v, l, m)   if ((v) > (l)) err_limit(fs, l, m)
 
#define checkcond(ls, c, em)   { if (!(c)) err_syntax(ls, em); }
 
#define const_pri(e)   check_exp((e)->k <= VKTRUE, (e)->k)
 
#define tvhaskslot(o)   ((o)->u32.hi == 0)
 
#define tvkslot(o)   ((o)->u32.lo)
 
#define bcemit_ABC(fs, o, a, b, c)   bcemit_INS(fs, BCINS_ABC(o, a, b, c))
 
#define bcemit_AD(fs, o, a, d)   bcemit_INS(fs, BCINS_AD(o, a, d))
 
#define bcemit_AJ(fs, o, a, j)   bcemit_INS(fs, BCINS_AJ(o, a, j))
 
#define bcptr(fs, e)   (&(fs)->bcbase[(e)->u.s.info].ins)
 
#define var_get(ls, fs, i)   ((ls)->vstack[(fs)->varmap[(i)]])
 
#define var_new_lit(ls, n, v)    var_new(ls, (n), lj_parse_keepstr(ls, "" v, sizeof(v)-1))
 
#define var_new_fixed(ls, n, vn)    var_new(ls, (n), (GCstr *)(uintptr_t)(vn))
 
#define var_lookup(ls, e)    var_lookup_((ls)->fs, lex_str(ls), (e), 1)
 
#define gola_isgoto(v)   ((v)->info & VSTACK_GOTO)
 
#define gola_islabel(v)   ((v)->info & VSTACK_LABEL)
 
#define gola_isgotolabel(v)   ((v)->info & (VSTACK_GOTO|VSTACK_LABEL))
 
#define synlevel_end(ls)   ((ls)->level--)
 
#define UNARY_PRIORITY   8 /* Priority for unary operators. */
 

Typedefs

typedef struct ExpDesc ExpDesc
 
typedef struct FuncScope FuncScope
 
typedef uint16_t VarIndex
 
typedef struct FuncState FuncState
 
typedef enum BinOpr BinOpr
 
typedef struct LHSVarList LHSVarList
 

Enumerations

enum  ExpKind {
  VKNIL , VKFALSE , VKTRUE , VKSTR ,
  VKNUM , VKLAST = VKNUM , VKCDATA , VLOCAL ,
  VUPVAL , VGLOBAL , VINDEXED , VJMP ,
  VRELOCABLE , VNONRELOC , VCALL , VVOID ,
  VKNIL , VKFALSE , VKTRUE , VKSTR ,
  VKNUM , VKLAST = VKNUM , VKCDATA , VLOCAL ,
  VUPVAL , VGLOBAL , VINDEXED , VJMP ,
  VRELOCABLE , VNONRELOC , VCALL , VVOID
}
 
enum  BinOpr {
  OPR_ADD , OPR_SUB , OPR_MUL , OPR_MOD ,
  OPR_POW , OPR_DIV , OPR_IDIV , OPR_BAND ,
  OPR_BOR , OPR_BXOR , OPR_SHL , OPR_SHR ,
  OPR_CONCAT , OPR_EQ , OPR_LT , OPR_LE ,
  OPR_NE , OPR_GT , OPR_GE , OPR_AND ,
  OPR_OR , OPR_NOBINOPR , OPR_ADD , OPR_SUB ,
  OPR_MUL , OPR_DIV , OPR_MOD , OPR_POW ,
  OPR_CONCAT , OPR_NE , OPR_EQ , OPR_LT ,
  OPR_LE , OPR_GT , OPR_GE , OPR_AND ,
  OPR_OR , OPR_NOBINOPR , OPR_ADD , OPR_SUB ,
  OPR_MUL , OPR_DIV , OPR_MOD , OPR_POW ,
  OPR_CONCAT , OPR_NE , OPR_EQ , OPR_LT ,
  OPR_GE , OPR_LE , OPR_GT , OPR_AND ,
  OPR_OR , OPR_NOBINOPR , OPR_ADD , OPR_SUB ,
  OPR_MUL , OPR_MOD , OPR_POW , OPR_DIV ,
  OPR_IDIV , OPR_BAND , OPR_BOR , OPR_BXOR ,
  OPR_SHL , OPR_SHR , OPR_CONCAT , OPR_EQ ,
  OPR_LT , OPR_LE , OPR_NE , OPR_GT ,
  OPR_GE , OPR_AND , OPR_OR , OPR_NOBINOPR ,
  OPR_ADD , OPR_SUB , OPR_MUL , OPR_DIV ,
  OPR_MOD , OPR_POW , OPR_CONCAT , OPR_NE ,
  OPR_EQ , OPR_LT , OPR_LE , OPR_GT ,
  OPR_GE , OPR_AND , OPR_OR , OPR_NOBINOPR ,
  OPR_ADD , OPR_SUB , OPR_MUL , OPR_DIV ,
  OPR_MOD , OPR_POW , OPR_CONCAT , OPR_NE ,
  OPR_EQ , OPR_LT , OPR_GE , OPR_LE ,
  OPR_GT , OPR_AND , OPR_OR , OPR_NOBINOPR
}
 

Functions

static LJ_AINLINE void expr_init (ExpDesc *e, ExpKind k, uint32_t info)
 
static int expr_numiszero (ExpDesc *e)
 
void lj_assert___LINE__ (int STATIC_ASSERTION_FAILED[((int) BC_ISGE-(int) BC_ISLT==(int) OPR_GE-(int) OPR_LT)?1:-1])
 
void lj_assert___LINE__ (int STATIC_ASSERTION_FAILED[((int) BC_ISLE-(int) BC_ISLT==(int) OPR_LE-(int) OPR_LT)?1:-1])
 
void lj_assert___LINE__ (int STATIC_ASSERTION_FAILED[((int) BC_ISGT-(int) BC_ISLT==(int) OPR_GT-(int) OPR_LT)?1:-1])
 
void lj_assert___LINE__ (int STATIC_ASSERTION_FAILED[((int) BC_SUBVV-(int) BC_ADDVV==(int) OPR_SUB-(int) OPR_ADD)?1:-1])
 
void lj_assert___LINE__ (int STATIC_ASSERTION_FAILED[((int) BC_MULVV-(int) BC_ADDVV==(int) OPR_MUL-(int) OPR_ADD)?1:-1])
 
void lj_assert___LINE__ (int STATIC_ASSERTION_FAILED[((int) BC_DIVVV-(int) BC_ADDVV==(int) OPR_DIV-(int) OPR_ADD)?1:-1])
 
void lj_assert___LINE__ (int STATIC_ASSERTION_FAILED[((int) BC_MODVV-(int) BC_ADDVV==(int) OPR_MOD-(int) OPR_ADD)?1:-1])
 
static LJ_NOINLINE void err_syntax (LexState *ls, ErrMsg em)
 
static LJ_NOINLINE void err_token (LexState *ls, LexToken tok)
 
static void err_limit (FuncState *fs, uint32_t limit, const char *what)
 
static BCReg const_num (FuncState *fs, ExpDesc *e)
 
static BCReg const_gc (FuncState *fs, GCobj *gc, uint32_t itype)
 
static BCReg const_str (FuncState *fs, ExpDesc *e)
 
GCstrlj_parse_keepstr (LexState *ls, const char *str, size_t len)
 
void lj_parse_keepcdata (LexState *ls, TValue *tv, GCcdata *cd)
 
static BCPos jmp_next (FuncState *fs, BCPos pc)
 
static int jmp_novalue (FuncState *fs, BCPos list)
 
static int jmp_patchtestreg (FuncState *fs, BCPos pc, BCReg reg)
 
static void jmp_dropval (FuncState *fs, BCPos list)
 
static void jmp_patchins (FuncState *fs, BCPos pc, BCPos dest)
 
static void jmp_append (FuncState *fs, BCPos *l1, BCPos l2)
 
static void jmp_patchval (FuncState *fs, BCPos list, BCPos vtarget, BCReg reg, BCPos dtarget)
 
static void jmp_tohere (FuncState *fs, BCPos list)
 
static void jmp_patch (FuncState *fs, BCPos list, BCPos target)
 
static void bcreg_bump (FuncState *fs, BCReg n)
 
static void bcreg_reserve (FuncState *fs, BCReg n)
 
static void bcreg_free (FuncState *fs, BCReg reg)
 
static void expr_free (FuncState *fs, ExpDesc *e)
 
static BCPos bcemit_INS (FuncState *fs, BCIns ins)
 
static void expr_discharge (FuncState *fs, ExpDesc *e)
 
static void bcemit_nil (FuncState *fs, BCReg from, BCReg n)
 
static void expr_toreg_nobranch (FuncState *fs, ExpDesc *e, BCReg reg)
 
static BCPos bcemit_jmp (FuncState *fs)
 
static void expr_toreg (FuncState *fs, ExpDesc *e, BCReg reg)
 
static void expr_tonextreg (FuncState *fs, ExpDesc *e)
 
static BCReg expr_toanyreg (FuncState *fs, ExpDesc *e)
 
static void expr_toval (FuncState *fs, ExpDesc *e)
 
static void bcemit_store (FuncState *fs, ExpDesc *var, ExpDesc *e)
 
static void bcemit_method (FuncState *fs, ExpDesc *e, ExpDesc *key)
 
static void invertcond (FuncState *fs, ExpDesc *e)
 
static BCPos bcemit_branch (FuncState *fs, ExpDesc *e, int cond)
 
static void bcemit_branch_t (FuncState *fs, ExpDesc *e)
 
static void bcemit_branch_f (FuncState *fs, ExpDesc *e)
 
static int foldarith (BinOpr opr, ExpDesc *e1, ExpDesc *e2)
 
static void bcemit_arith (FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2)
 
static void bcemit_comp (FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2)
 
static void bcemit_binop_left (FuncState *fs, BinOpr op, ExpDesc *e)
 
static void bcemit_binop (FuncState *fs, BinOpr op, ExpDesc *e1, ExpDesc *e2)
 
static void bcemit_unop (FuncState *fs, BCOp op, ExpDesc *e)
 
static int lex_opt (LexState *ls, LexToken tok)
 
static void lex_check (LexState *ls, LexToken tok)
 
static void lex_match (LexState *ls, LexToken what, LexToken who, BCLine line)
 
static GCstrlex_str (LexState *ls)
 
static void var_new (LexState *ls, BCReg n, GCstr *name)
 
static void var_add (LexState *ls, BCReg nvars)
 
static void var_remove (LexState *ls, BCReg tolevel)
 
static BCReg var_lookup_local (FuncState *fs, GCstr *n)
 
static MSize var_lookup_uv (FuncState *fs, MSize vidx, ExpDesc *e)
 
static void fscope_uvmark (FuncState *fs, BCReg level)
 
static MSize var_lookup_ (FuncState *fs, GCstr *name, ExpDesc *e, int first)
 
static MSize gola_new (LexState *ls, GCstr *name, uint8_t info, BCPos pc)
 
static void gola_patch (LexState *ls, VarInfo *vg, VarInfo *vl)
 
static void gola_close (LexState *ls, VarInfo *vg)
 
static void gola_resolve (LexState *ls, FuncScope *bl, MSize idx)
 
static void gola_fixup (LexState *ls, FuncScope *bl)
 
static VarInfogola_findlabel (LexState *ls, GCstr *name)
 
static void fscope_begin (FuncState *fs, FuncScope *bl, int flags)
 
static void fscope_end (FuncState *fs)
 
static void fs_fixup_bc (FuncState *fs, GCproto *pt, BCIns *bc, MSize n)
 
static void fs_fixup_uv2 (FuncState *fs, GCproto *pt)
 
static void fs_fixup_k (FuncState *fs, GCproto *pt, void *kptr)
 
static void fs_fixup_uv1 (FuncState *fs, GCproto *pt, uint16_t *uv)
 
static size_t fs_prep_line (FuncState *fs, BCLine numline)
 
static void fs_fixup_line (FuncState *fs, GCproto *pt, void *lineinfo, BCLine numline)
 
static size_t fs_prep_var (LexState *ls, FuncState *fs, size_t *ofsvar)
 
static void fs_fixup_var (LexState *ls, GCproto *pt, uint8_t *p, size_t ofsvar)
 
static int bcopisret (BCOp op)
 
static void fs_fixup_ret (FuncState *fs)
 
static GCprotofs_finish (LexState *ls, BCLine line)
 
static void fs_init (LexState *ls, FuncState *fs)
 
static void expr (LexState *ls, ExpDesc *v)
 
static void expr_str (LexState *ls, ExpDesc *e)
 
static void expr_index (FuncState *fs, ExpDesc *t, ExpDesc *e)
 
static void expr_field (LexState *ls, ExpDesc *v)
 
static void expr_bracket (LexState *ls, ExpDesc *v)
 
static void expr_kvalue (TValue *v, ExpDesc *e)
 
static void expr_table (LexState *ls, ExpDesc *e)
 
static BCReg parse_params (LexState *ls, int needself)
 
static void parse_chunk (LexState *ls)
 
static void parse_body (LexState *ls, ExpDesc *e, int needself, BCLine line)
 
static BCReg expr_list (LexState *ls, ExpDesc *v)
 
static void parse_args (LexState *ls, ExpDesc *e)
 
static void expr_primary (LexState *ls, ExpDesc *v)
 
static void expr_simple (LexState *ls, ExpDesc *v)
 
static void synlevel_begin (LexState *ls)
 
static BinOpr token2binop (LexToken tok)
 
static BinOpr expr_binop (LexState *ls, ExpDesc *v, uint32_t limit)
 
static void expr_unop (LexState *ls, ExpDesc *v)
 
static void expr_next (LexState *ls)
 
static BCPos expr_cond (LexState *ls)
 
static void assign_hazard (LexState *ls, LHSVarList *lh, const ExpDesc *v)
 
static void assign_adjust (LexState *ls, BCReg nvars, BCReg nexps, ExpDesc *e)
 
static void parse_assignment (LexState *ls, LHSVarList *lh, BCReg nvars)
 
static void parse_call_assign (LexState *ls)
 
static void parse_local (LexState *ls)
 
static void parse_func (LexState *ls, BCLine line)
 
static int parse_isend (LexToken tok)
 
static void parse_return (LexState *ls)
 
static void parse_break (LexState *ls)
 
static void parse_goto (LexState *ls)
 
static void parse_label (LexState *ls)
 
static void parse_block (LexState *ls)
 
static void parse_while (LexState *ls, BCLine line)
 
static void parse_repeat (LexState *ls, BCLine line)
 
static void parse_for_num (LexState *ls, GCstr *varname, BCLine line)
 
static int predict_next (LexState *ls, FuncState *fs, BCPos pc)
 
static void parse_for_iter (LexState *ls, GCstr *indexname)
 
static void parse_for (LexState *ls, BCLine line)
 
static BCPos parse_then (LexState *ls)
 
static void parse_if (LexState *ls, BCLine line)
 
static int parse_stmt (LexState *ls)
 
GCprotolj_parse (LexState *ls)
 

Variables

struct {
   uint8_t   left
 
   uint8_t   right
 
priority []
 

Macro Definition Documentation

◆ bcemit_ABC

#define bcemit_ABC (   fs,
  o,
  a,
  b,
  c 
)    bcemit_INS(fs, BCINS_ABC(o, a, b, c))

Definition at line 428 of file lj_parse.c.

◆ bcemit_AD

#define bcemit_AD (   fs,
  o,
  a,
  d 
)    bcemit_INS(fs, BCINS_AD(o, a, d))

Definition at line 429 of file lj_parse.c.

◆ bcemit_AJ

#define bcemit_AJ (   fs,
  o,
  a,
  j 
)    bcemit_INS(fs, BCINS_AJ(o, a, j))

Definition at line 430 of file lj_parse.c.

◆ bcptr

#define bcptr (   fs,
  e 
)    (&(fs)->bcbase[(e)->u.s.info].ins)

Definition at line 432 of file lj_parse.c.

◆ checkcond

#define checkcond (   ls,
  c,
  em 
)    { if (!(c)) err_syntax(ls, em); }

Definition at line 188 of file lj_parse.c.

◆ checklimit

#define checklimit (   fs,
  v,
  l,
  m 
)    if ((v) >= (l)) err_limit(fs, l, m)

Definition at line 186 of file lj_parse.c.

◆ checklimitgt

#define checklimitgt (   fs,
  v,
  l,
  m 
)    if ((v) > (l)) err_limit(fs, l, m)

Definition at line 187 of file lj_parse.c.

◆ const_pri

#define const_pri (   e)    check_exp((e)->k <= VKTRUE, (e)->k)

Definition at line 193 of file lj_parse.c.

◆ expr_hasjump

#define expr_hasjump (   e)    ((e)->t != (e)->f)

Definition at line 71 of file lj_parse.c.

◆ expr_isk

#define expr_isk (   e)    ((e)->k <= VKLAST)

Definition at line 73 of file lj_parse.c.

◆ expr_isk_nojump

#define expr_isk_nojump (   e)    (expr_isk(e) && !expr_hasjump(e))

Definition at line 74 of file lj_parse.c.

◆ expr_isnumk

#define expr_isnumk (   e)    ((e)->k == VKNUM)

Definition at line 75 of file lj_parse.c.

◆ expr_isnumk_nojump

#define expr_isnumk_nojump (   e)    (expr_isnumk(e) && !expr_hasjump(e))

Definition at line 76 of file lj_parse.c.

◆ expr_isstrk

#define expr_isstrk (   e)    ((e)->k == VKSTR)

Definition at line 77 of file lj_parse.c.

◆ expr_numberV

#define expr_numberV (   e)    numberVnum(expr_numtv((e)))

Definition at line 80 of file lj_parse.c.

◆ expr_numtv

#define expr_numtv (   e)    check_exp(expr_isnumk((e)), &(e)->u.nval)

Definition at line 79 of file lj_parse.c.

◆ FSCOPE_BREAK

#define FSCOPE_BREAK   0x02 /* Break used in scope. */

Definition at line 106 of file lj_parse.c.

◆ FSCOPE_GOLA

#define FSCOPE_GOLA   0x04 /* Goto or label used in scope. */

Definition at line 107 of file lj_parse.c.

◆ FSCOPE_LOOP

#define FSCOPE_LOOP   0x01 /* Scope is a (breakable) loop. */

Definition at line 105 of file lj_parse.c.

◆ FSCOPE_NOCLOSE

#define FSCOPE_NOCLOSE   0x10 /* Do not close upvalues. */

Definition at line 109 of file lj_parse.c.

◆ FSCOPE_UPVAL

#define FSCOPE_UPVAL   0x08 /* Upvalue in scope. */

Definition at line 108 of file lj_parse.c.

◆ gola_isgoto

#define gola_isgoto (   v)    ((v)->info & VSTACK_GOTO)

Definition at line 1160 of file lj_parse.c.

◆ gola_isgotolabel

#define gola_isgotolabel (   v)    ((v)->info & (VSTACK_GOTO|VSTACK_LABEL))

Definition at line 1162 of file lj_parse.c.

◆ gola_islabel

#define gola_islabel (   v)    ((v)->info & VSTACK_LABEL)

Definition at line 1161 of file lj_parse.c.

◆ LJ_MAX_VSTACK

#define LJ_MAX_VSTACK   (65536 - LJ_MAX_UPVAL)

Definition at line 115 of file lj_parse.c.

◆ lj_parse_c

#define lj_parse_c

Definition at line 9 of file lj_parse.c.

◆ LUA_CORE

#define LUA_CORE

Definition at line 10 of file lj_parse.c.

◆ NAME_BREAK

#define NAME_BREAK   ((GCstr *)(uintptr_t)1)

Definition at line 111 of file lj_parse.c.

◆ synlevel_end

#define synlevel_end (   ls)    ((ls)->level--)

Definition at line 2024 of file lj_parse.c.

◆ tvhaskslot

#define tvhaskslot (   o)    ((o)->u32.hi == 0)

Definition at line 195 of file lj_parse.c.

◆ tvkslot

#define tvkslot (   o)    ((o)->u32.lo)

Definition at line 196 of file lj_parse.c.

◆ UNARY_PRIORITY

#define UNARY_PRIORITY   8 /* Priority for unary operators. */

Definition at line 2061 of file lj_parse.c.

◆ var_get

#define var_get (   ls,
  fs,
  i 
)    ((ls)->vstack[(fs)->varmap[(i)]])

Definition at line 1030 of file lj_parse.c.

◆ var_lookup

#define var_lookup (   ls,
  e 
)     var_lookup_((ls)->fs, lex_str(ls), (e), 1)

Definition at line 1135 of file lj_parse.c.

◆ var_new_fixed

#define var_new_fixed (   ls,
  n,
  vn 
)     var_new(ls, (n), (GCstr *)(uintptr_t)(vn))

Definition at line 1054 of file lj_parse.c.

◆ var_new_lit

#define var_new_lit (   ls,
  n,
  v 
)     var_new(ls, (n), lj_parse_keepstr(ls, "" v, sizeof(v)-1))

Definition at line 1051 of file lj_parse.c.

◆ VSTACK_GOTO

#define VSTACK_GOTO   0x02 /* Pending goto. */

Definition at line 119 of file lj_parse.c.

◆ VSTACK_LABEL

#define VSTACK_LABEL   0x04 /* Label. */

Definition at line 120 of file lj_parse.c.

◆ VSTACK_VAR_RW

#define VSTACK_VAR_RW   0x01 /* R/W variable. */

Definition at line 118 of file lj_parse.c.

Typedef Documentation

◆ BinOpr

typedef enum BinOpr BinOpr

◆ ExpDesc

typedef struct ExpDesc ExpDesc

◆ FuncScope

typedef struct FuncScope FuncScope

◆ FuncState

typedef struct FuncState FuncState

◆ LHSVarList

typedef struct LHSVarList LHSVarList

◆ VarIndex

typedef uint16_t VarIndex

Definition at line 114 of file lj_parse.c.

Enumeration Type Documentation

◆ BinOpr

enum BinOpr
Enumerator
OPR_ADD 
OPR_SUB 
OPR_MUL 
OPR_MOD 
OPR_POW 
OPR_DIV 
OPR_IDIV 
OPR_BAND 
OPR_BOR 
OPR_BXOR 
OPR_SHL 
OPR_SHR 
OPR_CONCAT 
OPR_EQ 
OPR_LT 
OPR_LE 
OPR_NE 
OPR_GT 
OPR_GE 
OPR_AND 
OPR_OR 
OPR_NOBINOPR 
OPR_ADD 
OPR_SUB 
OPR_MUL 
OPR_DIV 
OPR_MOD 
OPR_POW 
OPR_CONCAT 
OPR_NE 
OPR_EQ 
OPR_LT 
OPR_LE 
OPR_GT 
OPR_GE 
OPR_AND 
OPR_OR 
OPR_NOBINOPR 
OPR_ADD 
OPR_SUB 
OPR_MUL 
OPR_DIV 
OPR_MOD 
OPR_POW 
OPR_CONCAT 
OPR_NE 
OPR_EQ 
OPR_LT 
OPR_GE 
OPR_LE 
OPR_GT 
OPR_AND 
OPR_OR 
OPR_NOBINOPR 
OPR_ADD 
OPR_SUB 
OPR_MUL 
OPR_MOD 
OPR_POW 
OPR_DIV 
OPR_IDIV 
OPR_BAND 
OPR_BOR 
OPR_BXOR 
OPR_SHL 
OPR_SHR 
OPR_CONCAT 
OPR_EQ 
OPR_LT 
OPR_LE 
OPR_NE 
OPR_GT 
OPR_GE 
OPR_AND 
OPR_OR 
OPR_NOBINOPR 
OPR_ADD 
OPR_SUB 
OPR_MUL 
OPR_DIV 
OPR_MOD 
OPR_POW 
OPR_CONCAT 
OPR_NE 
OPR_EQ 
OPR_LT 
OPR_LE 
OPR_GT 
OPR_GE 
OPR_AND 
OPR_OR 
OPR_NOBINOPR 
OPR_ADD 
OPR_SUB 
OPR_MUL 
OPR_DIV 
OPR_MOD 
OPR_POW 
OPR_CONCAT 
OPR_NE 
OPR_EQ 
OPR_LT 
OPR_GE 
OPR_LE 
OPR_GT 
OPR_AND 
OPR_OR 
OPR_NOBINOPR 

Definition at line 149 of file lj_parse.c.

◆ ExpKind

enum ExpKind
Enumerator
VKNIL 
VKFALSE 
VKTRUE 
VKSTR 
VKNUM 
VKLAST 
VKCDATA 
VLOCAL 
VUPVAL 
VGLOBAL 
VINDEXED 
VJMP 
VRELOCABLE 
VNONRELOC 
VCALL 
VVOID 
VKNIL 
VKFALSE 
VKTRUE 
VKSTR 
VKNUM 
VKLAST 
VKCDATA 
VLOCAL 
VUPVAL 
VGLOBAL 
VINDEXED 
VJMP 
VRELOCABLE 
VNONRELOC 
VCALL 
VVOID 

Definition at line 34 of file lj_parse.c.

Function Documentation

◆ assign_adjust()

static void assign_adjust ( LexState ls,
BCReg  nvars,
BCReg  nexps,
ExpDesc e 
)
static

◆ assign_hazard()

static void assign_hazard ( LexState ls,
LHSVarList lh,
const ExpDesc v 
)
static

Definition at line 2139 of file lj_parse.c.

References BC_MOV, bcemit_AD, bcreg_reserve(), FuncState::freereg, LexState::fs, lh, reg, v, and VINDEXED.

Referenced by parse_assignment().

◆ bcemit_arith()

◆ bcemit_binop()

◆ bcemit_binop_left()

static void bcemit_binop_left ( FuncState fs,
BinOpr  op,
ExpDesc e 
)
static

◆ bcemit_branch()

◆ bcemit_branch_f()

static void bcemit_branch_f ( FuncState fs,
ExpDesc e 
)
static

◆ bcemit_branch_t()

static void bcemit_branch_t ( FuncState fs,
ExpDesc e 
)
static

◆ bcemit_comp()

◆ bcemit_INS()

◆ bcemit_jmp()

◆ bcemit_method()

static void bcemit_method ( FuncState fs,
ExpDesc e,
ExpDesc key 
)
static

◆ bcemit_nil()

static void bcemit_nil ( FuncState fs,
BCReg  from,
BCReg  n 
)
static

◆ bcemit_store()

◆ bcemit_unop()

◆ bcopisret()

static int bcopisret ( BCOp  op)
static

Definition at line 1500 of file lj_parse.c.

References BC_CALLMT, BC_CALLT, BC_RET, BC_RET0, BC_RET1, and BC_RETM.

Referenced by fs_fixup_ret().

◆ bcreg_bump()

static void bcreg_bump ( FuncState fs,
BCReg  n 
)
static

◆ bcreg_free()

static void bcreg_free ( FuncState fs,
BCReg  reg 
)
static

Definition at line 391 of file lj_parse.c.

References FuncState::freereg, lua_assert, FuncState::nactvar, and reg.

Referenced by bcemit_store(), expr_discharge(), and expr_free().

◆ bcreg_reserve()

◆ const_gc()

static BCReg const_gc ( FuncState fs,
GCobj gc,
uint32_t  itype 
)
static

◆ const_num()

◆ const_str()

static BCReg const_str ( FuncState fs,
ExpDesc e 
)
static

◆ err_limit()

static void err_limit ( FuncState fs,
uint32_t  limit,
const char *  what 
)
static

◆ err_syntax()

static LJ_NOINLINE void err_syntax ( LexState ls,
ErrMsg  em 
)
static

◆ err_token()

static LJ_NOINLINE void err_token ( LexState ls,
LexToken  tok 
)
static

◆ expr()

static void expr ( LexState ls,
ExpDesc v 
)
static

Definition at line 2107 of file lj_parse.c.

References expr_binop(), and v.

Referenced by expr_bracket(), expr_cond(), expr_list(), expr_next(), expr_primary(), and expr_table().

◆ expr_binop()

static BinOpr expr_binop ( LexState ls,
ExpDesc v,
uint32_t  limit 
)
static

◆ expr_bracket()

static void expr_bracket ( LexState ls,
ExpDesc v 
)
static

Definition at line 1679 of file lj_parse.c.

References expr(), expr_toval(), LexState::fs, lex_check(), lj_lex_next(), FuncState::ls, and v.

Referenced by expr_primary(), and expr_table().

◆ expr_cond()

static BCPos expr_cond ( LexState ls)
static

Definition at line 2121 of file lj_parse.c.

References bcemit_branch_t(), expr(), LexState::fs, v, VKFALSE, and VKNIL.

Referenced by parse_repeat(), parse_then(), and parse_while().

◆ expr_discharge()

◆ expr_field()

static void expr_field ( LexState ls,
ExpDesc v 
)
static

Definition at line 1668 of file lj_parse.c.

References expr_index(), expr_str(), expr_toanyreg(), LexState::fs, key, lj_lex_next(), FuncState::ls, and v.

Referenced by expr_primary(), and parse_func().

◆ expr_free()

static void expr_free ( FuncState fs,
ExpDesc e 
)
static

◆ expr_index()

static void expr_index ( FuncState fs,
ExpDesc t,
ExpDesc e 
)
static

◆ expr_init()

static LJ_AINLINE void expr_init ( ExpDesc e,
ExpKind  k,
uint32_t  info 
)
static

Definition at line 83 of file lj_parse.c.

References e, info, k, and NO_JMP.

Referenced by expr_simple(), expr_str(), expr_table(), parse_args(), parse_assignment(), parse_body(), parse_local(), and var_lookup_().

◆ expr_kvalue()

static void expr_kvalue ( TValue v,
ExpDesc e 
)
static

Definition at line 1688 of file lj_parse.c.

References e, expr_numtv, LJ_TSTR, lua_assert, obj2gco, setgcVraw(), setpriV, tvisnumber, v, VKSTR, and VKTRUE.

Referenced by expr_table().

◆ expr_list()

static BCReg expr_list ( LexState ls,
ExpDesc v 
)
static

◆ expr_next()

static void expr_next ( LexState ls)
static

Definition at line 2113 of file lj_parse.c.

References e, expr(), expr_tonextreg(), and LexState::fs.

Referenced by parse_for_num().

◆ expr_numiszero()

static int expr_numiszero ( ExpDesc e)
static

Definition at line 91 of file lj_parse.c.

References e, expr_numtv, intV, tvisint, and tviszero.

Referenced by bcemit_unop(), and expr_table().

◆ expr_primary()

◆ expr_simple()

◆ expr_str()

static void expr_str ( LexState ls,
ExpDesc e 
)
static

Definition at line 1629 of file lj_parse.c.

References e, expr_init(), lex_str(), FuncState::ls, and VKSTR.

Referenced by expr_field(), expr_primary(), and expr_table().

◆ expr_table()

◆ expr_toanyreg()

◆ expr_tonextreg()

◆ expr_toreg()

◆ expr_toreg_nobranch()

◆ expr_toval()

static void expr_toval ( FuncState fs,
ExpDesc e 
)
static

◆ expr_unop()

static void expr_unop ( LexState ls,
ExpDesc v 
)
static

◆ foldarith()

static int foldarith ( BinOpr  opr,
ExpDesc e1,
ExpDesc e2 
)
static

◆ fs_finish()

◆ fs_fixup_bc()

static void fs_fixup_bc ( FuncState fs,
GCproto pt,
BCIns bc,
MSize  n 
)
static

Definition at line 1308 of file lj_parse.c.

References base, bc, BC_FUNCF, BC_FUNCV, FuncState::bcbase, BCINS_AD, FuncState::flags, FuncState::framesize, i, ins, n, PROTO_VARARG, and pt.

Referenced by fs_finish().

◆ fs_fixup_k()

◆ fs_fixup_line()

static void fs_fixup_line ( FuncState fs,
GCproto pt,
void lineinfo,
BCLine  numline 
)
static

◆ fs_fixup_ret()

◆ fs_fixup_uv1()

static void fs_fixup_uv1 ( FuncState fs,
GCproto pt,
uint16_t uv 
)
static

Definition at line 1390 of file lj_parse.c.

References memcpy, FuncState::nuv, pt, setmref, and FuncState::uvtmp.

Referenced by fs_finish().

◆ fs_fixup_uv2()

static void fs_fixup_uv2 ( FuncState fs,
GCproto pt 
)
static

◆ fs_fixup_var()

static void fs_fixup_var ( LexState ls,
GCproto pt,
uint8_t p,
size_t  ofsvar 
)
static

Definition at line 1481 of file lj_parse.c.

References FuncState::ls, memcpy, p, pt, LexState::sb, sbufB, sbuflen, and setmref.

Referenced by fs_finish().

◆ fs_init()

◆ fs_prep_line()

static size_t fs_prep_line ( FuncState fs,
BCLine  numline 
)
static

Definition at line 1399 of file lj_parse.c.

References numline, and FuncState::pc.

Referenced by fs_finish().

◆ fs_prep_var()

◆ fscope_begin()

◆ fscope_end()

◆ fscope_uvmark()

static void fscope_uvmark ( FuncState fs,
BCReg  level 
)
static

Definition at line 1296 of file lj_parse.c.

References FuncState::bl, FSCOPE_UPVAL, level, and BlockCnt::nactvar.

Referenced by var_lookup_().

◆ gola_close()

◆ gola_findlabel()

static VarInfo* gola_findlabel ( LexState ls,
GCstr name 
)
static

◆ gola_fixup()

◆ gola_new()

◆ gola_patch()

static void gola_patch ( LexState ls,
VarInfo vg,
VarInfo vl 
)
static

◆ gola_resolve()

◆ invertcond()

static void invertcond ( FuncState fs,
ExpDesc e 
)
static

Definition at line 701 of file lj_parse.c.

References bc_op, FuncState::bcbase, e, BCInsLine::ins, ip, and setbc_op.

Referenced by bcemit_branch_t(), and bcemit_unop().

◆ jmp_append()

static void jmp_append ( FuncState fs,
BCPos l1,
BCPos  l2 
)
static

◆ jmp_dropval()

static void jmp_dropval ( FuncState fs,
BCPos  list 
)
static

Definition at line 305 of file lj_parse.c.

References jmp_next(), jmp_patchtestreg(), NO_JMP, and NO_REG.

Referenced by bcemit_unop().

◆ jmp_next()

static BCPos jmp_next ( FuncState fs,
BCPos  pc 
)
static

Definition at line 258 of file lj_parse.c.

References bc_j, FuncState::bcbase, delta, BCInsLine::ins, NO_JMP, and pc.

Referenced by gola_close(), jmp_append(), jmp_dropval(), jmp_novalue(), and jmp_patchval().

◆ jmp_novalue()

static int jmp_novalue ( FuncState fs,
BCPos  list 
)
static

Definition at line 268 of file lj_parse.c.

References bc_a, BC_ISFC, BC_ISTC, bc_op, FuncState::bcbase, BCInsLine::ins, jmp_next(), NO_JMP, NO_REG, and p.

Referenced by expr_toreg().

◆ jmp_patch()

static void jmp_patch ( FuncState fs,
BCPos  list,
BCPos  target 
)
static

Definition at line 360 of file lj_parse.c.

References jmp_patchval(), jmp_tohere(), lua_assert, NO_REG, pc, FuncState::pc, and target.

Referenced by gola_close(), gola_patch(), parse_repeat(), and parse_while().

◆ jmp_patchins()

◆ jmp_patchtestreg()

static int jmp_patchtestreg ( FuncState fs,
BCPos  pc,
BCReg  reg 
)
static

Definition at line 279 of file lj_parse.c.

References bc_a, bc_d, BC_ISFC, BC_IST, BC_ISTC, BC_JMP, bc_op, FuncState::bcbase, BCINS_AJ, ins, BCInsLine::ins, NO_REG, pc, reg, setbc_a, and setbc_op.

Referenced by jmp_dropval(), and jmp_patchval().

◆ jmp_patchval()

static void jmp_patchval ( FuncState fs,
BCPos  list,
BCPos  vtarget,
BCReg  reg,
BCPos  dtarget 
)
static

Definition at line 339 of file lj_parse.c.

References jmp_next(), jmp_patchins(), jmp_patchtestreg(), next, NO_JMP, and reg.

Referenced by bcemit_INS(), expr_toreg(), and jmp_patch().

◆ jmp_tohere()

static void jmp_tohere ( FuncState fs,
BCPos  list 
)
static

◆ lex_check()

◆ lex_match()

◆ lex_opt()

◆ lex_str()

◆ lj_assert___LINE__() [1/7]

void lj_assert___LINE__ ( int  STATIC_ASSERTION_FAILED[((int) BC_DIVVV-(int) BC_ADDVV==(int) OPR_DIV-(int) OPR_ADD)?1:-1])

◆ lj_assert___LINE__() [2/7]

void lj_assert___LINE__ ( int  STATIC_ASSERTION_FAILED[((int) BC_ISGE-(int) BC_ISLT==(int) OPR_GE-(int) OPR_LT)?1:-1])

◆ lj_assert___LINE__() [3/7]

void lj_assert___LINE__ ( int  STATIC_ASSERTION_FAILED[((int) BC_ISGT-(int) BC_ISLT==(int) OPR_GT-(int) OPR_LT)?1:-1])

◆ lj_assert___LINE__() [4/7]

void lj_assert___LINE__ ( int  STATIC_ASSERTION_FAILED[((int) BC_ISLE-(int) BC_ISLT==(int) OPR_LE-(int) OPR_LT)?1:-1])

◆ lj_assert___LINE__() [5/7]

void lj_assert___LINE__ ( int  STATIC_ASSERTION_FAILED[((int) BC_MODVV-(int) BC_ADDVV==(int) OPR_MOD-(int) OPR_ADD)?1:-1])

◆ lj_assert___LINE__() [6/7]

void lj_assert___LINE__ ( int  STATIC_ASSERTION_FAILED[((int) BC_MULVV-(int) BC_ADDVV==(int) OPR_MUL-(int) OPR_ADD)?1:-1])

◆ lj_assert___LINE__() [7/7]

void lj_assert___LINE__ ( int  STATIC_ASSERTION_FAILED[((int) BC_SUBVV-(int) BC_ADDVV==(int) OPR_SUB-(int) OPR_ADD)?1:-1])

◆ lj_parse()

◆ lj_parse_keepcdata()

void lj_parse_keepcdata ( LexState ls,
TValue tv,
GCcdata cd 
)

Definition at line 246 of file lj_parse.c.

References LexState::fs, FuncState::kt, L, LexState::L, lj_tab_set(), FuncState::ls, setboolV, and setcdataV().

Referenced by lex_number().

◆ lj_parse_keepstr()

GCstr* lj_parse_keepstr ( LexState ls,
const char *  str,
size_t  len 
)

◆ parse_args()

◆ parse_assignment()

◆ parse_block()

static void parse_block ( LexState ls)
static

◆ parse_body()

◆ parse_break()

static void parse_break ( LexState ls)
static

Definition at line 2344 of file lj_parse.c.

References bcemit_jmp(), FuncState::bl, LexState::fs, FSCOPE_BREAK, gola_new(), NAME_BREAK, and VSTACK_GOTO.

Referenced by parse_repeat(), and parse_stmt().

◆ parse_call_assign()

static void parse_call_assign ( LexState ls)
static

◆ parse_chunk()

◆ parse_for()

◆ parse_for_iter()

◆ parse_for_num()

◆ parse_func()

static void parse_func ( LexState ls,
BCLine  line 
)
static

◆ parse_goto()

static void parse_goto ( LexState ls)
static

◆ parse_if()

static void parse_if ( LexState ls,
BCLine  line 
)
static

◆ parse_isend()

static int parse_isend ( LexToken  tok)
static

Definition at line 2295 of file lj_parse.c.

References TK_else, TK_elseif, TK_end, TK_eof, TK_until, and tok().

Referenced by parse_chunk(), parse_label(), and parse_return().

◆ parse_label()

◆ parse_local()

◆ parse_params()

◆ parse_repeat()

◆ parse_return()

◆ parse_stmt()

◆ parse_then()

static BCPos parse_then ( LexState ls)
static

Definition at line 2585 of file lj_parse.c.

References expr_cond(), lex_check(), lj_lex_next(), parse_block(), and TK_then.

Referenced by parse_if().

◆ parse_while()

◆ predict_next()

◆ synlevel_begin()

static void synlevel_begin ( LexState ls)
static

Definition at line 2018 of file lj_parse.c.

References LexState::level, lj_lex_error(), LJ_MAX_XLEVEL, and FuncState::ls.

Referenced by expr_binop(), parse_chunk(), and parse_label().

◆ token2binop()

static BinOpr token2binop ( LexToken  tok)
static

◆ var_add()

static void var_add ( LexState ls,
BCReg  nvars 
)
static

◆ var_lookup_()

static MSize var_lookup_ ( FuncState fs,
GCstr name,
ExpDesc e,
int  first 
)
static

◆ var_lookup_local()

static BCReg var_lookup_local ( FuncState fs,
GCstr n 
)
static

Definition at line 1080 of file lj_parse.c.

References i, FuncState::ls, n, FuncState::nactvar, strref, and var_get.

Referenced by var_lookup_().

◆ var_lookup_uv()

static MSize var_lookup_uv ( FuncState fs,
MSize  vidx,
ExpDesc e 
)
static

◆ var_new()

◆ var_remove()

static void var_remove ( LexState ls,
BCReg  tolevel 
)
static

Definition at line 1072 of file lj_parse.c.

References LexState::fs, FuncState::ls, FuncState::nactvar, FuncState::pc, and var_get.

Referenced by fscope_end().

Variable Documentation

◆ left

uint8_t left ( void  )

Definition at line 2051 of file lj_parse.c.

◆ 

priority[] { ... } const struct
Initial value:
= {
{6,6}, {6,6}, {7,7}, {7,7}, {7,7},
{10,9}, {5,4},
{3,3}, {3,3},
{3,3}, {3,3}, {3,3}, {3,3},
{2,2}, {1,1}
}

Referenced by expr_binop().

◆ right

uint8_t right ( void  )

Definition at line 2052 of file lj_parse.c.

Referenced by expr_binop().