示例#1
0
Parser::Parser(int ac, char **tab, std::string const &usage, bool n) : m_arg(tab),
								       m_usage(usage),
								       m_name(getArgument("-n", n)),
								       m_port(getArgument("-p", true)),
								       m_host(getArgument("-h", false)){
  try {
    for (int i = 1;i < ac ;++i){
      if (this->m_arg[i] && this->m_arg[i - 1] && this->m_arg[i][0] == '-' &&
	  std::string(this->m_arg[i - 1]) != "-n" && !checkTab(std::string(this->m_arg[i])))
	throw ErrorClient(this->m_usage, "Parser");
    }
    if (this->m_arg[ac - 1] && std::string(this->m_arg[ac - 1]) == "-d")
      std::cout << "Name : " << this->m_name
		<< std::endl
		<< "Port : " << this->m_port
		<< std::endl
		<< "Host : " << this->m_host
		<< std::endl;
  } catch (ErrorClient const &e) {
    throw ErrorClient(e.what(), "Parser");
  }
}
示例#2
0
/*******************************************************************
* Function:	ArrayIndexAnalysis::computeOutSet
* Purpose : a helper function to compute the out set an expression
* Initial : Nurudeen A. Lameed on July 21, 2009
********************************************************************
Revisions and bug fixes:
*/
void ArrayIndexAnalysis::computeOutSet(const Expression* expr, FlowSet& out)
{
    // what kind of expression?
    switch (expr->getExprType())
    {
    case Expression::PARAM:
    {
        // Convert it to a parameter type
        const ParamExpr* paramExpr = dynamic_cast<const ParamExpr*>(expr);

        // array/matrix symbol
        SymbolExpr* symbol = paramExpr->getSymExpr();
        const Expression::ExprVector& args = paramExpr->getArguments();

        // build a table of checks for the indices
        std::vector< std::bitset<2> > checkTab(args.size());

        TypeInfo::DimVector bounds(args.size(), 0);

        ArrayBoundsMap::const_iterator it  = arrayBoundsMap.find(symbol);
        if ( it != arrayBoundsMap.end() )	// already defined, get it
        {
            bounds = it->second;	// get the bounds
        }

        // insert the indexes
        for (size_t j = 0, size = args.size(); j < size; ++j)
        {
            // checks for the current index
            // bit 0 represents lower check while bit 1 represents upper check
            std::bitset<2> checks;

            // if it is a const, check against the bounds table,  1 >= index <= its dimension bound
            // remove all checks for the current index
            // if the index is greater than the bound from the table, update the
            // bound for the dimension with this index value ...

            // form an <index, dimension> pair
            IndexKey iKey = {args[j], j};

            bool mustCheck = false;		// are checks necessary for this access?

            // remove check for lower bound
            if ( out.erase( FlowFact(symbol, iKey, FlowFact::LOWER_BOUND)) > 0 )
            {
                checks.set(0);			// a mandatory check
                mustCheck = true;		// a mandatory check must be performed for this access
            }

            // remove check for upper bound
            if ( out.erase( FlowFact(symbol, iKey, FlowFact::UPPER_BOUND)) > 0 )
            {
                checks.set(1);			// a mandatory check
                mustCheck = true;		// a mandatory check must be performed for this access
            }

            // generate others ...
            if (  mustCheck && args[j]->getExprType() == Expression::INT_CONST )
            {
                size_t subscript = (dynamic_cast<const IntConstExpr*>(args[j]))->getValue();

                // replace the bound for the array dimension for the subscript with the subscript
                bounds[j] = subscript;   // must be greater than the current value

                // update flow set
                updateFlowSet(symbol, bounds, out);
            }

            // insert the table
            checkTab[j] = checks;

            // update the table
            arrayBoundsMap[symbol] = bounds;
        }

        // insert a table of checks for the indices of this array access
        factTable[paramExpr] = checkTab;
    }
    break;

    case Expression::BINARY_OP:
    {
        // convert to binary operator type
        const BinaryOpExpr* bOpExpr = dynamic_cast<const BinaryOpExpr*>(expr);

        // analyse right expr first
        computeOutSet(bOpExpr->getRightExpr(), out);

        // analyse left expr
        computeOutSet(bOpExpr->getLeftExpr(), out);
    }
    break;

    case Expression::UNARY_OP:
    {
        const UnaryOpExpr* uOpExpr = dynamic_cast<const UnaryOpExpr*>(expr);

        // analyse the operand
        computeOutSet(uOpExpr->getOperand(), out);
    }
    break;

    default:	// do nothing
    {
    }
    }
}
示例#3
0
bool vpDot::connexe(const vpImage<unsigned char>& I,unsigned int u,unsigned int v,
	       double &mean_value, double &u_cog, double &v_cog, double &n)
{
  std::vector<bool> checkTab(I.getWidth()*I.getHeight(),false);
  return connexe(I,u,v,mean_value,u_cog,v_cog,n,checkTab);
}