本文整理汇总了C++中cast_int函数的典型用法代码示例。如果您正苦于以下问题:C++ cast_int函数的具体用法?C++ cast_int怎么用?C++ cast_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cast_int函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: clLvalue
static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
int nparams = clLvalue(ci->func)->p->sp->numparams;
if (n >= cast_int(ci->u.l.base - ci->func) - nparams)
return NULL; /* no such vararg */
else {
*pos = ci->func + nparams + n;
return "(*vararg)"; /* generic name for any vararg */
}
}
开发者ID:4Second2None,项目名称:skynet,代码行数:9,代码来源:ldebug.c
示例2: luaO_int2fb
/*
** converts an integer to a "floating point byte", represented as
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
** eeeee != 0 and (xxx) otherwise.
*/
int luaO_int2fb (unsigned int x) {
int e = 0; /* exponent */
if (x < 8) return x;
while (x >= 0x10) {
x = (x+1) >> 1;
e++;
}
return ((e+1) << 3) | (cast_int(x) - 8);
}
开发者ID:CaringLabs,项目名称:MediaFramework,代码行数:14,代码来源:lobject.c
示例3: addk
static int addk (FuncState *fs, TValue *k, TValue *v) {
lua_State *L = fs->L;
TValue *idx = luaH_set(L, fs->h, k);
Proto *f = fs->f;
int oldsize = f->sizek;
if (ttisnumber(idx)) {
lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
return cast_int(nvalue(idx));
} else { /* constant not found; create a new entry */
setnvalue(idx, cast_num(fs->nk));
luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
MAXARG_Bx, "constant table overflow");
while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
setobj(L, &f->k[fs->nk], v);
luaC_barrier(L, f, v);
return fs->nk++;
}
}
开发者ID:xiqingping,项目名称:embedded_template,代码行数:18,代码来源:lcode.c
示例4: luaO_int2fb
/*
** converts an integer to a "floating point byte", represented as
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
** eeeee != 0 and (xxx) otherwise.
*/
int luaO_int2fb (unsigned int x) {
int e = 0; /* expoent */
while (x >= 16) {
x = (x+1) >> 1;
e++;
}
if (x < 8) return x;
else return ((e+1) << 3) | (cast_int(x) - 8);
}
开发者ID:BaronSmerti,项目名称:android-pppoe,代码行数:14,代码来源:lobject.c
示例5: cast_int
int HiroHand::readAngle(int idx)
{
int ang;
ang = cast_int(this->modules[idx]->getAngle());
if(ang == 0xF000)
std::cerr << "Angle Read Error" << std::endl;
return ang;
}
开发者ID:orioli,项目名称:MAID-ROBOT,代码行数:10,代码来源:HiroHands.cpp
示例6: ci_func
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
TMS tm = (TMS)0; /* to avoid warnings */
Proto *p = ci_func(ci)->p; /* calling function */
int pc = currentpc(ci); /* calling instruction index */
Instruction i = p->code[pc]; /* calling instruction */
if (ci->callstatus & CIST_HOOKED) { /* was it called inside a hook? */
*name = "?";
return "hook";
}
switch (GET_OPCODE(i)) {
case OP_CALL:
case OP_TAILCALL: /* get function name */
return getobjname(p, pc, GETARG_A(i), name);
case OP_TFORCALL: { /* for iterator */
*name = "for iterator";
return "for iterator";
}
/* all other instructions can call only through metamethods */
case OP_SELF: case OP_GETTABUP: case OP_GETTABLE:
tm = TM_INDEX;
break;
case OP_SETTABUP: case OP_SETTABLE:
tm = TM_NEWINDEX;
break;
case OP_ADD: case OP_SUB: case OP_MUL: case OP_MOD:
case OP_POW: case OP_DIV: case OP_IDIV: case OP_BAND:
case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: {
int offset = cast_int(GET_OPCODE(i)) - cast_int(OP_ADD); /* ORDER OP */
tm = cast(TMS, offset + cast_int(TM_ADD)); /* ORDER TM */
break;
}
case OP_UNM: tm = TM_UNM; break;
case OP_BNOT: tm = TM_BNOT; break;
case OP_LEN: tm = TM_LEN; break;
case OP_CONCAT: tm = TM_CONCAT; break;
case OP_EQ: tm = TM_EQ; break;
case OP_LT: tm = TM_LT; break;
case OP_LE: tm = TM_LE; break;
default: lua_assert(0); /* other instructions cannot call a function */
}
*name = getstr(G(L)->tmname[tm]);
return "metamethod";
}
开发者ID:1414648814,项目名称:ejoy2d,代码行数:43,代码来源:ldebug.c
示例7: restore_stack_limit
static void restore_stack_limit(lua_State *L)
{
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
if (L->size_ci > LUAI_MAXCALLS)
{ /* there was an overflow? */
int inuse = cast_int(L->ci - L->base_ci);
if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */
luaD_reallocCI(L, LUAI_MAXCALLS);
}
}
开发者ID:korman,项目名称:Temp,代码行数:10,代码来源:ldo.c
示例8: luaV_finishOp
/*
** finish execution of an opcode interrupted by an yield
*/
void luaV_finishOp (lua_State *L) {
CallInfo *ci = L->ci;
StkId base = ci->u.l.base;
Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */
OpCode op = GET_OPCODE(inst);
switch (op) { /* finish its execution */
case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV:
case OP_MOD: case OP_POW: case OP_UNM: case OP_LEN:
case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: {
setobjs2s(L, base + GETARG_A(inst), --L->top);
break;
}
case OP_LE: case OP_LT: case OP_EQ: {
int res = !l_isfalse(L->top - 1);
L->top--;
/* metamethod should not be called when operand is K */
lua_assert(!ISK(GETARG_B(inst)));
if (op == OP_LE && /* "<=" using "<" instead? */
ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE)))
res = !res; /* invert result */
lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP);
if (res != GETARG_A(inst)) /* condition failed? */
ci->u.l.savedpc++; /* skip jump instruction */
break;
}
case OP_CONCAT: {
StkId top = L->top - 1; /* top when 'call_binTM' was called */
int b = GETARG_B(inst); /* first element to concatenate */
int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */
setobj2s(L, top - 2, top); /* put TM result in proper position */
if (total > 1) { /* are there elements to concat? */
L->top = top - 1; /* top is one after last element (at top-2) */
luaV_concat(L, total); /* concat them (may yield again) */
}
/* move final result to final position */
setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1);
L->top = ci->top; /* restore top */
break;
}
case OP_TFORCALL: {
lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_TFORLOOP);
L->top = ci->top; /* correct top */
break;
}
case OP_CALL: {
if (GETARG_C(inst) - 1 >= 0) /* nresults >= 0? */
L->top = ci->top; /* adjust results */
break;
}
case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE:
break;
default: lua_assert(0);
}
}
开发者ID:lriki,项目名称:Volkoff,代码行数:57,代码来源:lvm.c
示例9: arrayindex
/*
** returns the index for `key' if `key' is an appropriate key to live in
** the array part of the table, -1 otherwise.
**
** Anything <=0 is taken as not being in the array part.
*/
static int arrayindex (const TValue *key, int max) {
lua_Integer i;
switch( ttype(key) ) {
#ifdef LUA_TINT
case LUA_TINT: i= ivalue(key); break;
#endif
case LUA_TNUMBER: if (tt_integer_valued(key,&i)) break;
default: return -1; /* not to be used as array index */
}
return (i <= max) ? cast_int(i) : -1;
}
开发者ID:7568168,项目名称:cheat-engine,代码行数:17,代码来源:ltable.c
示例10: luaG_typeerror
void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
const char *name = NULL;
const char *t = luaT_typenames[ttype(o)];
const char *kind = (isinstack(L->ci, o)) ?
getobjname(L, L->ci, cast_int(o - L->base), &name) :
NULL;
if (kind)
luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
op, kind, name, t);
else
luaG_runerror(L, "attempt to %s a %s value", op, t);
}
开发者ID:GranPC,项目名称:llvm-lua,代码行数:12,代码来源:ldebug.c
示例11: searchvar
static int searchvar(FuncState *fs, TString *n)
{
int i;
for (i = cast_int(fs->nactvar) - 1; i >= 0; i--)
{
if (luaS_eqstr(n, getlocvar(fs, i)->varname))
return i;
}
return -1; /* not found */
}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:12,代码来源:lparser.c
示例12: getupvalname
static const char *varinfo (lua_State *L, const TValue *o) {
const char *name = NULL; /* to avoid warnings */
CallInfo *ci = L->ci;
const char *kind = NULL;
if (isLua(ci)) {
kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */
if (!kind && isinstack(ci, o)) /* no? try a register */
kind = getobjname(ci_func(ci)->p, currentpc(ci),
cast_int(o - ci->u.l.base), &name);
}
return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : "";
}
开发者ID:chanchancl,项目名称:YDWE,代码行数:12,代码来源:ldebug.c
示例13: approx
double approx(double a, int digits) {
digits--;
bool neg=false;
if(a<0) {
neg=true;
a=-a;
}
//cout<<a<<endl;
int tpow=0;
while(a<pow(10, digits)) {
tpow++;
a*=10;
}
while(a>pow(10, digits+1)) {
tpow--;
a/=10;
}
if(neg==false)
return cast_int(a)/pow(10, tpow);
else
return -cast_int(a)/pow(10, tpow);
}
开发者ID:BB90,项目名称:CommunityDetectionCodes,代码行数:40,代码来源:cast.cpp
示例14: traversestack
static int traversestack (global_State *g, lua_State *L) {
StkId o = L->stack;
if (o == NULL)
return 1; /* stack not completely built yet */
for (; o < L->top; o++)
markvalue(g, o);
if (g->gcstate == GCSatomic) { /* final traversal? */
StkId lim = L->stack + L->stacksize; /* real end of stack */
for (; o < lim; o++) /* clear not-marked stack slice */
setnilvalue(o);
}
return TRAVCOST + cast_int(o - L->stack);
}
开发者ID:alucard-dracula,项目名称:yggdrasil,代码行数:13,代码来源:lgc.c
示例15: luaO_int2fb
/*
** converts an integer to a "floating point byte", represented as
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
** eeeee != 0 and (xxx) otherwise.
*/
int luaO_int2fb (unsigned int x) {
int e = 0; /* exponent */
if (x < 8) return x;
while (x >= (8 << 4)) { /* coarse steps */
x = (x + 0xf) >> 4; /* x = ceil(x / 16) */
e += 4;
}
while (x >= (8 << 1)) { /* fine steps */
x = (x + 1) >> 1; /* x = ceil(x / 2) */
e++;
}
return ((e+1) << 3) | (cast_int(x) - 8);
}
开发者ID:swizl,项目名称:lua,代码行数:18,代码来源:lobject.cpp
示例16: l_hashfloat
static int l_hashfloat (lua_Number n) {
int i;
lua_Integer ni;
n = l_mathop(frexp)(n, &i) * -cast_num(INT_MIN);
if (!lua_numbertointeger(n, &ni)) { /* is 'n' inf/-inf/NaN? */
lua_assert(luai_numisnan(n) || l_mathop(fabs)(n) == cast_num(HUGE_VAL));
return 0;
}
else { /* normal case */
unsigned int u = cast_uint(i) + cast_uint(ni);
return cast_int(u <= cast_uint(INT_MAX) ? u : ~u);
}
}
开发者ID:luciouskami,项目名称:YDWE,代码行数:13,代码来源:ltable.c
示例17: DumpString
static void DumpString (const TString *s, DumpState *D) {
if (s == NULL)
DumpByte(0, D);
else {
size_t size = s->len + 1; /* include trailing '\0' */
if (size < 0xFF)
DumpByte(cast_int(size), D);
else {
DumpByte(0xFF, D);
DumpVar(size, D);
}
DumpVector(getstr(s), size - 1, D); /* no need to save '\0' */
}
}
开发者ID:141141,项目名称:nodemcu-firmware-lua5.3.0,代码行数:14,代码来源:ldump.c
示例18: compute_quantiles
void compute_quantiles(double q, deque<double> & y, deque<double> & qs) {
int qv=cast_int((1-q)/2 * y.size());
if(qv<0)
qv=0;
if(qv>=int(y.size()))
qv=y.size()-1;
qs.push_back(y[qv]);
qv=cast_int((1+q)/2 * y.size());
if(qv<0)
qv=0;
if(qv>=int(y.size()))
qv=y.size()-1;
qs.push_back(y[qv]);
}
开发者ID:RoyZhengGao,项目名称:CommunityEvaluation,代码行数:23,代码来源:histograms.cpp
示例19: cast_int
bool Parameters::set(string &flag, string &num) {
// false is something goes wrong
cout << "setting... " << flag << " " << num << endl;
double err;
if (!cast_string_to_double(num, err)) {
cerr << "\n***********************\nERROR while reading parameters" << endl;
return false;
}
if (flag == command_flags[0]) {
if (fabs(err - int(err)) > 1e-8) {
cerr << "\n***********************\nERROR: number of nodes must be an integer" << endl;
return false;
}
num_nodes = cast_int(err);
} else if (flag == command_flags[1]) {
average_k = err;
} else if (flag == command_flags[2]) {
max_degree = cast_int(err);
} else if (flag == command_flags[3]) {
mixing_parameter = err;
} else if (flag == command_flags[4]) {
tau = err;
} else if (flag == command_flags[5]) {
tau2 = err;
} else if (flag == command_flags[6]) {
if (fabs(err - int(err)) > 1e-8) {
cerr << "\n***********************\nERROR: the minumum community size must be an integer" << endl;
return false;
}
nmin = cast_int(err);
} else if (flag == command_flags[7]) {
if (fabs(err - int(err)) > 1e-8) {
cerr << "\n***********************\nERROR: the maximum community size must be an integer" << endl;
return false;
}
nmax = cast_int(err);
} else if (flag == command_flags[8]) {
if (fabs(err - int(err)) > 1e-8) {
cerr << "\n***********************\nERROR: the number of overlapping nodes must be an integer" << endl;
return false;
}
overlapping_nodes = cast_int(err);
} else if (flag == command_flags[9]) {
if (fabs(err - int(err)) > 1e-8) {
cerr
<< "\n***********************\nERROR: the number of membership of the overlapping nodes must be an integer"
<< endl;
return false;
}
overlap_membership = cast_int(err);
} else {
cerr << "\n***********************\nERROR while reading parameters: " << flag << " is an unknown option"
<< endl;
return false;
}
return true;
}
开发者ID:BB90,项目名称:CommunityDetectionCodes,代码行数:57,代码来源:set_parameters.cpp
示例20: io_file_write
static int io_file_write(lua_State *L, FILE *fp, int start)
{
cTValue *tv;
int status = 1;
for (tv = L->base+start; tv < L->top; tv++) {
if (tvisstr(tv)) {
MSize len = strV(tv)->len;
status = status && (fwrite(strVdata(tv), 1, len, fp) == len);
} else if (tvisnum(tv)) {
status = status && (fprintf(fp, LUA_NUMBER_FMT, numV(tv)) > 0);
} else {
lj_err_argt(L, cast_int(tv - L->base) + 1, LUA_TSTRING);
}
}
return io_pushresult(L, status, NULL);
}
开发者ID:derdewey,项目名称:luajit,代码行数:16,代码来源:lib_io.c
注:本文中的cast_int函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论