Exemple #1
0
void transform_two_array(int n)
{
	char dst2[expr_size];
	char op[expr_size],dst[expr_size],type[expr_size],op1[expr_size],expr[expr_size],op2[expr_size],expr1[expr_size];
	sscanf(inst[n],"%s %s %s",op,expr,type);
	
	int size=0;
	sscanf(type,"%d",&size);

	sscanf(inst[n+1],"%s %s %s",op1,dst,type);
	sscanf(inst[n+3],"%s %s %s",op2,expr1,dst2);

	char name[expr_size];
	if(find_base(dst,name))//有数组的标志,带有base
	{
		if(strcmp(type,"GP")==0)
		{
			strcpy(var_name[num_v],name);
			asize[num_v++]=size/8;
		}
		sprintf(inst[n],"nop ");
		sprintf(inst[n+1],"nop ");


		int reg=0;
		int t=get_op(expr,dst,reg);
		
		if(t==1)
			sprintf(inst[n+2],"ok %s",dst);
		else if(t==3)
		{
			sprintf(inst[n]," var %s ",expr);
			sprintf(inst[n+2],"ok %s",dst);
		}
		else if(t==2)
		{
			sprintf(inst[n+2],"expr %d",reg);
		}

		t=0,reg=0;
		t=get_op(expr1,dst,reg);
		
		if(t==1)
			sprintf(inst[n+3],"ok %s",dst);
		else if(t==3)
		{
			sprintf(inst[n+1]," var %s ",expr1);
			sprintf(inst[n+3],"ok %s",dst);
		}
		else if(t==2)
		{
			sprintf(inst[n+3],"expr %d",reg);
		}

		sprintf(inst[n+4],"array2 %s %s %d",name,type,size/8);
	}
}
Exemple #2
0
std:: string POETUop:: toString(ASTOutputEnum config)
    { 
     switch (get_op())
      {
        case POET_OP_RETURN: case POET_OP_CAR: case POET_OP_CDR: case POET_OP_COPY: case POET_OP_LEN:
        case POET_OP_REBUILD: case POET_OP_RESTORE: case POET_OP_SAVE: case POET_OP_CLEAR:
            return std::string(OpName[get_op()])+"("+arg->toString(config)+")";
        case POET_OP_NOT: case POET_OP_UMINUS:
            return std::string(OpName[get_op()])+arg->toString(config);
        case POET_OP_DELAY: case POET_OP_APPLY:
            return std::string(OpName[get_op()])+"{"+arg->toString(config)+"}";
        default:return POETOperator::toString(config); 
      }
    }
Exemple #3
0
std:: string POETBop:: toString(ASTOutputEnum config)
      {
       switch (get_op())
       {
        case POET_OP_SEQ: 
           return get_arg(0)->toString(config) + ";" + get_arg(1)->toString(config);
        case POET_OP_ERASE: 
             if (get_arg(0) == get_arg(1))
               return "ERASE("+get_arg(0)->toString(config) + ")";
        case POET_OP_MAP: case POET_OP_LIST: case POET_OP_LIST1: case POET_OP_REPLACE: case POET_OP_PERMUTE: case POET_OP_TRACE: case POET_OP_INSERT: case POET_OP_SPLIT:
               return POETOperator::toString(config);
        case POET_OP_DEBUG: 
              return "DEBUG["+get_arg(0)->toString(config)+"]"+"{"+get_arg(1)->toString(config)+"}";
        case POET_OP_DOT:
              return get_arg(0)->toString(config) + "." + get_arg(1)->toString(OUTPUT_NO_DEBUG);
        case POET_OP_TYPEMATCH: 
        {
        std::string opd2_string = arg2->toString(config);;
        if (config != OUTPUT_NO_DEBUG) return arg1->toString(config) + "=>" + opd2_string;
        if (arg1->get_enum() == SRC_LIST) 
           {
           POETList* opd1_list = static_cast<POETList*>(arg1);
           POETCode* opd1_head = opd1_list->get_first(), *opd1_tail=opd1_list->get_rest();
           std::string res = opd1_head->toString(config);
           if (opd1_head->get_enum() == SRC_LIST)
               res= res + " //@BEGIN(" + opd2_string + ")" + opd1_tail->toString(config);
           else if (opd1_head->get_enum() == SRC_OP)
               res= res + " BEGIN(" + opd2_string + ")" + opd1_tail->toString(config);
           else return res + opd1_tail->toString(config) + "//@ =>" + opd2_string;
           if (opd1_tail->get_enum() == SRC_OP) return res + " END(" + opd2_string + ")";
           else return res + " //@END(" + opd2_string + ")";
           }
         else if (arg1->get_enum() == SRC_OP)
           return "\n//@; BEGIN("+opd2_string+")"+arg1->toString(config)+" END("+opd2_string+")"; 
         return arg1->toString(config) + "//@ =>" + opd2_string;
        } 
        case POET_OP_CASE: return "case " + get_arg(0)->toString(config)+":"+get_arg(1)->toString(config);
        default:
            std::string opd1_string = arg1->toString(config),
                  opd2_string = arg2->toString(config);
            if (arg1->get_enum() == SRC_OP &&
                static_cast<POETOperator*>(arg1)->get_op() < get_op())
               opd1_string = "(" + opd1_string + ")";
            if (arg2->get_enum() == SRC_OP &&
                static_cast<POETOperator*>(arg2)->get_op() < get_op())
               opd2_string = "(" + opd2_string + ")";
            return opd1_string + std::string(OpName[get_op()]) + opd2_string;
       }
     }
// send an async message to a service asynchronously
Boolean ModuleController::ModuleSendAsync(const pegasus_module & handle,
					  Uint32 msg_handle,
					  Uint32 destination_q,
					  AsyncRequest *message,
					  void *callback_parm)
{
   //printf("verifying handle %p, controller at %p \n", &handle, this);

   if ( false == verify_handle(const_cast<pegasus_module *>(&handle)))
      throw(Permission(pegasus_thread_self()));

   if (message->op == NULL)
   {
      message->op = get_op();
      message->op->put_request(message);
   }


   callback_handle *cb = new callback_handle(const_cast<pegasus_module *>(&handle),
					     callback_parm);

   message->setRouting(msg_handle);
   message->resp = getQueueId();
   message->block = false;
   message->dest = destination_q;
   return SendAsync(message->op,
		    destination_q,
		    _async_handleEnqueue,
		    this,
		    cb);
}
Exemple #5
0
char	*ft_clean_line(char *line)
{
	t_pos	pos_i;
	int		i_cpy;
	int		i;
	int		c_op;
	char	*clean;

	if (!init_var_n_check(line, &i, &pos_i, &i_cpy))
		return (NULL);
	clean = (char *)ft_memalloc(ft_strlen(line));
	while (line[++i])
		if (ft_isunixspec(line[i]) && (c_op = get_op(line[i], line[i + 1])))
		{
			if (pos_i.i != -1 && (i == pos_i.i + 1 || (i == pos_i.i + 2 &&
				(pos_i.op == DDIRL || pos_i.op == DDIRR))))
				return (ft_error(PEOP, NULL, -1), NULL);
			if (!ft_issame(c_op, pos_i.op) &&
					(ft_addnchar(line + i_cpy, &clean, i - i_cpy)))
				if (pos_i.i != -1 && pos_i.op != 1)
					return (clean);
			i_cpy = i;
			pos_i = POS(i, c_op);
			i = (c_op == DDIRL || c_op == DDIRR) ? i + 1 : i;
		}
	ft_addnchar(line + i_cpy, &clean, i - i_cpy);
	return (clean);
}
Exemple #6
0
void transform_array(int n)//数组转换
{
	char op[expr_size],fuc1[expr_size],type[expr_size],op1[expr_size],expr[expr_size];
	sscanf(inst[n],"%s %s %s",op,expr,type);
	sscanf(inst[n+1],"%s %s %s",op1,fuc1,type);
	
	char name[expr_size];
	if(find_base(fuc1,name))//有数组的标志,带有base
	{
		if(strcmp(type,"GP")==0)
		{
			strcpy(var_name[num_v++],name);
		}

		sprintf(inst[n]," nop ");
		sprintf(inst[n+1]," nop ");

		int reg=0;
		int t=get_op(expr,fuc1,reg);
		
		if(t==1)
			sprintf(inst[n+2]," array %s[%s] %s %s ",name,fuc1,name,type);
		else if(t==3)
		{
			sprintf(inst[n+1]," var %s ",expr);
			sprintf(inst[n+2]," array %s[%s] %s %s ",name,fuc1,name,type);
		}
		else if(t==2)
		{
			sprintf(inst[n+2]," array %s[(%s)] %s %s %s %d",name,expr,name,type,"reg",reg);
		}
	}
}
static void perturb_latent_entropy(basic_block bb, tree rhs)
{
	gimple_stmt_iterator gsi;
	gimple assign;
	tree addxorrol, temp;

	// 1. create temporary copy of latent_entropy
	temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
	add_referenced_var(temp);

	// 2. read...
	temp = make_ssa_name(temp, NULL);
	assign = gimple_build_assign(temp, latent_entropy_decl);
	SSA_NAME_DEF_STMT(temp) = assign;
	add_referenced_var(latent_entropy_decl);
	gsi = gsi_after_labels(bb);
	gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
	update_stmt(assign);

	// 3. ...modify...
	addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
	temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
	assign = gimple_build_assign(temp, addxorrol);
	SSA_NAME_DEF_STMT(temp) = assign;
	gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
	update_stmt(assign);

	// 4. ...write latent_entropy
	assign = gimple_build_assign(latent_entropy_decl, temp);
	gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
	update_stmt(assign);
}
int		is_valid_mnemonic(char *mnemonic)
{
  op_t		op;

  op = get_op(mnemonic);
  return (op.mnemonique != 0);
}
Exemple #9
0
int kvmppc_core_emulate_op_44x(struct kvm_run *run, struct kvm_vcpu *vcpu,
			       unsigned int inst, int *advance)
{
	int emulated = EMULATE_DONE;
	int dcrn = get_dcrn(inst);
	int ra = get_ra(inst);
	int rb = get_rb(inst);
	int rc = get_rc(inst);
	int rs = get_rs(inst);
	int rt = get_rt(inst);
	int ws = get_ws(inst);

	switch (get_op(inst)) {
	case 31:
		switch (get_xop(inst)) {

		case XOP_MFDCR:
			emulated = emulate_mfdcr(vcpu, rt, dcrn);
			break;

		case XOP_MFDCRX:
			emulated = emulate_mfdcr(vcpu, rt,
					kvmppc_get_gpr(vcpu, ra));
			break;

		case XOP_MTDCR:
			emulated = emulate_mtdcr(vcpu, rs, dcrn);
			break;

		case XOP_MTDCRX:
			emulated = emulate_mtdcr(vcpu, rs,
					kvmppc_get_gpr(vcpu, ra));
			break;

		case XOP_TLBWE:
			emulated = kvmppc_44x_emul_tlbwe(vcpu, ra, rs, ws);
			break;

		case XOP_TLBSX:
			emulated = kvmppc_44x_emul_tlbsx(vcpu, rt, ra, rb, rc);
			break;

		case XOP_ICCCI:
			break;

		default:
			emulated = EMULATE_FAIL;
		}

		break;

	default:
		emulated = EMULATE_FAIL;
	}

	if (emulated == EMULATE_FAIL)
		emulated = kvmppc_booke_emulate_op(run, vcpu, inst, advance);

	return emulated;
}
// send a message to a module within another service asynchronously
Boolean ModuleController::ModuleSendAsync(const pegasus_module & handle,
					  Uint32 msg_handle,
					  Uint32 destination_q,
					  const String & destination_module,
					  AsyncRequest *message,
					  void *callback_parm)
{

   if ( false == verify_handle(const_cast<pegasus_module *>(&handle)))
      throw(Permission(pegasus_thread_self()));

   AsyncOpNode *op = get_op();
   AsyncModuleOperationStart *request =
      new AsyncModuleOperationStart(msg_handle,
				    op,
				    destination_q,
				    getQueueId(),
				    true,
				    destination_module,
				    message);
   request->dest = destination_q;
   callback_handle *cb = new callback_handle(const_cast<pegasus_module *>(&handle), callback_parm);
   return SendAsync(op,
		    destination_q,
		    _async_handleEnqueue,
		    this,
		    cb);
}
Boolean MessageQueueService::SendForget(Message *msg)
{
   AsyncOpNode *op = 0;
   Uint32 mask = msg->getMask();

   if (mask & message_mask::ha_async)
   {
      op = (static_cast<AsyncMessage *>(msg))->op ;
   }

   if (op == 0)
   {
      op = get_op();
      op->_request.insert_first(msg);
      if (mask & message_mask::ha_async)
      {
         (static_cast<AsyncMessage *>(msg))->op = op;
      }
   }
   op->_op_dest = MessageQueue::lookup(msg->dest);
   op->_flags |= ASYNC_OPFLAGS_FIRE_AND_FORGET;
   op->_flags &= ~(ASYNC_OPFLAGS_CALLBACK | ASYNC_OPFLAGS_SAFE_CALLBACK
       | ASYNC_OPFLAGS_SIMPLE_STATUS);
   op->_state &= ~ASYNC_OPSTATE_COMPLETE;
   if (op->_op_dest == 0)
   {
      op->release();
      return_op(op);
      return false;
   }

   // now see if the meta dispatcher will take it
   return  _meta_dispatcher->route_async(op);
}
Exemple #12
0
static inline void collect_regs(
        unsigned long *regs,
        instr_t *instr,
        int (*num_ops)(instr_t *),
        opnd_t (*get_op)(instr_t *, uint)
) {
    int i;
    opnd_t opnd;

    // make sure these regs are always seen as "used"
    *regs |= (1 << DR_REG_NULL);

    for(i=0; i < num_ops(instr); i++) {
        opnd = get_op(instr, i);
        if(opnd_is_reg(opnd)) {
            collect_reg(regs, opnd_get_reg(opnd));
        } else if(opnd_is_base_disp(opnd)) {
            collect_reg(regs, opnd_get_base(opnd));
            collect_reg(regs, opnd_get_index(opnd));
        }
    }

    collect_reg(regs, DR_REG_RSP);
    collect_reg(regs, DR_REG_RBP);
    collect_reg(regs, DR_REG_RAX);
    collect_reg(regs, DR_REG_RDX);
}
Exemple #13
0
void FE_stage()
{
  /* only part of FE_stage function is implemented */ 
  /* please complete the rest of FE_stage function */ 

  if(stop_fetching)
  	return;

  if(FE_latch->op_valid || FE_latch->pipeline_stall_enabled)
  {
	  /* Data inside the latch is valid and next stage is still using it.
	     Or ID stage has enabled pipeline stalling because of a branch instruction.
	     Do not fetch */
	  return;
  }

  Op *op = get_free_op();
  bool next_op_exists = get_op(op);
  if(!next_op_exists)			/* Indicate the end_of_trace by the FE cycle */
  {
	free_op(op);
	op = get_free_op();
	op->is_last_instruction = true;
	stop_fetching = true;
  }

  /* hwsim : get the instruction and pass to ID phase */
  FE_latch->op = op;				/* pass the op to ID stage */
  FE_latch->op_valid = true;			/* Mark it as valid */
  FE_latch->pipeline_stall_enabled = false;	/* Disable pipeline stall, if any */

  //   next_pc = pc + op->inst_size;  // you need this code for building a branch predictor 

}
Exemple #14
0
std:: string POETTop:: toString(ASTOutputEnum config)
    {
      switch (get_op()) {
      case POET_OP_IFELSE: 
         return "("+arg1->toString(config) + ")?(" + arg2->toString(config) + "):(" + arg3->toString(config)+")";
      default: return POETOperator::toString(config);
      }
    }
Exemple #15
0
static cell_type_e parsearg(char *arg)
{
    if (arg == NULL)
        return BAD_CELL;

    int is_double = 0, has_period = 0, has_negative = 0;
    int is_hard_string = 0, is_soft_string = 0;
    char *beg_arg = arg;

    while (*arg != '\0') {
        if (*arg >= '0' && *arg <= '9') {
            is_double++;
        } else if (*arg == '-') {
            is_double++;
            has_negative++;
        } else if (*arg == '.') {
            is_double++;
            has_period++;
        } else if (*arg == '"') {
            is_hard_string++;
        } else {
            is_soft_string++;
        }
        arg++;
    }
    arg = beg_arg;

    if (is_hard_string) {
        if (is_hard_string == 2 && *(--arg) == '"')
            return QUOTED_STRING;
        else
            return STRING;
    } else if (is_soft_string) {
        if (has_period > 1 || has_negative > 1)
            return STRING;

        if (valid_cell_id(arg) == 0)
            return CELL_ID;

        if (get_op(arg) != NULL)
            return FUNCTION;

        return STRING;
    } else if (is_double) {
        if (has_period > 1 || has_negative > 1)
            return STRING;

        if ((has_period && is_double == 1) || (has_period && has_negative && is_double == 2))
            return STRING;

        if (has_negative && is_double == 1)
            return FUNCTION;

        return DOUBLE;
    } else {
        return BAD_CELL;
    }
}
/*--- dissect_qsig_arg ------------------------------------------------------*/
static int
dissect_qsig_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
  int offset = 0;
  rose_ctx_t *rctx;
  gint32 opcode = 0, service;
  const qsig_op_t *op_ptr;
  const gchar *p;
  proto_item *ti, *ti_tmp;
  proto_tree *qsig_tree;

  /* Reject the packet if data is NULL */
  if (data == NULL)
    return 0;
  rctx = get_rose_ctx(data);
  DISSECTOR_ASSERT(rctx);

  if (rctx->d.pdu != 1)  /* invoke */
    return offset;
  if (rctx->d.code == 0) {  /* local */
    opcode = rctx->d.code_local;
    op_ptr = get_op(opcode);
  } else if (rctx->d.code == 1) {  /* global */
    op_ptr = (qsig_op_t *)g_hash_table_lookup(qsig_oid2op_hashtable, rctx->d.code_global);
    if (op_ptr) opcode = op_ptr->opcode;
  } else {
    return offset;
  }
  if (!op_ptr)
    return offset;
  service = get_service(opcode);

  ti = proto_tree_add_item(tree, proto_qsig, tvb, offset, tvb_captured_length(tvb), ENC_NA);
  qsig_tree = proto_item_add_subtree(ti, ett_qsig);

  proto_tree_add_uint(qsig_tree, hf_qsig_operation, tvb, 0, 0, opcode);
  p = try_val_to_str(opcode, VALS(qsig_str_operation));
  if (p) {
    proto_item_append_text(ti, ": %s", p);
    proto_item_append_text(rctx->d.code_item, " - %s", p);
    if (rctx->apdu_depth >= 0)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rctx->apdu_depth), " %s", p);
  }

  ti_tmp = proto_tree_add_uint(qsig_tree, hf_qsig_service, tvb, 0, 0, service);
  p = try_val_to_str(service, VALS(qsig_str_service_name));
  if (p) proto_item_append_text(ti_tmp, " - %s", p);

  if (op_ptr->arg_pdu)
    offset = op_ptr->arg_pdu(tvb, pinfo, qsig_tree, NULL);
  else
    if (tvb_reported_length_remaining(tvb, offset) > 0) {
      proto_tree_add_expert(tree, pinfo, &ei_qsig_unsupported_error_type, tvb, offset, -1);
      offset += tvb_captured_length_remaining(tvb, offset);
    }

  return offset;
}
Exemple #17
0
//==========================================================================================================
//==========================================================================================================
Production::Production(vector<Symbol> _symbols, string _action_name): symbols(_symbols), action_name(_action_name) {
    // Find the last symbol that is an operator
    auto iter = find_if(symbols.rbegin(), symbols.rend(), [](Symbol sym){ return is_op(sym); });
    
    if(iter != symbols.rend())
        op = get_op(*iter);
    else
        op = nullptr;
}
Exemple #18
0
//if和while的检测
void cmp_inst(char op[],char fuc1[],char fuc2[],char op1[],char op2[],int &i)
{
	char temp[expr_size];
	char v1[expr_size],v2[expr_size];
	int t1=0,t2=0,reg2=0,reg1=0;//flag用于指示是否为常数

	if(get_op(fuc1,v1,reg1)==2)
		get_expr(reg1,v1);
	if(get_op(fuc2,v2,reg2)==2)
		get_expr(reg2,v2);//获取判断语言的两个变量,或者是常数。如果是变量需要加到变量表中。
			
	sscanf(inst[i+1],"%s %s %s",op,fuc1,fuc2);
	int jump=0;
	sscanf(fuc2,"[%d]",&jump);
	bool flag_while=judge_while(i,jump);//判断是否可能为while循环

	if(strcmp(op,"blbc")==0)//正常的等于
	{
		if(flag_while)
			sprintf(temp,"while(%s%s%s) \n",v1,op1,v2);
		else
			sprintf(temp,"if(%s%s%s) \n",v1,op1,v2);
	}
	else if(strcmp(op,"blbs")==0)//等于的相反情况
	{
		if(flag_while)
			sprintf(temp,"while(%s%s%s) \n",v1,op2,v2);
		else
			sprintf(temp,"if(%s%s%s) \n",v1,op2,v2);
	}
	else
	{
		fprintf(fw,"cmpeq is wrong struct! \n");
	}
			
	extra[jump]++;//跳转的目的指令需要补全  }

	i++;//增加一条指令
	add_tab();//添加tab键
	fprintf(fw,"%s",temp);//放入缓存区
	add_tab();
	fprintf(fw,"{\n");
	num_big++;//{的个数增加一个
}
void FE_stage()
{
  /* only part of FE_stage function is implemented */ 
  /* please complete the rest of FE_stage function */ 
	
	
	if(FE_latch->stage_stall==false)	//check if no pipeline stalled
	{
		Op* new_op = get_free_op();	//get a placeholder op out of the pool
		if(get_op(new_op))		//copy op from trace into the placeholder op
		{
			if((new_op->opcode>=OP_FMEM)&&(new_op->opcode<=OP_FCMO)){
				float_count++;
			}
			if((new_op->opcode>=OP_IADD)&&(new_op->opcode<=OP_MM)){
				integer_count++;
			}
			if((new_op->opcode>=OP_CF)&&(new_op->opcode<=OP_LDA)){
				if(new_op->opcode==OP_CF) branch_count++;				
				integer_count++;
			}
			if((new_op->opcode>=OP_LDA)&&(new_op->opcode<=OP_LD)){
				load_count++;
			}
			if((new_op->opcode==OP_MM)||(new_op->opcode==OP_IMUL)){
				multiple_count++;
			}

			if(new_op->opcode==OP_ST){
				store_count++;
			}			
			if((new_op->opcode == OP_CF) && new_op->cf_type==CF_CBR && use_bpred==true)
			{
				uint64_t pc = new_op->instruction_addr;
				bool predicted_dir=0;		
				predicted_dir=bpred_access(branchpred,pc);
				bpred_update(branchpred,pc,predicted_dir,new_op->actually_taken);
				if(new_op->actually_taken != predicted_dir)
				{
					new_op->mispredicted_branch=true;
				}
				bpred_mispred_count=branchpred->mispred;
				bpred_okpred_count=branchpred->okpred;
			}

			FE_latch->op=new_op;
			FE_latch->op_valid=true;
		}
		else
			free_op(new_op);
	}
	
  //   next_pc = pc + op->inst_size;  // you need this code for building a branch predictor 

}
/*--- dissect_qsig_arg ------------------------------------------------------*/
static int
dissect_qsig_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
  int offset;
  rose_ctx_t *rctx;
  gint32 opcode = 0, service;
  const qsig_op_t *op_ptr;
  const gchar *p;
  proto_item *ti, *ti_tmp;
  proto_tree *qsig_tree;

  offset = 0;
  rctx = get_rose_ctx(pinfo->private_data);
  DISSECTOR_ASSERT(rctx);
  if (rctx->d.pdu != 1)  /* invoke */
    return offset;
  if (rctx->d.code == 0) {  /* local */
    opcode = rctx->d.code_local;
    op_ptr = get_op(opcode);
  } else if (rctx->d.code == 1) {  /* global */
    op_ptr = g_hash_table_lookup(qsig_oid2op_hashtable, rctx->d.code_global);
    if (op_ptr) opcode = op_ptr->opcode;
  } else {
    return offset;
  }
  if (!op_ptr)
    return offset;
  service = get_service(opcode);

  ti = proto_tree_add_item(tree, proto_qsig, tvb, offset, tvb_length(tvb), ENC_NA);
  qsig_tree = proto_item_add_subtree(ti, ett_qsig);

  proto_tree_add_uint(qsig_tree, hf_qsig_operation, tvb, 0, 0, opcode);
  p = match_strval(opcode, VALS(qsig_str_operation));
  if (p) {
    proto_item_append_text(ti, ": %s", p);
    proto_item_append_text(rctx->d.code_item, " - %s", p);
    if (rctx->apdu_depth >= 0)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rctx->apdu_depth), " %s", p);
  }

  ti_tmp = proto_tree_add_uint(qsig_tree, hf_qsig_service, tvb, 0, 0, service);
  p = match_strval(service, VALS(qsig_str_service_name));
  if (p) proto_item_append_text(ti_tmp, " - %s", p);

  if (op_ptr->arg_pdu)
    offset = op_ptr->arg_pdu(tvb, pinfo, qsig_tree);
  else
    if (tvb_length_remaining(tvb, offset) > 0) {
      proto_tree_add_text(qsig_tree, tvb, offset, -1, "UNSUPPORTED ARGUMENT TYPE (QSIG)");
      offset += tvb_length_remaining(tvb, offset);
    }

  return offset;
}
QString Analitza::str(QDomNode n){
	QDomNode j,k=n;
	QDomElement e;
	QString operador;
	QValueList<QString> nombres;
	unsigned int fills = 0;
	while( !n.isNull() ) {
		e = n.toElement();
		if(e.tagName() == "apply" || e.tagName() == ""){
			j = e.firstChild();
			//No fa falta que tinguem tot entre parentesi
// 			cout << "hola :)" << endl;
// 			cout << toOpId(k) << "<->" << toOpId(j) << endl;
			if(toOpId(k) <= toOpId(j) || isOperador(get_op(j)) == 1)
				nombres.append(str(j));
			else
				nombres.append("(" + str(j) + ")");
		} else if (e.tagName() == "cn" ||e.tagName() == "ci") {
			nombres.append("<mn>" + e.text() + "</mn>");
		} else if(isNum(e.tagName())){
			nombres.append("<mn>" + e.tagName() + "</mn>");
		} else if (isOperador(e.tagName())) {
			operador = e.tagName();
		} else if (e.tagName()=="declare") {
			j = e.firstChild(); //Segons l'estandar, es <ci>
			nombres.append(j.toElement().text());
			j = j.nextSibling(); //Valor a guardar
			nombres.append(j.toElement().text());
			operador = "declare";
			fills=3;
			
		}
		fills++;
		n= n.nextSibling();
	}
	QString r="";
	QValueList<QString>::iterator it;
	
	it = nombres.begin();
	
	r = *it;
	if(fills>2)
		it++;
	
	cout << QString::QString("aaaa--------->%1 %2\n").arg(operador).arg(fills).ascii() << endl;
	
	for(; it != nombres.end(); ++it){
		cout << (*it).ascii() << endl;
		r = escriu(r,*it,operador, fills<=2?1:0);
	}
	
// 	cout << "hola" << endl;
	return r;
}
Exemple #22
0
static int eval_function(operator_t *op, stack_t **values, char *val_str, size_t size)
{
    if (op == NULL || val_str == NULL || size <= 2)
        return -1;

    double val = 0.0;
    char *arg;
    char *op_name = (char *) op->name;
    size_t i, num_args = 0;
    int is_bad_formula = 0;
    operator_t *nested_op;

    stack_t *args = NULL;
    if (is_arg_arithmetic(op_name)) {
        num_args = 2;
    } else {
        char *arg_count = pop_copy(values);
        if (arg_count == NULL)
            goto error;

        num_args = strtol(arg_count, NULL, 10);
        free(arg_count);
    }

    for (i = 0; i < num_args; i++) {
        arg = pop_copy(values);
        //printf("arg[%d]==%s\n", i, arg);
        if (parsearg(arg) == FUNCTION) {
            nested_op = get_op(arg);
            free(arg);
            if (eval_function(nested_op, values, val_str, size) == 0)
                push_copy(&args, val_str, size);
            else
                goto error;

        } else if (push(&args, arg) != 0) {
            goto error;
        }
    }

    val = op->function(&args, &is_bad_formula);
    if (is_bad_formula)
        goto error;

    if (ftoa(val, val_str, size) == NULL)
        goto error;

    return 0;

error:
    clear_stack(&args);
    return -1;
}
Exemple #23
0
int		eval_expr_deep(char *str)
{
	int	*tab_nbr;
	int	*tab_op;
	int	count[2];
	int	total;

	tab_nbr = get_nbr(str, count);
	tab_op = get_op(str, count);
	total = get_total(tab_nbr, tab_op, count);
	return (total);
}
Exemple #24
0
std:: string POETQop:: toString(ASTOutputEnum config)
    {
      switch (get_op()) {
      case POET_OP_FOR:
         return "for ("+arg1->toString(config) + ";" + arg2->toString(config) + ";" + arg3->toString(config)+")"
               + "{" + arg4->toString(config) + "}";
      case POET_OP_FOREACH: case POET_OP_FOREACHR:
         return "foreach ("+arg1->toString(config) + ":" + arg2->toString(config) + ":" + arg3->toString(config)+")"
               + "{" + arg4->toString(config) + "}";
      default: return POETOperator::toString(config);
      }
    }
Exemple #25
0
int judge_expr1(int n,char name[],int &value)
{
	int i=0;
	char op[100],fuc1[100],fuc2[100];
	sscanf(inst_temp[n],"%s %s %s",op,fuc1,fuc2);
	int reg=0;
	if(strcmp(op,"move")==0)
	{
		int t=get_op(fuc1,fuc1,reg);
		strcpy(name,fuc2);
		if(t==1)
		{
			sscanf(fuc1,"%d",&value);
			return 1;
		}
		else
			return 2;
	}
	else if(strcmp(op,"store")==0)
	{
		int t=get_op(fuc1,fuc1,reg);
		char temp[100];
		sscanf(inst_temp[n-1],"%s %s %s",op,temp,fuc2);
		if(strcmp(fuc2,"GP")==0&&strcmp(op,"add")==0)
			strcpy(name,temp);
		else
			return 0;//useless
		if(t==1)
		{
			sscanf(fuc1,"%d",&value);
			return 1;//constant
		}
		else
			return 2;//not constant
	}
	return 0;
}
/*--- dissect_isdn_sup_arg ------------------------------------------------------*/
static int
dissect_isdn_sup_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
  int offset = 0;
  rose_ctx_t *rctx;
  gint32 opcode = 0;
  const gchar *p;
  const isdn_sup_op_t *op_ptr;
  proto_item *ti;
  proto_tree *isdn_sup_tree;

  /* Reject the packet if data is NULL */
  if (data == NULL)
    return 0;
  rctx = get_rose_ctx(data);
  DISSECTOR_ASSERT(rctx);

  if (rctx->d.pdu != 1)  /* invoke */
    return offset;
  if (rctx->d.code == 0) {  /* local */
    opcode = rctx->d.code_local;
  } else {
    return offset;
  }
  op_ptr = get_op(opcode);
  if (!op_ptr)
    return offset;

  ti = proto_tree_add_item(tree, proto_isdn_sup, tvb, offset, -1, ENC_NA);
  isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup);

  proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_operation, tvb, 0, 0, opcode);
  p = try_val_to_str(opcode, VALS(isdn_sup_str_operation));
  if (p) {
    proto_item_append_text(ti, ": %s", p);
    proto_item_append_text(rctx->d.code_item, " - %s", p);
    if (rctx->apdu_depth >= 0)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rctx->apdu_depth), " %s", p);
  }

  if (op_ptr->arg_pdu)
    offset = op_ptr->arg_pdu(tvb, pinfo, isdn_sup_tree, NULL);
  else
    if (tvb_reported_length_remaining(tvb, offset) > 0) {
      proto_tree_add_expert(tree, pinfo, &ei_isdn_sup_unsupported_error_type, tvb, offset, -1);
      offset += tvb_reported_length_remaining(tvb, offset);
    }

  return offset;
}
static void perturb_local_entropy(basic_block bb, tree local_entropy)
{
	gimple_stmt_iterator gsi;
	gimple assign;
	tree addxorrol, rhs;
	enum tree_code op;

	op = get_op(&rhs);
	addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
	assign = gimple_build_assign(local_entropy, addxorrol);
	gsi = gsi_after_labels(bb);
	gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
	update_stmt(assign);
//debug_bb(bb);
}
Boolean ModuleController::_send_forget(Uint32 destination_q,
				       const String & destination_module,
				       AsyncRequest *message)
{
   AsyncOpNode *op = get_op();
   message->dest = destination_q;
   AsyncModuleOperationStart *request =
      new AsyncModuleOperationStart(0,
				    op,
				    destination_q,
				    getQueueId(),
				    true,
				    destination_module,
				    message);
   return SendForget(request);
}
Exemple #29
0
/* Eval the args given to -test and computes the function, unused */
ast_st* eval_args(int argc, const char ** argv, int par, int * index) {

  ast_st *tmp1, *tmp2;
  kind_en op = Nothing;
  int i;

  for (i = 0; i < argc; i++) {

    if (!strcmp(argv[i],"(")) {

      tmp2 = eval_args(argc-i, argv+i+1, 1, index);
      if (tmp2 == NULL) return NULL;
      i += *index;
    }
    else if (!strcmp(argv[i], ")"))
      if (par) {
        *index = i+1;
        return tmp1;
      }
      else {
        printf("Closing parenthesis unmatched\n");
        return NULL;
      }

    else if (is_op(argv[i])) { 
      op = get_op(argv[i]);
    }

    else {
      int val = !strcmp(argv[i], "") ? 0 : atoi(argv[i]);
      tmp2 = create_int(val);
      
      if (op != Nothing) {
        tmp1 = create_node(op, tmp1, tmp2);
        op = Nothing;
      } else tmp1 = tmp2;
    }
  }

  if (!par)
    return tmp1;
  else {
    printf("Opening parenthesis unmatched\n");
    return NULL;
  }
}
Exemple #30
0
void				do_sub(t_dtab *token)
{
	unsigned int	i;
	t_tok			tmp;

	i = 0;
	get_op(&tmp);
	while (TDATA[++i].type != TOK_EOF && i < token->size)
	{
		if (TDATA[i].type == TOK_OP && TDATA[i].val == -1.0)
		{
			TDATA[i + 1].val *= -1;
			dtab_remove(token, i);
			dtab_insert(token, i, &tmp);
		}
	}
}