本文整理匯總了C++中EMIT函數的典型用法代碼示例。如果您正苦於以下問題:C++ EMIT函數的具體用法?C++ EMIT怎麽用?C++ EMIT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EMIT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: p_bre
/*
- p_bre - BRE parser top level, anchoring and concatenation
* Giving end1 as OUT essentially eliminates the end1/end2 check.
*
* This implementation is a bit of a kludge, in that a trailing $ is first
* taken as an ordinary character and then revised to be an anchor. The
* only undesirable side effect is that '$' gets included as a character
* category in such cases. This is fairly harmless; not worth fixing.
* The amount of lookahead needed to avoid this kludge is excessive.
*/
static void
p_bre(struct parse *p,
int end1, /* first terminating character */
int end2) /* second terminating character */
{
sopno start = HERE();
int first = 1; /* first subexpression? */
int wasdollar = 0;
if (EAT('^')) {
EMIT(OBOL, 0);
p->g->iflags |= USEBOL;
p->g->nbol++;
}
while (MORE() && !SEETWO(end1, end2)) {
wasdollar = p_simp_re(p, first);
first = 0;
}
if (wasdollar) { /* oops, that was a trailing anchor */
DROP(1);
EMIT(OEOL, 0);
p->g->iflags |= USEEOL;
p->g->neol++;
}
REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */
}
示例2: join_paths
static size_t join_paths(char *dst, size_t bufsize,
const char *s1, const char *s2)
{
const char *list[2];
int i;
char c;
const char *p;
char *q = dst;
size_t n = 0;
bool slash = false;
list[0] = s1;
list[1] = s2;
for (i = 0; i < 2; i++) {
p = list[i];
while ((c = *p++)) {
if (c == '/') {
if (!slash)
EMIT(c);
slash = true;
} else {
EMIT(c);
slash = false;
}
}
}
if (bufsize)
*q = '\0';
return n;
}
示例3: DumpMemory
/***************************************************************
** Diagnostic routine that prints memory in table format.
*/
void DumpMemory( void *addr, int32 cnt)
{
int32 ln, cn, nlines;
unsigned char *ptr, *cptr, c;
nlines = (cnt + 15) / 16;
ptr = (unsigned char *) addr;
EMIT_CR;
for (ln=0; ln<nlines; ln++)
{
MSG( ConvertNumberToText( (int32) ptr, 16, FALSE, 8 ) );
MSG(": ");
cptr = ptr;
for (cn=0; cn<16; cn++)
{
MSG( ConvertNumberToText( (int32) *cptr++, 16, FALSE, 2 ) );
EMIT(' ');
}
EMIT(' ');
for (cn=0; cn<16; cn++)
{
c = *ptr++;
if ((c < ' ') || (c > '}')) c = '.';
EMIT(c);
}
EMIT_CR;
}
}
示例4: cvt_d
static void cvt_d(fmt_code_info_t *info) {
/* declare buf and p, initialize p */
char buf[200];
char *p = buf + sizeof(buf);
#define EMIT(m) do { \
if(val == INT_MIN) \
m = INT_MAX + 1U; \
else if(val < 0) \
m = -val; \
else \
m = val; \
\
do \
*--p = (char)(m % 10 + '0'); \
while((m /= 10) > 0); \
\
if(val < 0) \
*--p = '-'; \
} while(0)
if(info->flags['L']) {
int64_t val = va_arg(*info->app, int64_t);
int64_t m;
EMIT(m);
} else if(info->flags['l']) {
long val = va_arg(*info->app, long);
long m;
EMIT(m);
} else if(info->flags['h']) {
示例5: onVisitNode
void BytecodeTranslatorVisitor::visitUnaryOpNode(UnaryOpNode* node) {
onVisitNode(node);
VISIT(node->operand());
switch (node->kind()) {
case tNOT: {
ensureTopType(VT_INT); /* if (!3.14) should fail */
Label L_True(bytecode());
Label L_End(bytecode());
EMIT(BC_ILOAD0);
EMIT_BRANCH(BC_IFICMPE, L_True);
EMIT(BC_ILOAD0);
EMIT_BRANCH(BC_JA, L_End);
EMIT_BIND(L_True);
EMIT(BC_ILOAD1);
EMIT_BIND(L_End);
break;
}
case tSUB:
ensureTopIsNumeric();
EMIT(TYPED(NEG));
break;
default:
ERROR("Unknown unary op");
}
}
示例6: emit_quoted_scalar
bool emit_quoted_scalar(const node *each)
{
EMIT("'");
if(!emit_raw_scalar(each))
{
log_error("shell", "uh oh! couldn't emit quoted scalar");
return false;
}
EMIT("'");
return true;
}
示例7: emit_json_quoted_scalar
static bool emit_json_quoted_scalar(const Scalar *each)
{
EMIT("\"");
if(!emit_json_raw_scalar(each))
{
log_error(component, "uh oh! couldn't emit quoted scalar");
return false;
}
EMIT("\"");
return true;
}
示例8: quote_c_style_counted
/*
* C-style name quoting.
*
* (1) if sb and fp are both NULL, inspect the input name and counts the
* number of bytes that are needed to hold c_style quoted version of name,
* counting the double quotes around it but not terminating NUL, and
* returns it.
* However, if name does not need c_style quoting, it returns 0.
*
* (2) if sb or fp are not NULL, it emits the c_style quoted version
* of name, enclosed with double quotes if asked and needed only.
* Return value is the same as in (1).
*/
static size_t quote_c_style_counted(const char *name, ssize_t maxlen,
struct strbuf *sb, FILE *fp, int no_dq)
{
#undef EMIT
#define EMIT(c) \
do { \
if (sb) strbuf_addch(sb, (c)); \
if (fp) fputc((c), fp); \
count++; \
} while (0)
#define EMITBUF(s, l) \
do { \
if (sb) strbuf_add(sb, (s), (l)); \
if (fp) fwrite((s), (l), 1, fp); \
count += (l); \
} while (0)
size_t len, count = 0;
const char *p = name;
for (;;) {
int ch;
len = next_quote_pos(p, maxlen);
if (len == maxlen || (maxlen < 0 && !p[len]))
break;
if (!no_dq && p == name)
EMIT('"');
EMITBUF(p, len);
EMIT('\\');
p += len;
ch = (unsigned char)*p++;
if (maxlen >= 0)
maxlen -= len + 1;
if (sq_lookup[ch] >= ' ') {
EMIT(sq_lookup[ch]);
} else {
EMIT(((ch >> 6) & 03) + '0');
EMIT(((ch >> 3) & 07) + '0');
EMIT(((ch >> 0) & 07) + '0');
}
}
EMITBUF(p, len);
if (p == name) /* no ending quote needed */
return 0;
if (!no_dq)
EMIT('"');
return count;
}
示例9: castTopsToCommonType
void BytecodeTranslatorVisitor::processNumericOperation(TokenKind op) {
castTopsToCommonType();
switch (op) {
case tADD: EMIT(TYPED(ADD)); break;
case tSUB: EMIT(TYPED(SUB)); break;
case tMUL: EMIT(TYPED(MUL)); break;
default : EMIT(TYPED(DIV)); break;
}
popType();
ensureTopIsNumeric();
}
示例10: emit_json_mapping_item
static bool emit_json_mapping_item(Node *key, Node *value, void *context)
{
log_trace(component, "emitting mapping item");
size_t *count = (size_t *)context;
if(0 != (*count)++)
{
EMIT(",");
}
if(!emit_json_quoted_scalar(scalar(key)))
{
return false;
}
EMIT(":");
return emit_json_node(value, NULL);
}
示例11: ffDotS
/* ( ... --- ... , print stack ) */
void ffDotS( void )
{
cell *sp;
int32 i, Depth;
MSG("Stack<");
MSG( ConvertNumberToText( gVarBase, 10, TRUE, 1 ) ); /* Print base in decimal. */
MSG("> ");
Depth = gCurrentTask->td_StackBase - gCurrentTask->td_StackPtr;
sp = gCurrentTask->td_StackBase;
if( Depth < 0 )
{
MSG("UNDERFLOW!");
}
else
{
for( i=0; i<Depth; i++ )
{
/* Print as unsigned if not base 10. */
MSG( ConvertNumberToText( *(--sp), gVarBase, (gVarBase == 10), 1 ) );
EMIT(' ');
}
}
MSG("\n");
}
示例12: doinsert
/*
- doinsert - insert a sop into the strip
*/
static void
doinsert(struct parse *p, sop op, size_t opnd, sopno pos)
{
sopno sn;
sop s;
int i;
/* avoid making error situations worse */
if (p->error != 0)
return;
sn = HERE();
EMIT(op, opnd); /* do checks, ensure space */
assert(HERE() == sn+1);
s = p->strip[sn];
/* adjust paren pointers */
assert(pos > 0);
for (i = 1; i < NPAREN; i++) {
if (p->pbegin[i] >= pos) {
p->pbegin[i]++;
}
if (p->pend[i] >= pos) {
p->pend[i]++;
}
}
memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos],
(HERE()-pos-1)*sizeof(sop));
p->strip[pos] = s;
}
示例13: FIND_ATTACHED_STREAM_INFO
void Recorder::onRecord(XnUInt32 nodeId, XnCodecBase* pCodec, const OniFrame* pFrame, XnUInt32 frameId, XnUInt64 timestamp)
{
if (0 == nodeId || NULL == pFrame)
{
return;
}
FIND_ATTACHED_STREAM_INFO(nodeId)
if (!pInfo) return;
Memento undoPoint(this);
if (NULL != pCodec)
{
XnUInt32 bufferSize_bytes32 = pFrame->dataSize * 2 + pCodec->GetOverheadSize();
XnUInt8* buffer = XN_NEW_ARR(XnUInt8, bufferSize_bytes32);
XnStatus status = pCodec->Compress(reinterpret_cast<const XnUChar*>(pFrame->data),
pFrame->dataSize, buffer, &bufferSize_bytes32);
XnSizeT bufferSize_bytes = bufferSize_bytes32;
if (XN_STATUS_OK == status)
{
EMIT(RECORD_NEW_DATA(
nodeId,
pInfo->lastNewDataRecordPosition,
timestamp,
frameId,
buffer,
bufferSize_bytes))
}
XN_DELETE_ARR(buffer);
}
示例14: irc_status_busy
void
irc_status_busy(connection_t *c, int on, char *msg)
{
c->status &= ~STATUS_MASK;
if (on) {
c->status |= STATUS_BUSY;
if (msg != NULL) {
IRC(c)->away = a_strdup(c->area, msg);
PDEBUG("vado in away: %s", IRC(c)->away);
}
} else {
c->status |= STATUS_AVAILABLE;
if (IRC(c)->away != NULL) {
a_free(c->area, IRC(c)->away);
IRC(c)->away = NULL;
}
}
EMIT(c, "send status");
IRC_SEND_SRVMODE(c, c->nick, c->nick, (on) ? "+a" : "-a");
}
示例15: popType
void BytecodeTranslatorVisitor::castTopsToCommonType() {
VarType hi = popType();
VarType lo = popType();
if (hi != lo) {
if (hi == VT_DOUBLE) {
EMIT(BC_SWAP);
EMIT(BC_I2D);
EMIT(BC_SWAP);
} else {
EMIT(BC_I2D);
}
hi = VT_DOUBLE;
}
pushType(hi);
pushType(hi);
}