MCPcopy Create free account
hub / github.com/DFHack/dfhack / simpleexp

Function simpleexp

depends/lua/src/lparser.c:932–984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

930
931
932static void simpleexp (LexState *ls, expdesc *v) {
933 /* simpleexp -> FLT | INT | STRING | NIL | TRUE | FALSE | ... |
934 constructor | FUNCTION body | suffixedexp */
935 switch (ls->t.token) {
936 case TK_FLT: {
937 init_exp(v, VKFLT, 0);
938 v->u.nval = ls->t.seminfo.r;
939 break;
940 }
941 case TK_INT: {
942 init_exp(v, VKINT, 0);
943 v->u.ival = ls->t.seminfo.i;
944 break;
945 }
946 case TK_STRING: {
947 codestring(ls, v, ls->t.seminfo.ts);
948 break;
949 }
950 case TK_NIL: {
951 init_exp(v, VNIL, 0);
952 break;
953 }
954 case TK_TRUE: {
955 init_exp(v, VTRUE, 0);
956 break;
957 }
958 case TK_FALSE: {
959 init_exp(v, VFALSE, 0);
960 break;
961 }
962 case TK_DOTS: { /* vararg */
963 FuncState *fs = ls->fs;
964 check_condition(ls, fs->f->is_vararg,
965 "cannot use '...' outside a vararg function");
966 init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
967 break;
968 }
969 case '{': { /* constructor */
970 constructor(ls, v);
971 return;
972 }
973 case TK_FUNCTION: {
974 luaX_next(ls);
975 body(ls, v, 0, ls->linenumber);
976 return;
977 }
978 default: {
979 suffixedexp(ls, v);
980 return;
981 }
982 }
983 luaX_next(ls);
984}
985
986
987static UnOpr getunopr (int op) {

Callers 1

subexprFunction · 0.85

Calls 7

init_expFunction · 0.85
codestringFunction · 0.85
luaK_codeABCFunction · 0.85
constructorFunction · 0.85
luaX_nextFunction · 0.85
bodyFunction · 0.85
suffixedexpFunction · 0.85

Tested by

no test coverage detected