当前位置: 首页>>代码示例>>C++>>正文


C++ push_stack函数代码示例

本文整理汇总了C++中push_stack函数的典型用法代码示例。如果您正苦于以下问题:C++ push_stack函数的具体用法?C++ push_stack怎么用?C++ push_stack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了push_stack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: nargs

void SymIdFunc::execute() {
  // return id of each symbol in the arguments
  boolean noargs = !nargs() && !nkeys();
  int numargs = nargs();
  if (!numargs) return;
  int symbol_ids[numargs];
  for (int i=0; i<numargs; i++) {
    ComValue& val = stack_arg(i, true);
    if (val.is_type(AttributeValue::CommandType))
      symbol_ids[i] = val.command_symid();
    else if (val.is_type(AttributeValue::StringType))
      symbol_ids[i] = val.string_val();
    else if (val.is_type(AttributeValue::SymbolType))
      symbol_ids[i] = val.symbol_val();
    else 
      symbol_ids[i] = -1;
  }
  reset_stack();

  if (numargs>1) {
    AttributeValueList* avl = new AttributeValueList();
    ComValue retval(avl);
    for (int i=0; i<numargs; i++)
      avl->Append(new AttributeValue(symbol_ids[i], AttributeValue::IntType));
    push_stack(retval);
  } else {
    ComValue retval (symbol_ids[0], AttributeValue::IntType);
    push_stack(retval);
  }

}
开发者ID:barak,项目名称:ivtools-cvs,代码行数:31,代码来源:symbolfunc.c

示例2: 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);
	  }
	}
      } 	
    }
}
开发者ID:jmzaleski,项目名称:ivtools-1.2,代码行数:60,代码来源:grfunc.c

示例3: calc

void calc(char* operand, Stack stack){
  int one = NULL;
  int two = NULL;
  if (can_pop_stack){
    two = pop_stack(stack);
    one = pop_stack(stack);
  }
  else{
    printf("your stack is full");
    return;
  }
  int three;
  if (strcmp(operand,"+")==0){
    three = one + two;
    printf("calc %d", three);
    push_stack(stack, three);
  }
  else if (strcmp(operand,"-")==0){
    three = one - two;
    printf("calc %d", three);
    push_stack(stack, three);
  }
  else if (strcmp(operand,"x")==0){
    three = one * two;
    printf("calc %d", three);
    push_stack(stack, three);
  }
  else{
    three = one / two;
    printf("calc %d", three);
    push_stack(stack, three);
  }
  return;
}
开发者ID:michellethomas,项目名称:see_play,代码行数:34,代码来源:rpn_calc.c

示例4: deal_tmp

void deal_tmp(sqstack *operator, sqstack *operand, char ch)
{
   int op1, op2;

   while ( convert_operator(ch) <= convert_operator((char)top_stack(operator)) )
   {
      op2 = pop_stack(operand);
      op1 = pop_stack(operand);
      switch ( (char)pop_stack(operator) )
      {
         case '+' :
                   printf("push data: %d + %d\n", op1, op2);
                   push_stack(operand, op1 + op2);
                   break;
         case '-' :
                   printf("push data: %d - %d\n", op1, op2);
                   push_stack(operand, op1 - op2);
                   break;
         case '*' :
                   printf("push data: %d * %d\n", op1, op2);
                   push_stack(operand, op1 * op2);
                   break;
         case '/' :
                   printf("push data: %d / %d\n", op1, op2);
                   push_stack(operand, op1 / op2);
                   break;
      }
      if ( empty_stack(operator) || ((char)pop_stack(operator) == '(') ) 
      {
         break;
      }      
   }
   push_stack(operator, (int)ch);
}
开发者ID:mysticTot,项目名称:learn_c,代码行数:34,代码来源:sample.c

示例5: 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());
}
开发者ID:barak,项目名称:ivtools-cvs,代码行数:26,代码来源:symbolfunc.c

示例6: deal_bracket

void deal_bracket(sqstack *operator, sqstack *operand)
{
   int op1, op2;


   while ( (char)top_stack(operator) != '(' )
   {
      op2 = pop_stack(operand);
      op1 = pop_stack(operand);
      switch ( (char)pop_stack(operator) )
      {
         case '+' :
                   printf("push data: %d + %d\n", op1, op2);
                   push_stack(operand, op1 + op2);
                   break;
         case '-' :
                   printf("push data: %d - %d\n", op1, op2);
                   push_stack(operand, op1 - op2);
                   break;
         case '*' :
                   printf("push data: %d * %d\n", op1, op2);
                   push_stack(operand, op1 * op2);
                   break;
         case '/' :
                   printf("push data: %d / %d\n", op1, op2);
                   push_stack(operand, op1 / op2);
                   break;
      }
   } 
   pop_stack(operator);    
}
开发者ID:mysticTot,项目名称:learn_c,代码行数:31,代码来源:sample.c

示例7: 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());
}
开发者ID:steinarb,项目名称:interviews,代码行数:30,代码来源:postfunc.c

示例8: 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);
  }
}
开发者ID:barak,项目名称:ivtools-cvs,代码行数:25,代码来源:statfunc.c

示例9: 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);
}
开发者ID:jmzaleski,项目名称:ivtools-1.2,代码行数:60,代码来源:grfunc.c

示例10: ReverseCipherExpression

PCIPHEREXP __INTERNAL_FUNC__ ReverseCipherExpression(PCIPHEREXP pCipherExp) {
	/*
	 * 再压入操作符号与操作节点时
	 * 链中第一个节点不压入栈
	 * 最后一个操作符号不压入栈
	 *
	 * 逆向式中的第一个节点肯定没有操作符号
	 */
	__bool bIsFirst = TRUE;
	LOGIC_OPT *pOpt = NULL;
	PCIPHEREXP pReverseCipherExp = NULL, *pReverseCipherExpPoint = NULL;
	PCIPHEREXP pCurrCipherExp = pCipherExp;
	PSTACK pOptStack = init_stack(0);
	__integer i = 0, iCipherNodeCount = CountCipherNode(pCipherExp);
	PSTACK pCipherExpNodeStack = init_stack(sizeof(CIPHEREXP) * iCipherNodeCount);
	for (i = 0; i < iCipherNodeCount; i++) {
		if (i == 0) {//舍弃第一个节点
			push_stack(pOptStack, &(pCurrCipherExp->Opt), sizeof(LOGIC_OPT));
		} else if (i == iCipherNodeCount-1) {
			push_stack(pCipherExpNodeStack, pCurrCipherExp, sizeof(CIPHEREXP));
		} else {
			push_stack(pOptStack, &(pCurrCipherExp->Opt), sizeof(LOGIC_OPT));
			push_stack(pCipherExpNodeStack, pCurrCipherExp, sizeof(CIPHEREXP));
		}
		pCurrCipherExp = pCurrCipherExp->pNextExp;
	}

	/*
	 * 首先扩充第一个节点(变量)
	 */
	pReverseCipherExpPoint = &pReverseCipherExp;
	do {
		pOpt = (LOGIC_OPT *)pop_stack(pOptStack, sizeof(LOGIC_OPT));
		(*pReverseCipherExpPoint) = CreateCipherExp();

		// 如果是第一个节点
		if (bIsFirst) {
			(*pReverseCipherExpPoint)->bNot = pCipherExp->bNot;//第一个变量是否拥有NOT操作
			(*pReverseCipherExpPoint)->Opt = GenerateReverseLogicOpt(*pOpt);	
			bIsFirst = FALSE;
		} else {
			if (!pOpt)
				(*pReverseCipherExpPoint)->Opt = LOGIC_NONE;
			else
				(*pReverseCipherExpPoint)->Opt = *pOpt;
			pCurrCipherExp = (PCIPHEREXP)pop_stack(pCipherExpNodeStack, sizeof(CIPHEREXP));
			(*pReverseCipherExpPoint)->bKey = pCurrCipherExp->bKey;
			(*pReverseCipherExpPoint)->bNot = pCurrCipherExp->bNot;
			(*pReverseCipherExpPoint)->dwVal = pCurrCipherExp->dwVal;
		}/* end else */
		pReverseCipherExpPoint = &((*pReverseCipherExpPoint)->pNextExp);
	} while (pOpt);
	free_stack(pOptStack);
	free_stack(pCipherExpNodeStack);
	return pReverseCipherExp;
}
开发者ID:453483289,项目名称:cerberus,代码行数:56,代码来源:CipherExpGen.c

示例11: stack_arg

void DegToRadFunc::execute() {
    ComValue operandx = stack_arg(0);
    reset_stack();
    if (operandx.is_nil()) {
      push_stack(ComValue::nullval());
      return;
    }
    ComValue result(operandx.double_val()*2*3.1415926535897932270E0/360.);
    push_stack(result);
}
开发者ID:jmzaleski,项目名称:ivtools-1.2,代码行数:10,代码来源:mathfunc.c

示例12: push_Stack

int push_Stack(BiTree s)
{
	if(s->top== size-1 || root == NULL)
		return 0;
	s->top++;
	s->base[s->top]=root;
	s->base[(s->top)*2]=root->Lchild;
	push_stack(root->Lchild,s);
	push_stack(root->Rchild,s);
	return 1; 	
}
开发者ID:Lyrics1,项目名称:learn_git,代码行数:11,代码来源:栈的二叉树.cpp

示例13: __parser

void __parser(lp_token** input,
              int count)
{
  success=false;
  int top_state=0;
  int input_index=0;
  int accept_state=16;
  int pop_count=0;
  int action=0;

  //initialize the stack at state 0
  pcstack* parse_stack=new_pcstack();
  push_stack(parse_stack,(void*)new_token(0,0));

  while(true)
  {
    top_state=((lp_token*)peek_stack(parse_stack))->lex_id;
    if(input_index==count)action=parse_table[top_state][12];
    else if(input[input_index]->lex_id>=12)return;
    else action=parse_table[top_state][input[input_index]->lex_id];

    if(action==accept_state)//accept
    {
      action=-((lp_token*)peek_stack(parse_stack))->lex_id;
      __prh(&action,parse_stack);
      //printf("accept\n");
      success=true;
      return;
    }
    if(action>0)//shift
    {
      //printf("shift\n");
      push_stack(parse_stack,(void*)new_token(action,input[input_index]->lex_val));
      ++input_index;
    }
    else if(action<0)//reduce
    {
      pop_count=__prh(&action,parse_stack);
      if(pop_count==-1)break;//catch errors here
      while(pop_count>0)
      {
        pop_stack(parse_stack);
        --pop_count;
      }
      push_stack(parse_stack,(void*)new_token(parse_table[((lp_token*)peek_stack(parse_stack))->lex_id][action],0));
      //printf("reduce\n");
    }
    else//error
    {
      //printf("error\n");
      return;
    }
  }
}
开发者ID:jmgunn87,项目名称:clrgen,代码行数:54,代码来源:parser.cpp

示例14: check_phi_src

void ra_checker::run_on(container_node* c) {

	if (c->is_region()) {
		region_node *r = static_cast<region_node*>(c);
		if (r->loop_phi) {
			check_phi_src(r->loop_phi, 0);
			process_phi_dst(r->loop_phi);
		}
	} else if (c->is_depart()) {

		push_stack();

	} else if (c->is_repeat()) {

		push_stack();

	}

	for (node_iterator I = c->begin(), E = c->end(); I != E; ++I) {
		node *n = *I;

		if(n->is_cf_inst() || n->is_fetch_inst()) {
			check_op_src(n);
			process_op_dst(n);
		}

		if (n->is_container()) {
			if (n->is_alu_group()) {
				check_alu_group(static_cast<alu_group_node*>(n));
			} else {
				container_node *nc = static_cast<container_node*>(n);
				run_on(nc);
			}
		}
	}

	if (c->is_depart()) {
		depart_node *r = static_cast<depart_node*>(c);
		check_phi_src(r->target->phi, r->dep_id);
		pop_stack();
	} else if (c->is_repeat()) {
		repeat_node *r = static_cast<repeat_node*>(c);
		assert (r->target->loop_phi);

		pop_stack();
	} else if (c->is_region()) {
		region_node *r = static_cast<region_node*>(c);
		if (r->phi)
			process_phi_dst(r->phi);
	}
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:51,代码来源:sb_ra_checker.cpp

示例15: symvalv

void SplitStrFunc::execute() {
  ComValue symvalv(stack_arg(0));
  reset_stack();

  if (symvalv.is_string()) {
    AttributeValueList* avl = new AttributeValueList();
    ComValue retval(avl);
    const char* str = symvalv.symbol_ptr();
    int len = strlen(str);
    for (int i=0; i<len; i++)
      avl->Append(new AttributeValue(str[i]));
    push_stack(retval);
  } else
    push_stack(ComValue::nullval());
}
开发者ID:barak,项目名称:ivtools-cvs,代码行数:15,代码来源:symbolfunc.c


注:本文中的push_stack函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。