Esempio n. 1
0
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);
  }

}
Esempio n. 2
0
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);
	  }
	}
      } 	
    }
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
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);
}
Esempio n. 5
0
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());
}
Esempio n. 6
0
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);    
}
Esempio n. 7
0
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());
}
Esempio n. 8
0
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);
  }
}
Esempio n. 9
0
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);
}
Esempio n. 10
0
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);
  }
}
Esempio n. 11
0
void SymbolFunc::execute() {
  // return symbol for each id argument
  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_char() || val.is_short() || val.is_int())
      symbol_ids[i] = val.int_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++) {
      ComValue* av = new ComValue(symbol_ids[i], AttributeValue::SymbolType);
      av->bquote(1);
      avl->Append(av);
    }
    push_stack(retval);
  } else {
    ComValue retval (symbol_ids[0], AttributeValue::SymbolType);
    retval.bquote(1);
    push_stack(retval);
  }

}
Esempio n. 12
0
void CreateLineFunc::execute() {
    const int x0 = 0;  
    const int y0 = 1;  
    const int x1 = 2;  
    const int y1 = 3;  
    const int n = 4;
    int coords[n];
    ComValue& vect = stack_arg(0);
    if (!vect.is_type(ComValue::ArrayType) || vect.array_len() != n) {
        reset_stack();
	push_stack(ComValue::nullval());
	return;
    }

    ALIterator i;
    AttributeValueList* avl = vect.array_val();
    avl->First(i);
    for (int j=0; j<n && !avl->Done(i); j++) {
        coords[j] = avl->GetAttrVal(i)->int_val();
	avl->Next(i);
    }

    AttributeList* al = stack_keys();
    Resource::ref(al);
    reset_stack();

    PasteCmd* cmd = nil;

    if (coords[x0] != coords[x1] || coords[y0] != coords[y1]) {
	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");
	ArrowLine* line = new ArrowLine(coords[x0], coords[y0], coords[x1], coords[y1], aVar->Head(), aVar->Tail(), 
					_ed->GetViewer()->GetMagnification(), stdgraphic);

	if (brVar != nil) line->SetBrush(brVar->GetBrush());

	if (colVar != nil) {
	    line->FillBg(!colVar->GetBgColor()->None());
	    line->SetColors(colVar->GetFgColor(), colVar->GetBgColor());
            }
	line->SetTransformer(rel);
	Unref(rel);
	ArrowLineOvComp* comp = new ArrowLineOvComp(line);
	comp->SetAttributeList(al);
	if (PasteModeFunc::paste_mode()==0)
	  cmd = new PasteCmd(_ed, new Clipboard(comp));
	ComValue compval(new OverlayViewRef(comp), symbol_add("ArrowLineComp"));
	push_stack(compval);
	execute_log(cmd);
    } else 
	push_stack(ComValue::nullval());

    Unref(al);
}
Esempio n. 13
0
void CreateEllipseFunc::execute() {
    const int x0 = 0;  
    const int y0 = 1;  
    const int r1 = 2;  
    const int r2 = 3;  
    const int n = 4;
    int args[n];
    ComValue& vect = stack_arg(0);
    if (!vect.is_type(ComValue::ArrayType) ||  vect.array_len() != n) {
        reset_stack();
	push_stack(ComValue::nullval());
	return;
    }

    ALIterator i;
    AttributeValueList* avl = vect.array_val();
    avl->First(i);
    for (int j=0; j<n && !avl->Done(i); j++) {
        args[j] = avl->GetAttrVal(i)->int_val();
	avl->Next(i);
    }

    AttributeList* al = stack_keys();
    Resource::ref(al);
    reset_stack();

    PasteCmd* cmd = nil;

    if (args[r1] > 0 && args[r2] > 0) {
	BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar");
	PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar");
	ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar");

	Transformer* rel = get_transformer(al);
	
	SF_Ellipse* ellipse = new SF_Ellipse(args[x0], args[y0], args[r1], args[r2], stdgraphic);

	if (brVar != nil) ellipse->SetBrush(brVar->GetBrush());
	if (patVar != nil) ellipse->SetPattern(patVar->GetPattern());

	if (colVar != nil) {
	    ellipse->FillBg(!colVar->GetBgColor()->None());
	    ellipse->SetColors(colVar->GetFgColor(), colVar->GetBgColor());
            }
	ellipse->SetTransformer(rel);
	Unref(rel);
	EllipseOvComp* comp = new EllipseOvComp(ellipse);
	comp->SetAttributeList(al);
	if (PasteModeFunc::paste_mode()==0)
	  cmd = new PasteCmd(_ed, new Clipboard(comp));
	ComValue compval( new OverlayViewRef(comp), symbol_add("EllipseComp"));
	push_stack(compval);
	execute_log(cmd);
    } else 
	push_stack(ComValue::nullval());

    Unref(al);
}
Esempio n. 14
0
void CreateTextFunc::execute() {
    const int x0 = 0;  
    const int y0 = 1;  
    const int n = 2;
    int args[n];
    ComValue& vect = stack_arg(0);
    ComValue& txtv = stack_arg(1);
    if (!vect.is_type(ComValue::ArrayType) || vect.array_len() != n) {
        reset_stack();
	push_stack(ComValue::nullval());
	return;
    }

    ALIterator i;
    AttributeValueList* avl = vect.array_val();
    avl->First(i);
    for (int j=0; j<n && !avl->Done(i); j++) {
        args[j] = avl->GetAttrVal(i)->int_val();
	avl->Next(i);
    }

    const char* txt = symbol_pntr( txtv.symbol_ref() );

    AttributeList* al = stack_keys();
    Resource::ref(al);
    reset_stack();
   
    PasteCmd* cmd = nil;
    
    if (txt) {
	ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar");
	FontVar* fntVar = (FontVar*) _ed->GetState("FontVar");
	
        Transformer* rel = get_transformer(al);
	
	TextGraphic* text = new TextGraphic(txt, stdgraphic);

	if (colVar != nil) {
	    text->FillBg(!colVar->GetBgColor()->None());
	    text->SetColors(colVar->GetFgColor(), colVar->GetBgColor());
            }
	if (fntVar != nil) text->SetFont(fntVar->GetFont());
	text->SetTransformer(new Transformer());
	text->Translate(args[x0], args[y0]);
	text->GetTransformer()->postmultiply(rel);
	Unref(rel);
	TextOvComp* comp = new TextOvComp(text);
	comp->SetAttributeList(al);
	if (PasteModeFunc::paste_mode()==0)
	  cmd = new PasteCmd(_ed, new Clipboard(comp));
	ComValue compval(new OverlayViewRef(comp), symbol_add("TextComp"));
	push_stack(compval);
	execute_log(cmd);
    } else
        push_stack(ComValue::nullval());

    Unref(al);
}
Esempio n. 15
0
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;
}
Esempio n. 16
0
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);
}
Esempio n. 17
0
void Log2Func::execute() {
    ComValue operandx = stack_arg(0);
    reset_stack();
    if (operandx.is_nil()) {
      push_stack(ComValue::nullval());
      return;
    }
    ComValue result(log2(operandx.double_val()));
    push_stack(result);
}
Esempio n. 18
0
void PowFunc::execute() {
    ComValue operandx = stack_arg(0);
    ComValue operandy = stack_arg(1);
    reset_stack();
    if (operandx.is_nil() || operandy.is_nil()) {
      push_stack(ComValue::nullval());
      return;
    }
    ComValue result(pow(operandx.double_val(), operandy.double_val()));
    push_stack(result);
}
Esempio n. 19
0
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; 	
}
Esempio n. 20
0
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;
    }
  }
}
Esempio n. 21
0
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);
	}
}
Esempio n. 22
0
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());
}
Esempio n. 23
0
void arch_prepare_thread(struct thread *t,
                         void asmlinkage (*thread_entry)(void *), void *arg)
{
	uintptr_t stack = t->stack_current;

	/* Imitate thread_entry(t) with return address of 0. thread_entry()
	 * is assumed to never return. */
	stack = push_stack(stack, (uintptr_t)arg);
	stack = push_stack(stack, (uintptr_t)0);
	stack = push_stack(stack, (uintptr_t)thread_entry);
	/* Make room for the registers. Ignore intial values. */
	stack -= sizeof(struct pushad_regs);

	t->stack_current = stack;
}
Esempio n. 24
0
void text_para_context::start_element(xmlns_id_t ns, xml_token_t name, const xml_attrs_t& attrs)
{
    xml_token_pair_t parent = push_stack(ns, name);
    if (ns == NS_odf_text)
    {
        switch (name)
        {
            case XML_p:
                // paragraph
                xml_element_expected(parent, XMLNS_UNKNOWN_ID, XML_UNKNOWN_TOKEN);
            break;
            case XML_span:
            {
                // text span.
                xml_element_expected(parent, NS_odf_text, XML_p);
                flush_segment();
                pstring style_name =
                    for_each(attrs.begin(), attrs.end(), single_attr_getter(m_pool, NS_odf_text, XML_style_name)).get_value();
                m_span_stack.push_back(style_name);

            }
            break;
            case XML_s:
                // control character.  ignored for now.
            break;
            default:
                warn_unhandled();
        }
    }
    else
        warn_unhandled();
}
Esempio n. 25
0
int main(int argc, char **argv) {
  int i;
  int x;
  int p;
  Stack stack = new_stack(argc);
  for(i=0; i <= argc; i++){
    if(argv[i] == NULL){
      printf("you have no args %d", i);
      break;
    }
    else if(isdigit(argv[i][0])){
      p = atoi(argv[i]);
      printf("arg %d\n", p);
      push_stack(stack, p);
    }
    else if(strcmp(argv[i],"+")==0 || strcmp(argv[i],"-")==0 || strcmp(argv[i],"x")==0 || strcmp(argv[i],"/")==0){
      printf("arg %s\n", argv[i]);
      char* arg = argv[i];
      calc(arg, stack);
    }
    else{
      printf("args %s", argv[i]);
    }
  }
}
Esempio n. 26
0
extern inline void maybe_mark_and_push(unix_socket *x)
{
	if (x->protinfo.af_unix.marksweep&MARKED)
		return;
	x->protinfo.af_unix.marksweep|=MARKED;
	push_stack(x);
}
Esempio n. 27
0
int main(void){
	Pilha my_stack;
	fila my_queue;
	iniciar_stack(tamanho,&my_stack);
	iniciar_queue(tamanho,&my_queue);
	
	for(register unsigned int cont = 0 ; cont < 10 ; cont ++){
		push_queue(cont,&my_queue);
		printf("Fila(%d):%d\n",cont+1,cont);
	}
	int *aux;
	aux = (int*)malloc((sizeof(tamanho)));
	aux = listar_queue(my_queue);
	for(register unsigned int cont = 0 ; cont < 10 ; cont ++){
		int valor = aux[cont];
		push_stack(valor,&my_stack);
		printf("Fila(%d):%d\n",cont+1,aux[cont]);
		pop_queue(&my_queue);
	}
	int quantidade;
	aux = listar_stack(my_stack,&quantidade);
	for(register unsigned int cont = 0 ; cont < 10 ; cont ++){
		int valor = aux[cont];
		push_queue(valor,&my_queue);
		printf("Fila(%d):%d\n",cont+1,aux[cont]);
	}
	free(aux);
}
/* virtual */ void CollisionShapeNodeVisitor::visit(CollisionShapeNode* node) {
  
  pop_stack(node);
  math::mat4 curr_matrix(matrix_stack_.top() * node->get_transform());

  if (shape_index_ >= rigid_body_->shapes().size()) {
    rigid_body_->shapes().push_back(RigidBodyNode::ShapeElement());
    resync_ = true;
  }
  RigidBodyNode::ShapeElement& sh = rigid_body_->shapes().at(shape_index_);
  if (sh.transform != curr_matrix) {
    sh.transform = curr_matrix;
    resync_ = true;
  }
  if (sh.shape_name != node->data.get_shape()) {
    sh.shape = CollisionShapeDatabase::instance()->lookup(node->data.get_shape());
    sh.shape_name = node->data.get_shape();
    resync_ = true;
  }
  ++shape_index_;

  // visit children of the collision shape
  if (node->has_children()) {
    push_stack(curr_matrix);

    for (auto child : node->children_)
      child->accept(*this);
  }
}
Esempio n. 29
0
static fz_draw_state *
fz_knockout_begin(fz_draw_device *dev)
{
	fz_context *ctx = dev->ctx;
	fz_bbox bbox;
	fz_pixmap *dest, *shape;
	fz_draw_state *state = &dev->stack[dev->top];
	int isolated = state->blendmode & FZ_BLEND_ISOLATED;

	if ((state->blendmode & FZ_BLEND_KNOCKOUT) == 0)
		return state;

	state = push_stack(dev);

	bbox = fz_pixmap_bbox(dev->ctx, state->dest);
	bbox = fz_intersect_bbox(bbox, state->scissor);
	dest = fz_new_pixmap_with_bbox(dev->ctx, state->dest->colorspace, bbox);

	if (isolated)
	{
		fz_clear_pixmap(ctx, dest);
	}
	else
	{
		/* Find the last but one destination to copy */
		int i = dev->top-1; /* i = the one on entry (i.e. the last one) */
		fz_pixmap *prev = state->dest;
		while (i > 0)
		{
			prev = dev->stack[--i].dest;
			if (prev != state->dest)
				break;
		}
		if (prev)
			fz_copy_pixmap_rect(ctx, dest, prev, bbox);
		else
			fz_clear_pixmap(ctx, dest);
	}

	if (state->blendmode == 0 && isolated)
	{
		/* We can render direct to any existing shape plane. If there
		 * isn't one, we don't need to make one. */
		shape = state->shape;
	}
	else
	{
		shape = fz_new_pixmap_with_bbox(dev->ctx, NULL, bbox);
		fz_clear_pixmap(dev->ctx, shape);
	}
#ifdef DUMP_GROUP_BLENDS
	dump_spaces(dev->top-1, "Knockout begin\n");
#endif
	state[1].scissor = bbox;
	state[1].dest = dest;
	state[1].shape = shape;
	state[1].blendmode &= ~FZ_BLEND_MODEMASK;

	return &state[1];
}
Esempio n. 30
0
static void
fz_draw_clip_path(fz_device *devp, fz_path *path, fz_rect rect, int even_odd, fz_matrix ctm)
{
	fz_draw_device *dev = devp->user;
	float expansion = fz_matrix_expansion(ctm);
	float flatness = 0.3f / expansion;
	fz_bbox bbox;
	fz_draw_state *state = &dev->stack[dev->top];
	fz_colorspace *model;
	fz_context *ctx = dev->ctx;

	fz_reset_gel(dev->gel, state->scissor);
	fz_flatten_fill_path(dev->gel, path, ctm, flatness);
	fz_sort_gel(dev->gel);

	state = push_stack(dev);
	model = state->dest->colorspace;

	bbox = fz_bound_gel(dev->gel);
	bbox = fz_intersect_bbox(bbox, state->scissor);
	bbox = fz_intersect_bbox(bbox, fz_bbox_from_rect(rect));
	/* SumatraPDF: try to match rendering with and without display list */
	if (fz_is_infinite_rect(rect))
		bbox = fz_intersect_bbox(bbox, fz_bbox_from_rect(fz_bound_path(ctx, path, NULL, ctm)));

	if (fz_is_empty_rect(bbox) || fz_is_rect_gel(dev->gel))
	{
		state[1].scissor = bbox;
		state[1].mask = NULL;
#ifdef DUMP_GROUP_BLENDS
		dump_spaces(dev->top-1, "Clip (rectangular) begin\n");
#endif
		return;
	}

	fz_try(ctx)
	{
		state[1].mask = fz_new_pixmap_with_bbox(dev->ctx, NULL, bbox);
		fz_clear_pixmap(dev->ctx, state[1].mask);
		state[1].dest = fz_new_pixmap_with_bbox(dev->ctx, model, bbox);
		fz_clear_pixmap(dev->ctx, state[1].dest);
		if (state[1].shape)
		{
			state[1].shape = fz_new_pixmap_with_bbox(dev->ctx, NULL, bbox);
			fz_clear_pixmap(dev->ctx, state[1].shape);
		}

		fz_scan_convert(dev->gel, even_odd, bbox, state[1].mask, NULL);

		state[1].blendmode |= FZ_BLEND_ISOLATED;
		state[1].scissor = bbox;
#ifdef DUMP_GROUP_BLENDS
		dump_spaces(dev->top-1, "Clip (non-rectangular) begin\n");
#endif
	}
	fz_catch(ctx)
	{
		emergency_pop_stack(dev, state);
	}
}