MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / simpleexp

Function simpleexp

Source/Misc/lua/src/lua.c:8303–8351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8301
8302
8303static void simpleexp (LexState *ls, expdesc *v) {
8304/* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
8305constructor | FUNCTION body | primaryexp */
8306switch (ls->t.token) {
8307case TK_NUMBER: {
8308init_exp(v, VKNUM, 0);
8309v->u.nval = ls->t.seminfo.r;
8310break;
8311}
8312case TK_STRING: {
8313codestring(ls, v, ls->t.seminfo.ts);
8314break;
8315}
8316case TK_NIL: {
8317init_exp(v, VNIL, 0);
8318break;
8319}
8320case TK_TRUE: {
8321init_exp(v, VTRUE, 0);
8322break;
8323}
8324case TK_FALSE: {
8325init_exp(v, VFALSE, 0);
8326break;
8327}
8328case TK_DOTS: { /* vararg */
8329FuncState *fs = ls->fs;
8330check_condition(ls, fs->f->is_vararg,
8331"cannot use " LUA_QL("...") " outside a vararg function");
8332fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */
8333init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
8334break;
8335}
8336case '{': { /* constructor */
8337constructor(ls, v);
8338return;
8339}
8340case TK_FUNCTION: {
8341luaX_next(ls);
8342body(ls, v, 0, ls->linenumber);
8343return;
8344}
8345default: {
8346primaryexp(ls, v);
8347return;
8348}
8349}
8350luaX_next(ls);
8351}
8352
8353
8354static UnOpr getunopr (int op) {

Callers 1

subexprFunction · 0.85

Calls 7

init_expFunction · 0.85
codestringFunction · 0.85
luaK_codeABCFunction · 0.85
luaX_nextFunction · 0.85
bodyFunction · 0.85
primaryexpFunction · 0.85
constructorFunction · 0.70

Tested by

no test coverage detected