Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lobject.c File Reference
#include "lprefix.h"
#include <locale.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lctype.h"
#include "ldebug.h"
#include "ldo.h"
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"
#include "lstring.h"
#include "lvm.h"

Go to the source code of this file.

Macros

#define lobject_c
 
#define LUA_CORE
 
#define L_MAXLENNUM   200
 
#define MAXBY10   cast(lua_Unsigned, LUA_MAXINTEGER / 10)
 
#define MAXLASTD   cast_int(LUA_MAXINTEGER % 10)
 
#define MAXNUMBER2STR   50
 
#define LL(x)   (sizeof(x)/sizeof(char) - 1)
 
#define RETS   "..."
 
#define PRE   "[string \""
 
#define POS   "\"]"
 
#define addstr(a, b, l)   ( memcpy(a,b,(l) * sizeof(char)), a += (l) )
 

Functions

int luaO_int2fb (unsigned int x)
 
int luaO_fb2int (int x)
 
int luaO_ceillog2 (unsigned int x)
 
static lua_Integer intarith (lua_State *L, int op, lua_Integer v1, lua_Integer v2)
 
static lua_Number numarith (lua_State *L, int op, lua_Number v1, lua_Number v2)
 
void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, TValue *res)
 
int luaO_hexavalue (int c)
 
static int isneg (const char **s)
 
static const char * l_str2dloc (const char *s, lua_Number *result, int mode)
 
static const char * l_str2d (const char *s, lua_Number *result)
 
static const char * l_str2int (const char *s, lua_Integer *result)
 
size_t luaO_str2num (const char *s, TValue *o)
 
int luaO_utf8esc (char *buff, unsigned long x)
 
void luaO_tostring (lua_State *L, StkId obj)
 
static void pushstr (lua_State *L, const char *str, size_t l)
 
const char * luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp)
 
const char * luaO_pushfstring (lua_State *L, const char *fmt,...)
 
void luaO_chunkid (char *out, const char *source, size_t bufflen)
 

Variables

LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT}
 

Macro Definition Documentation

◆ addstr

#define addstr ( a,
b,
l )   ( memcpy(a,b,(l) * sizeof(char)), a += (l) )

Definition at line 485 of file lua-5.3.6/src/lobject.c.

Referenced by luaO_chunkid().

◆ L_MAXLENNUM

#define L_MAXLENNUM   200

Definition at line 248 of file lua-5.3.6/src/lobject.c.

Referenced by l_str2d().

◆ LL

#define LL ( x)    (sizeof(x)/sizeof(char) - 1)

Definition at line 479 of file lua-5.3.6/src/lobject.c.

Referenced by luaO_chunkid().

◆ lobject_c

#define lobject_c

Definition at line 7 of file lua-5.3.6/src/lobject.c.

◆ LUA_CORE

#define LUA_CORE

Definition at line 8 of file lua-5.3.6/src/lobject.c.

◆ MAXBY10

#define MAXBY10   cast(lua_Unsigned, LUA_MAXINTEGER / 10)

Definition at line 296 of file lua-5.3.6/src/lobject.c.

Referenced by l_str2int().

◆ MAXLASTD

#define MAXLASTD   cast_int(LUA_MAXINTEGER % 10)

Definition at line 297 of file lua-5.3.6/src/lobject.c.

Referenced by l_str2int().

◆ MAXNUMBER2STR

#define MAXNUMBER2STR   50

Definition at line 365 of file lua-5.3.6/src/lobject.c.

Referenced by luaO_tostring().

◆ POS

#define POS   "\"]"

Definition at line 483 of file lua-5.3.6/src/lobject.c.

Referenced by luaO_chunkid().

◆ PRE

#define PRE   "[string \""

Definition at line 482 of file lua-5.3.6/src/lobject.c.

Referenced by luaO_chunkid().

◆ RETS

#define RETS   "..."

Definition at line 481 of file lua-5.3.6/src/lobject.c.

Referenced by luaO_chunkid().

Function Documentation

◆ intarith()

static lua_Integer intarith ( lua_State * L,
int op,
lua_Integer v1,
lua_Integer v2 )
static

Definition at line 83 of file lua-5.3.6/src/lobject.c.

84 {
85 switch (op) {
86 case LUA_OPADD: return intop(+, v1, v2);
87 case LUA_OPSUB:return intop(-, v1, v2);
88 case LUA_OPMUL:return intop(*, v1, v2);
89 case LUA_OPMOD: return luaV_mod(L, v1, v2);
90 case LUA_OPIDIV: return luaV_div(L, v1, v2);
91 case LUA_OPBAND: return intop(&, v1, v2);
92 case LUA_OPBOR: return intop(|, v1, v2);
93 case LUA_OPBXOR: return intop(^, v1, v2);
94 case LUA_OPSHL: return luaV_shiftl(v1, v2);
95 case LUA_OPSHR: return luaV_shiftl(v1, -v2);
96 case LUA_OPUNM: return intop(-, 0, v1);
97 case LUA_OPBNOT: return intop(^, ~l_castS2U(0), v1);
98 default: lua_assert(0); return 0;
99 }
100}
#define lua_assert(c)
#define LUA_OPSUB
#define LUA_OPMUL
#define LUA_OPMOD
#define LUA_OPADD
#define LUA_OPUNM
#define l_castS2U(i)
#define LUA_OPBXOR
#define LUA_OPSHL
#define LUA_OPBOR
#define LUA_OPSHR
#define LUA_OPBNOT
#define LUA_OPBAND
#define LUA_OPIDIV
lua_Integer luaV_div(lua_State *L, lua_Integer m, lua_Integer n)
lua_Integer luaV_shiftl(lua_Integer x, lua_Integer y)
lua_Integer luaV_mod(lua_State *L, lua_Integer m, lua_Integer n)
#define intop(op, v1, v2)

References intop, l_castS2U, lua_assert, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPIDIV, LUA_OPMOD, LUA_OPMUL, LUA_OPSHL, LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, luaV_div(), luaV_mod(), and luaV_shiftl().

Referenced by luaO_arith().

◆ isneg()

static int isneg ( const char ** s)
static

Definition at line 169 of file lua-5.3.6/src/lobject.c.

169 {
170 if (**s == '-') { (*s)++; return 1; }
171 else if (**s == '+') (*s)++;
172 return 0;
173}
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318

References s.

Referenced by l_str2int().

◆ l_str2d()

static const char * l_str2d ( const char * s,
lua_Number * result )
static

Definition at line 274 of file lua-5.3.6/src/lobject.c.

274 {
275 const char *endptr;
276 const char *pmode = strpbrk(s, ".xXnN");
277 int mode = pmode ? ltolower(cast_uchar(*pmode)) : 0;
278 if (mode == 'n') /* reject 'inf' and 'nan' */
279 return NULL;
280 endptr = l_str2dloc(s, result, mode); /* try to convert */
281 if (endptr == NULL) { /* failed? may be a different locale */
282 char buff[L_MAXLENNUM + 1];
283 const char *pdot = strchr(s, '.');
284 if (strlen(s) > L_MAXLENNUM || pdot == NULL)
285 return NULL; /* string too long or no dot; fail */
286 strcpy(buff, s); /* copy string to buffer */
287 buff[pdot - s] = lua_getlocaledecpoint(); /* correct decimal point */
288 endptr = l_str2dloc(buff, result, mode); /* try again */
289 if (endptr != NULL)
290 endptr = s + (endptr - buff); /* make relative to 's' */
291 }
292 return endptr;
293}
#define NULL
Definition gmacros.h:924
#define ltolower(c)
#define cast_uchar(i)
static const char * l_str2dloc(const char *s, lua_Number *result, int mode)
#define L_MAXLENNUM
#define lua_getlocaledecpoint()

References cast_uchar, L_MAXLENNUM, l_str2dloc(), ltolower, lua_getlocaledecpoint, NULL, and s.

Referenced by luaO_str2num().

◆ l_str2dloc()

static const char * l_str2dloc ( const char * s,
lua_Number * result,
int mode )
static

Definition at line 251 of file lua-5.3.6/src/lobject.c.

251 {
252 char *endptr;
253 *result = (mode == 'x') ? lua_strx2number(s, &endptr) /* try to convert */
254 : lua_str2number(s, &endptr);
255 if (endptr == s) return NULL; /* nothing recognized? */
256 while (lisspace(cast_uchar(*endptr))) endptr++; /* skip trailing spaces */
257 return (*endptr == '\0') ? endptr : NULL; /* OK if no trailing characters */
258}
#define lua_str2number(s, p)
#define lisspace(c)
#define lua_strx2number(s, p)

References cast_uchar, lisspace, lua_str2number, lua_strx2number, NULL, and s.

Referenced by l_str2d().

◆ l_str2int()

static const char * l_str2int ( const char * s,
lua_Integer * result )
static

Definition at line 299 of file lua-5.3.6/src/lobject.c.

299 {
300 lua_Unsigned a = 0;
301 int empty = 1;
302 int neg;
303 while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
304 neg = isneg(&s);
305 if (s[0] == '0' &&
306 (s[1] == 'x' || s[1] == 'X')) { /* hex? */
307 s += 2; /* skip '0x' */
308 for (; lisxdigit(cast_uchar(*s)); s++) {
309 a = a * 16 + luaO_hexavalue(*s);
310 empty = 0;
311 }
312 }
313 else { /* decimal */
314 for (; lisdigit(cast_uchar(*s)); s++) {
315 int d = *s - '0';
316 if (a >= MAXBY10 && (a > MAXBY10 || d > MAXLASTD + neg)) /* overflow? */
317 return NULL; /* do not accept it (as integer) */
318 a = a * 10 + d;
319 empty = 0;
320 }
321 }
322 while (lisspace(cast_uchar(*s))) s++; /* skip trailing spaces */
323 if (empty || *s != '\0') return NULL; /* something wrong in the numeral */
324 else {
325 *result = l_castU2S((neg) ? 0u - a : a);
326 return s;
327 }
328}
#define lisxdigit(c)
#define lisdigit(c)
LUA_UNSIGNED lua_Unsigned
#define l_castU2S(i)
static int isneg(const char **s)
#define MAXBY10
#define MAXLASTD
int luaO_hexavalue(int c)

References cast_uchar, isneg(), l_castU2S, lisdigit, lisspace, lisxdigit, luaO_hexavalue(), MAXBY10, MAXLASTD, NULL, and s.

Referenced by luaO_str2num().

◆ luaO_arith()

void luaO_arith ( lua_State * L,
int op,
const TValue * p1,
const TValue * p2,
TValue * res )

Definition at line 123 of file lua-5.3.6/src/lobject.c.

124 {
125 switch (op) {
126 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
127 case LUA_OPSHL: case LUA_OPSHR:
128 case LUA_OPBNOT: { /* operate only on integers */
130 if (tointeger(p1, &i1) && tointeger(p2, &i2)) {
131 setivalue(res, intarith(L, op, i1, i2));
132 return;
133 }
134 else break; /* go to the end */
135 }
136 case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */
137 lua_Number n1; lua_Number n2;
138 if (tonumber(p1, &n1) && tonumber(p2, &n2)) {
139 setfltvalue(res, numarith(L, op, n1, n2));
140 return;
141 }
142 else break; /* go to the end */
143 }
144 default: { /* other operations */
145 lua_Number n1; lua_Number n2;
146 if (ttisinteger(p1) && ttisinteger(p2)) {
147 setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2)));
148 return;
149 }
150 else if (tonumber(p1, &n1) && tonumber(p2, &n2)) {
151 setfltvalue(res, numarith(L, op, n1, n2));
152 return;
153 }
154 else break; /* go to the end */
155 }
156 }
157 /* could not perform raw operation; try metamethod */
158 lua_assert(L != NULL); /* should not fail when folding (compile time) */
159 luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD));
160}
#define cast(t, exp)
@ TM_ADD
LUA_INTEGER lua_Integer
LUA_NUMBER lua_Number
#define tonumber(o, n)
#define LUA_OPPOW
#define LUA_OPDIV
static lua_Integer intarith(lua_State *L, int op, lua_Integer v1, lua_Integer v2)
static lua_Number numarith(lua_State *L, int op, lua_Number v1, lua_Number v2)
#define ttisinteger(o)
#define setfltvalue(obj, x)
#define ivalue(o)
#define setivalue(obj, x)
void luaT_trybinTM(lua_State *L, const TValue *p1, const TValue *p2, StkId res, TMS event)
#define tointeger(o, i)

References cast, intarith(), ivalue, lua_assert, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, luaT_trybinTM(), NULL, numarith(), setfltvalue, setivalue, TM_ADD, tointeger, tonumber, and ttisinteger.

◆ luaO_ceillog2()

int luaO_ceillog2 ( unsigned int x)

Definition at line 65 of file lua-5.3.6/src/lobject.c.

65 {
66 static const lu_byte log_2[256] = { /* log_2[i] = ceil(log2(i - 1)) */
67 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
68 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
69 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
70 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
71 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
72 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
73 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
74 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
75 };
76 int l = 0;
77 x--;
78 while (x >= 256) { l += 8; x >>= 8; }
79 return l + log_2[x];
80}
unsigned char lu_byte

◆ luaO_chunkid()

void luaO_chunkid ( char * out,
const char * source,
size_t bufflen )

Definition at line 487 of file lua-5.3.6/src/lobject.c.

487 {
488 size_t l = strlen(source);
489 if (*source == '=') { /* 'literal' source */
490 if (l <= bufflen) /* small enough? */
491 memcpy(out, source + 1, l * sizeof(char));
492 else { /* truncate it */
493 addstr(out, source + 1, bufflen - 1);
494 *out = '\0';
495 }
496 }
497 else if (*source == '@') { /* file name */
498 if (l <= bufflen) /* small enough? */
499 memcpy(out, source + 1, l * sizeof(char));
500 else { /* add '...' before rest of name */
501 addstr(out, RETS, LL(RETS));
502 bufflen -= LL(RETS);
503 memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char));
504 }
505 }
506 else { /* string; format as [string "source"] */
507 const char *nl = strchr(source, '\n'); /* find first new line (if any) */
508 addstr(out, PRE, LL(PRE)); /* add prefix */
509 bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */
510 if (l < bufflen && nl == NULL) { /* small one-line source? */
511 addstr(out, source, l); /* keep it */
512 }
513 else {
514 if (nl != NULL) l = nl - source; /* stop at first newline */
515 if (l > bufflen) l = bufflen;
516 addstr(out, source, l);
517 addstr(out, RETS, LL(RETS));
518 }
519 memcpy(out, POS, (LL(POS) + 1) * sizeof(char));
520 }
521}
#define bufflen(B)
#define addstr(a, b, l)
#define PRE
#define LL(x)
#define POS
#define RETS

References addstr, bufflen, LL, NULL, POS, PRE, and RETS.

◆ luaO_fb2int()

int luaO_fb2int ( int x)

Definition at line 57 of file lua-5.3.6/src/lobject.c.

57 {
58 return (x < 8) ? x : ((x & 7) + 8) << ((x >> 3) - 1);
59}

◆ luaO_hexavalue()

int luaO_hexavalue ( int c)

Definition at line 163 of file lua-5.3.6/src/lobject.c.

163 {
164 if (lisdigit(c)) return c - '0';
165 else return (ltolower(c) - 'a') + 10;
166}

References lisdigit, and ltolower.

Referenced by l_str2int().

◆ luaO_int2fb()

int luaO_int2fb ( unsigned int x)

Definition at line 41 of file lua-5.3.6/src/lobject.c.

41 {
42 int e = 0; /* exponent */
43 if (x < 8) return x;
44 while (x >= (8 << 4)) { /* coarse steps */
45 x = (x + 0xf) >> 4; /* x = ceil(x / 16) */
46 e += 4;
47 }
48 while (x >= (8 << 1)) { /* fine steps */
49 x = (x + 1) >> 1; /* x = ceil(x / 2) */
50 e++;
51 }
52 return ((e+1) << 3) | (cast_int(x) - 8);
53}
#define cast_int(i)

References cast_int.

◆ luaO_pushfstring()

const char * luaO_pushfstring ( lua_State * L,
const char * fmt,
... )

Definition at line 468 of file lua-5.3.6/src/lobject.c.

468 {
469 const char *msg;
470 va_list argp;
471 va_start(argp, fmt);
472 msg = luaO_pushvfstring(L, fmt, argp);
473 va_end(argp);
474 return msg;
475}
const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)

References luaO_pushvfstring().

Referenced by luaO_pushvfstring().

◆ luaO_pushvfstring()

const char * luaO_pushvfstring ( lua_State * L,
const char * fmt,
va_list argp )

Definition at line 400 of file lua-5.3.6/src/lobject.c.

400 {
401 int n = 0;
402 for (;;) {
403 const char *e = strchr(fmt, '%');
404 if (e == NULL) break;
405 pushstr(L, fmt, e - fmt);
406 switch (*(e+1)) {
407 case 's': { /* zero-terminated string */
408 const char *s = va_arg(argp, char *);
409 if (s == NULL) s = "(null)";
410 pushstr(L, s, strlen(s));
411 break;
412 }
413 case 'c': { /* an 'int' as a character */
414 char buff = cast(char, va_arg(argp, int));
415 if (lisprint(cast_uchar(buff)))
416 pushstr(L, &buff, 1);
417 else /* non-printable character; print its code */
418 luaO_pushfstring(L, "<\\%d>", cast_uchar(buff));
419 break;
420 }
421 case 'd': { /* an 'int' */
422 setivalue(L->top, va_arg(argp, int));
423 goto top2str;
424 }
425 case 'I': { /* a 'lua_Integer' */
426 setivalue(L->top, cast(lua_Integer, va_arg(argp, l_uacInt)));
427 goto top2str;
428 }
429 case 'f': { /* a 'lua_Number' */
430 setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
431 top2str: /* convert the top element to a string */
432 luaD_inctop(L);
433 luaO_tostring(L, L->top - 1);
434 break;
435 }
436 case 'p': { /* a pointer */
437 char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */
438 void *p = va_arg(argp, void *);
439 int l = lua_pointer2str(buff, sizeof(buff), p);
440 pushstr(L, buff, l);
441 break;
442 }
443 case 'U': { /* an 'int' as a UTF-8 sequence */
444 char buff[UTF8BUFFSZ];
445 int l = luaO_utf8esc(buff, cast(long, va_arg(argp, long)));
446 pushstr(L, buff + UTF8BUFFSZ - l, l);
447 break;
448 }
449 case '%': {
450 pushstr(L, "%", 1);
451 break;
452 }
453 default: {
454 luaG_runerror(L, "invalid option '%%%c' to 'lua_pushfstring'",
455 *(e + 1));
456 }
457 }
458 n += 2;
459 fmt = e+2;
460 }
461 luaD_checkstack(L, 1);
462 pushstr(L, fmt, strlen(fmt));
463 if (n > 0) luaV_concat(L, n + 1);
464 return svalue(L->top - 1);
465}
void luaG_runerror(lua_State *L, const char *fmt,...)
#define luaD_checkstack(L, n)
LUAI_UACNUMBER l_uacNumber
#define cast_num(i)
#define svalue(o)
void luaV_concat(lua_State *L, int total, int last)
#define lisprint(c)
void luaD_inctop(lua_State *L)
LUAI_UACINT l_uacInt
void luaO_tostring(lua_State *L, StkId obj)
const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
static void pushstr(lua_State *L, const char *str, size_t l)
int luaO_utf8esc(char *buff, unsigned long x)
#define UTF8BUFFSZ
#define lua_pointer2str(buff, sz, p)

References cast, cast_num, cast_uchar, lisprint, lua_pointer2str, luaD_checkstack, luaD_inctop(), luaG_runerror(), luaO_pushfstring(), luaO_tostring(), luaO_utf8esc(), luaV_concat(), NULL, pushstr(), s, setfltvalue, setivalue, svalue, lua_State::top, and UTF8BUFFSZ.

Referenced by luaO_pushfstring().

◆ luaO_str2num()

size_t luaO_str2num ( const char * s,
TValue * o )

Definition at line 331 of file lua-5.3.6/src/lobject.c.

331 {
333 const char *e;
334 if ((e = l_str2int(s, &i)) != NULL) { /* try as an integer */
335 setivalue(o, i);
336 }
337 else if ((e = l_str2d(s, &n)) != NULL) { /* else try as a float */
338 setfltvalue(o, n);
339 }
340 else
341 return 0; /* conversion failed */
342 return (e - s) + 1; /* success; return string size */
343}
static const char * l_str2int(const char *s, lua_Integer *result)
static const char * l_str2d(const char *s, lua_Number *result)

References l_str2d(), l_str2int(), NULL, s, setfltvalue, and setivalue.

Referenced by l_strton(), lua_stringtonumber(), luaV_tointeger(), luaV_tonumber_(), read_numeral(), and read_numeral().

◆ luaO_tostring()

void luaO_tostring ( lua_State * L,
StkId obj )

Definition at line 371 of file lua-5.3.6/src/lobject.c.

371 {
372 char buff[MAXNUMBER2STR];
373 size_t len;
375 if (ttisinteger(obj))
376 len = lua_integer2str(buff, sizeof(buff), ivalue(obj));
377 else {
378 len = lua_number2str(buff, sizeof(buff), fltvalue(obj));
379#if !defined(LUA_COMPAT_FLOATSTRING)
380 if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */
381 buff[len++] = lua_getlocaledecpoint();
382 buff[len++] = '0'; /* adds '.0' to result */
383 }
384#endif
385 }
386 setsvalue2s(L, obj, luaS_newlstr(L, buff, len));
387}
#define setsvalue2s
#define ttisnumber(o)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
#define lua_number2str(s, n)
#define MAXNUMBER2STR
#define fltvalue(o)
#define lua_integer2str(s, sz, n)

References fltvalue, ivalue, lua_assert, lua_getlocaledecpoint, lua_integer2str, lua_number2str, luaS_newlstr(), MAXNUMBER2STR, setsvalue2s, ttisinteger, and ttisnumber.

Referenced by lua_tolstring(), and luaO_pushvfstring().

◆ luaO_utf8esc()

int luaO_utf8esc ( char * buff,
unsigned long x )

Definition at line 346 of file lua-5.3.6/src/lobject.c.

346 {
347 int n = 1; /* number of bytes put in buffer (backwards) */
348 lua_assert(x <= 0x10FFFF);
349 if (x < 0x80) /* ascii? */
350 buff[UTF8BUFFSZ - 1] = cast(char, x);
351 else { /* need continuation bytes */
352 unsigned int mfb = 0x3f; /* maximum that fits in first byte */
353 do { /* add continuation bytes */
354 buff[UTF8BUFFSZ - (n++)] = cast(char, 0x80 | (x & 0x3f));
355 x >>= 6; /* remove added bits */
356 mfb >>= 1; /* now there is one less bit available in first byte */
357 } while (x > mfb); /* still needs continuation byte? */
358 buff[UTF8BUFFSZ - n] = cast(char, (~mfb << 1) | x); /* add first byte */
359 }
360 return n;
361}

References cast, lua_assert, and UTF8BUFFSZ.

Referenced by luaO_pushvfstring(), utf8esc(), and utf8esc().

◆ numarith()

static lua_Number numarith ( lua_State * L,
int op,
lua_Number v1,
lua_Number v2 )
static

Definition at line 103 of file lua-5.3.6/src/lobject.c.

104 {
105 switch (op) {
106 case LUA_OPADD: return luai_numadd(L, v1, v2);
107 case LUA_OPSUB: return luai_numsub(L, v1, v2);
108 case LUA_OPMUL: return luai_nummul(L, v1, v2);
109 case LUA_OPDIV: return luai_numdiv(L, v1, v2);
110 case LUA_OPPOW: return luai_numpow(L, v1, v2);
111 case LUA_OPIDIV: return luai_numidiv(L, v1, v2);
112 case LUA_OPUNM: return luai_numunm(L, v1);
113 case LUA_OPMOD: {
114 lua_Number m;
115 luai_nummod(L, v1, v2, m);
116 return m;
117 }
118 default: lua_assert(0); return 0;
119 }
120}
#define luai_nummul(L, a, b)
#define luai_numdiv(L, a, b)
#define luai_numpow(L, a, b)
#define luai_numunm(L, a)
#define luai_numsub(L, a, b)
#define luai_numidiv(L, a, b)
#define luai_nummod(L, a, b, m)
#define luai_numadd(L, a, b)

References lua_assert, LUA_OPADD, LUA_OPDIV, LUA_OPIDIV, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSUB, LUA_OPUNM, luai_numadd, luai_numdiv, luai_numidiv, luai_nummod, luai_nummul, luai_numpow, luai_numsub, and luai_numunm.

Referenced by luaO_arith().

◆ pushstr()

static void pushstr ( lua_State * L,
const char * str,
size_t l )
static

Definition at line 390 of file lua-5.3.6/src/lobject.c.

390 {
391 setsvalue2s(L, L->top, luaS_newlstr(L, str, l));
392 luaD_inctop(L);
393}

References luaD_inctop(), luaS_newlstr(), setsvalue2s, and lua_State::top.

Referenced by luaO_pushvfstring().

Variable Documentation

◆ luaO_nilobject_

LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT}

Definition at line 33 of file lua-5.3.6/src/lobject.c.

#define NILCONSTANT