本文整理汇总了C++中reset_stack函数的典型用法代码示例。如果您正苦于以下问题:C++ reset_stack函数的具体用法?C++ reset_stack怎么用?C++ reset_stack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reset_stack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test2
static void
test2 (void)
{
mpfr_t x;
long *a, *b, *c;
reset_stack ();
org = (long *) stack;
a = dummy_set_si (42);
b = dummy_set_si (17);
c = dummy_add (a, b);
c = dummy_compact (c, org);
(mpfr_custom_init_set) (x, c[0], c[1], p, &c[2]);
if (c != org || mpfr_cmp_ui (x, 59) != 0)
{
printf ("Compact (2) failed! c=%p a=%p\n", (void *) c, (void *) a);
mpfr_dump (x);
exit (1);
}
a = dummy_set_si (42);
b = dummy_set_si (-17);
c = dummy_add (a, b);
c = dummy_compact (c, org);
(mpfr_custom_init_set) (x, c[0], c[1], p, &c[2]);
if (c != org || mpfr_cmp_ui (x, 25) != 0)
{
printf ("Compact (6) failed! c=%p a=%p\n", (void *) c, (void *) a);
mpfr_dump (x);
exit (1);
}
reset_stack ();
}
示例2: stack_arg
void CreateOpenSplineFunc::execute() {
ComValue& vect = stack_arg(0);
if (!vect.is_type(ComValue::ArrayType) || vect.array_len()==0) {
reset_stack();
push_stack(ComValue::nullval());
return;
}
const int len = vect.array_len();
const int npts = len/2;
int x[npts];
int y[npts];
ALIterator i;
AttributeValueList* avl = vect.array_val();
avl->First(i);
for (int j=0; j<npts && !avl->Done(i); j++) {
x[j] = avl->GetAttrVal(i)->int_val();
avl->Next(i);
y[j] = avl->GetAttrVal(i)->int_val();
avl->Next(i);
}
AttributeList* al = stack_keys();
Resource::ref(al);
reset_stack();
PasteCmd* cmd = nil;
if (npts) {
BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar");
PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar");
ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar");
Transformer* rel = get_transformer(al);
ArrowVar* aVar = (ArrowVar*) _ed->GetState("ArrowVar");
ArrowOpenBSpline* openspline = new ArrowOpenBSpline(x, y, npts, aVar->Head(), aVar->Tail(),
_ed->GetViewer()->GetMagnification(), stdgraphic);
if (brVar != nil) openspline->SetBrush(brVar->GetBrush());
if (patVar != nil) openspline->SetPattern(patVar->GetPattern());
if (colVar != nil) {
openspline->FillBg(!colVar->GetBgColor()->None());
openspline->SetColors(colVar->GetFgColor(), colVar->GetBgColor());
}
openspline->SetTransformer(rel);
Unref(rel);
ArrowSplineOvComp* comp = new ArrowSplineOvComp(openspline);
comp->SetAttributeList(al);
if (PasteModeFunc::paste_mode()==0)
cmd = new PasteCmd(_ed, new Clipboard(comp));
ComValue compval(new OverlayViewRef(comp), symbol_add("ArrowSplineComp"));
push_stack(compval);
execute_log(cmd);
} else
push_stack(ComValue::nullval());
Unref(al);
}
示例3: test_nan_inf_zero
static void
test_nan_inf_zero (void)
{
mpfr_ptr val;
int sign;
int kind;
reset_stack ();
val = new_mpfr (MPFR_PREC_MIN);
mpfr_set_nan (val);
kind = (mpfr_custom_get_kind) (val);
if (kind != MPFR_NAN_KIND)
{
printf ("mpfr_custom_get_kind error: ");
mpfr_dump (val);
printf (" is kind %d instead of %d\n", kind, (int) MPFR_NAN_KIND);
exit (1);
}
val = new_nan (MPFR_PREC_MIN);
if (!mpfr_nan_p(val))
{
printf ("Error: mpfr_custom_init_set doesn't set NAN mpfr.\n");
exit (1);
}
val = new_inf (MPFR_PREC_MIN);
if (!mpfr_inf_p(val) || mpfr_sgn(val) >= 0)
{
printf ("Error: mpfr_custom_init_set doesn't set -INF mpfr.\n");
exit (1);
}
sign = 1;
mpfr_set_inf (val, sign);
kind = (mpfr_custom_get_kind) (val);
if ((ABS (kind) != MPFR_INF_KIND) || (SIGN (kind) != SIGN (sign)))
{
printf ("mpfr_custom_get_kind error: ");
mpfr_dump (val);
printf (" is kind %d instead of %d\n", kind, (int) MPFR_INF_KIND);
printf (" have sign %d instead of %d\n", SIGN (kind), SIGN (sign));
exit (1);
}
sign = -1;
mpfr_set_zero (val, sign);
kind = (mpfr_custom_get_kind) (val);
if ((ABS (kind) != MPFR_ZERO_KIND) || (SIGN (kind) != SIGN (sign)))
{
printf ("mpfr_custom_get_kind error: ");
mpfr_dump (val);
printf (" is kind %d instead of %d\n", kind, (int) MPFR_ZERO_KIND);
printf (" have sign %d instead of %d\n", SIGN (kind), SIGN (sign));
exit (1);
}
reset_stack ();
}
示例4: nargs
void SymValFunc::execute() {
// return value for each symbol variable
boolean noargs = !nargs() && !nkeys();
int numargs = nargs();
if (!numargs) return;
ComValue* varvalues[numargs];
for (int i=0; i<numargs; i++) {
// return fully-evaluated value: expression --> symbol --> value
varvalues[i] = &stack_arg(i, false);
// lookup_symval(*varvalues[i]);
}
if (numargs>1) {
AttributeValueList* avl = new AttributeValueList();
ComValue retval(avl);
for (int i=0; i<numargs; i++)
avl->Append(new ComValue(*varvalues[i]));
reset_stack();
push_stack(retval);
} else {
ComValue retval (*varvalues[0]);
reset_stack();
push_stack(retval);
}
}
示例5: test1
static void
test1 (void)
{
mpfr_ptr x, y;
reset_stack ();
org = (long *) stack;
x = new_mpfr (p);
y = new_mpfr (p);
mpfr_set_ui (x, 42, MPFR_RNDN);
mpfr_set_ui (y, 17, MPFR_RNDN);
mpfr_add (y, x, y, MPFR_RNDN);
y = return_mpfr (y, (char *) org);
if ((long *) y != org || mpfr_cmp_ui (y, 59) != 0)
{
printf ("Compact (1) failed!\n");
exit (1);
}
x = new_mpfr (p);
y = new_mpfr (p);
mpfr_set_ui (x, 4217, MPFR_RNDN);
mpfr_set_ui (y, 1742, MPFR_RNDN);
mpfr_add (y, x, y, MPFR_RNDN);
y = return_mpfr_func (y, (char *) org);
if ((long *) y != org || mpfr_cmp_ui (y, 5959) != 0)
{
printf ("Compact (5) failed!\n");
exit (1);
}
reset_stack ();
}
示例6: reset_stack
void DeleteFunc::execute() {
Viewer* viewer = _ed->GetViewer();
int nf=nargsfixed();
if (nf==0) {
reset_stack();
return;
}
Clipboard* delcb = new Clipboard();
for (int i=0; i<nf; i++) {
ComValue& obj = stack_arg(i);
if (obj.object_compview()) {
ComponentView* comview = (ComponentView*)obj.obj_val();
OverlayComp* comp = (OverlayComp*)comview->GetSubject();
if (comp) delcb->Append(comp);
}
}
DeleteCmd* delcmd = new DeleteCmd(GetEditor(), delcb);
delcmd->Execute();
unidraw->Update();
delete delcmd;
reset_stack();
}
示例7: vallist
void SumFunc::execute() {
ComValue vallist(stack_arg(0));
reset_stack();
if (vallist.is_type(ComValue::ArrayType)) {
AttributeValueList* avl = vallist.array_val();
AddFunc addfunc(comterp());
push_stack(ComValue::zeroval());
Iterator it;
int count = 0;
for (avl->First(it); !avl->Done(it); avl->Next(it)) {
count++;
push_stack(*avl->GetAttrVal(it));
addfunc.exec(2,0);
}
if (_meanfunc) {
DivFunc divfunc(comterp());
ComValue divisor(count, ComValue::IntType);
push_stack(divisor);
divfunc.exec(2,0);
}
} else {
push_stack(vallist);
}
}
示例8: objv
void TransformerFunc::execute() {
ComValue objv(stack_arg(0));
ComValue transv(stack_arg(0));
reset_stack();
if (objv.object_compview()) {
ComponentView* compview = (ComponentView*)objv.obj_val();
if (compview && compview->GetSubject()) {
OverlayComp* comp = (OverlayComp*)compview->GetSubject();
Graphic* gr = comp->GetGraphic();
if (gr) {
Transformer* trans = gr->GetTransformer();
if (transv.is_unknown() || !transv.is_array() || transv.array_val()->Number()!=6) {
AttributeValueList* avl = new AttributeValueList();
float a00, a01, a10, a11, a20, a21;
trans->matrix(a00, a01, a10, a11, a20, a21);
avl->Append(new AttributeValue(a00));
avl->Append(new AttributeValue(a01));
avl->Append(new AttributeValue(a10));
avl->Append(new AttributeValue(a11));
avl->Append(new AttributeValue(a20));
avl->Append(new AttributeValue(a21));
ComValue retval(avl);
push_stack(retval);
} else {
float a00, a01, a10, a11, a20, a21;
AttributeValueList* avl = transv.array_val();
Iterator it;
AttributeValue* av;
avl->First(it);
av = avl->GetAttrVal(it);
a00 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a01 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a10 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a11 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a20 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a21 = av->float_val();
Transformer t(a00, a01, a10, a11, a20, a21);
*gr->GetTransformer()=t;
ComValue compval(new OverlayViewRef(comp), comp->class_symid());
push_stack(compval);
}
}
}
}
}
示例9: ifilev
void TileFileFunc::execute() {
ComValue ifilev(stack_arg(0));
ComValue ofilev(stack_arg(1));
ComValue five12(512);
ComValue twidthv(stack_arg(2, false, five12));
ComValue theightv(stack_arg(3, false, five12));
reset_stack();
const char* ifile = symbol_pntr(ifilev.symbol_ref());
const char* ofile = symbol_pntr(ofilev.symbol_ref());
#ifndef NDEBUG
cerr << "tilefile args - ifn: " << ifile << "ofn: " << ofile
<< ", twidth: " << twidthv.int_val() << ", theight: "
<< theightv.int_val() << "\n";
#endif
if (
ifile && ofile &&
(twidthv.type() == ComValue::IntType) &&
(theightv.type() == ComValue::IntType)
) {
int twidth = twidthv.int_val();
int theight = theightv.int_val();
Command* cmd = new TileFileCmd(_ed, ifile, ofile, twidth, theight);
execute_log(cmd);
}
else {
push_stack(ComValue::nullval());
}
}
示例10: test_lazy
void test_lazy()
{
#ifdef DEFERRED_CALLS_FIRST_DRAFT
Branch branch;
Term* a = branch.compile("a = add(1 2)");
set_lazy_call(a, true);
Stack context;
push_frame(&context, &branch);
run_interpreter(&context);
test_equals(get_register(&context, a), ":Unevaluated");
Frame* frame = push_frame(&context, &branch);
frame->pc = a->index;
frame->startPc = frame->pc;
frame->endPc = frame->pc + 1;
frame->strategy = ByDemand;
run_interpreter(&context);
test_equals(get_register(&context, a), "3");
reset_stack(&context);
Term* b = branch.compile("b = add(a a)");
push_frame(&context, &branch);
run_interpreter(&context);
test_equals(get_register(&context, a), "3");
test_equals(get_register(&context, b), "6");
#endif
}
示例11: listv
void JoinStrFunc::execute() {
ComValue listv(stack_arg(0));
static int sym_symid = symbol_add("sym");
ComValue symflagv(stack_key(sym_symid));
boolean symflag = symflagv.is_true();
reset_stack();
if (listv.is_array()) {
AttributeValueList* avl = listv.array_val();
if (avl) {
char cbuf[avl->Number()+1];
Iterator i;
int cnt=0;
for (avl->First(i); !avl->Done(i); avl->Next(i)) {
cbuf[cnt] = avl->GetAttrVal(i)->char_val();
cnt++;
}
cbuf[cnt] = '\0';
ComValue retval(symbol_add(cbuf), symflag ? ComValue::SymbolType : ComValue::StringType);
push_stack(retval);
return;
}
}
push_stack(ComValue::nullval());
}
示例12: reset_stack
void *connection_handler(void * cconn)
{
struct cconn * cc = (struct cconn*) cconn;
//int sock = *(int*)socket_desc;
char c;
int ret;
int br;
//write(sock , message , strlen(message));
reset_stack ( cc );
while ( (br=read(cc->fd,&c,1)==1 ) )
{
//printf ( "read: %c\n", c );
addc ( cc, c );
}
printf("N: tcpserver: client disconnected\n" );
close ( cc->fd );
free(cc);
return 0;
}
示例13: symbol_add
void WhileFunc::execute() {
static int body_symid = symbol_add("body");
static int until_symid = symbol_add("until");
static int nilchk_symid = symbol_add("nilchk");
ComValue untilflag(stack_key_post_eval(until_symid));
ComValue nilchkflag(stack_key_post_eval(nilchk_symid));
ComValue* bodyexpr = nil;
while (1) {
if (untilflag.is_false()) {
ComValue doneexpr(stack_arg_post_eval(0));
if (nilchkflag.is_false() ? doneexpr.is_false() : doneexpr.is_unknown()) break;
}
delete bodyexpr;
ComValue keybody(stack_key_post_eval(body_symid, false, ComValue::unkval(), true));
if (keybody.is_unknown() && nargsfixed()>= 2)
bodyexpr = new ComValue(stack_arg_post_eval(1));
else
bodyexpr = new ComValue(keybody);
if (untilflag.is_true()) {
ComValue doneexpr(stack_arg_post_eval(0));
if (nilchkflag.is_false() ? doneexpr.is_true() : doneexpr.is_unknown()) break;
}
}
reset_stack();
if (bodyexpr) {
push_stack(*bodyexpr);
delete bodyexpr;
} else
push_stack(ComValue::nullval());
}
示例14: flush_stack
static void flush_stack(void)
{
if (current_pid < 0)
return;
save_call_chain(current_pid, ips, ips_idx, 0);
free(ips);
reset_stack();
}
示例15: stack_arg
void NegFunc::execute() {
ComValue& operand1 = stack_arg(0);
ComValue result(operand1);
result.type(ComValue::BooleanType);
switch (operand1.type()) {
case ComValue::CharType:
result.char_ref() = ! operand1.char_val();
break;
case ComValue::UCharType:
result.uchar_ref() = ! operand1.uchar_val();
break;
case ComValue::ShortType:
result.short_ref() = ! operand1.short_val();
break;
case ComValue::UShortType:
result.ushort_ref() = ! operand1.ushort_val();
break;
case ComValue::IntType:
result.int_ref() = ! operand1.int_val();
break;
case ComValue::UIntType:
result.uint_ref() = ! operand1.uint_val();
break;
case ComValue::LongType:
result.long_ref() = ! operand1.long_val();
break;
case ComValue::ULongType:
result.ulong_ref() = ! operand1.ulong_val();
break;
case ComValue::FloatType:
result.float_ref() = ! operand1.float_val();
break;
case ComValue::DoubleType:
result.double_ref() = ! operand1.double_val();
break;
case ComValue::BooleanType:
result.boolean_ref() = ! operand1.boolean_val();
break;
case ComValue::UnknownType:
result.boolean_ref() = true;
break;
case ComValue::ArrayType:
case ComValue::ObjectType:
result.boolean_ref() = false;
break;
case ComValue::SymbolType:
case ComValue::StringType:
result.boolean_ref() = operand1.symbol_val()<0;
break;
case ComValue::StreamType:
result.boolean_ref() = !operand1.stream_mode();
break;
}
reset_stack();
push_stack(result);
}