Esempio n. 1
0
  //-----------------------------------------------------------
  void OprtShr::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int num)
  {
	  assert(num==2);

	  if (!a_pArg[0]->IsScalar())
		  throw ParserError(ErrorContext(ecTYPE_CONFLICT_FUN, GetExprPos(), GetIdent(), a_pArg[0]->GetType(), 'i', 1));

	  if (!a_pArg[1]->IsScalar())
		  throw ParserError(ErrorContext(ecTYPE_CONFLICT_FUN, GetExprPos(), GetIdent(), a_pArg[1]->GetType(), 'i', 2));

	  float_type a = a_pArg[0]->GetFloat(),
		  b = a_pArg[1]->GetFloat();

	  if (a!=(int_type)a)
		  throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, GetExprPos(), a_pArg[0]->GetIdent(), a_pArg[0]->GetType(), 'i', 1) ); 

	  if (b!=(int_type)b)
		  throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, GetExprPos(), a_pArg[1]->GetIdent(), a_pArg[1]->GetType(), 'i', 2) ); 

	  float_type result = a*std::pow(2, -b);
	  int numDigits = std::numeric_limits<float_type>::digits10;

	  if (std::fabs(result) >= std::fabs(std::pow(10.0, numDigits)))
		  throw ParserError(ErrorContext(ecOVERFLOW, GetExprPos(), GetIdent()));

	  if (result>0)
		  *ret = std::floor(result);
	  else
		  *ret = std::ceil(result);
  }
Esempio n. 2
0
void CStatement::Action(const CDbapiEvent& e)
{
    _TRACE(GetIdent() << " " << (void*)this << ": '" << e.GetName()
           << "' received from " << e.GetSource()->GetIdent());

    CResultSet *rs;

    if (dynamic_cast<const CDbapiFetchCompletedEvent*>(&e) != 0 ) {
        if( m_irs != 0 && (rs = dynamic_cast<CResultSet*>(e.GetSource())) != 0 ) {
            if( rs == m_irs ) {
                m_rowCount = rs->GetTotalRows();
                _TRACE("Rowcount from the last resultset: " << m_rowCount);
            }
        }
    }

    if (dynamic_cast<const CDbapiDeletedEvent*>(&e) != 0 ) {
        RemoveListener(e.GetSource());
        if(dynamic_cast<CConnection*>(e.GetSource()) != 0 ) {
            _TRACE("Deleting " << GetIdent() << " " << (void*)this);
            delete this;
        }
        else if( m_irs != 0 && (rs = dynamic_cast<CResultSet*>(e.GetSource())) != 0 ) {
            if( rs == m_irs ) {
                _TRACE("Clearing cached CResultSet " << (void*)m_irs);
                m_irs = 0;
            }
        }
    }
}
Esempio n. 3
0
  //-----------------------------------------------------------------------------------------------
  void OprtSubCmplx::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int num)
  { 
    assert(num==2);
    
    const IValue *arg1 = a_pArg[0].Get();
    const IValue *arg2 = a_pArg[1].Get();
    if ( a_pArg[0]->IsNonComplexScalar() && a_pArg[1]->IsNonComplexScalar())
    {
      *ret = arg1->GetFloat() - arg2->GetFloat(); 
    }
    else if (a_pArg[0]->GetType()=='m' && a_pArg[1]->GetType()=='m')
    {
      // Matrix + Matrix
      *ret = arg1->GetArray() - arg2->GetArray();
    }
    else
    {
      if (!a_pArg[0]->IsScalar())
        throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, GetExprPos(), GetIdent(), a_pArg[0]->GetType(), 'c', 1)); 

      if (!a_pArg[1]->IsScalar())
        throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, GetExprPos(), GetIdent(), a_pArg[1]->GetType(), 'c', 2)); 
      
      *ret = cmplx_type(a_pArg[0]->GetFloat() - a_pArg[1]->GetFloat(),
                        a_pArg[0]->GetImag() - a_pArg[1]->GetImag()); 
    }
  }
Esempio n. 4
0
void CResultSet::Action(const CDbapiEvent& e)
{
    _TRACE(GetIdent() << " " << (void*)this
              << ": '" << e.GetName()
              << "' received from " << e.GetSource()->GetIdent());

    if(dynamic_cast<const CDbapiClosedEvent*>(&e) != 0 ) {
        if( dynamic_cast<CStatement*>(e.GetSource()) != 0
            || dynamic_cast<CCallableStatement*>(e.GetSource()) != 0 ) {
            if( m_rs != 0 ) {
                _TRACE("Discarding old CDB_Result " << (void*)m_rs);
                Invalidate();
            }
        }
    }
    else if(dynamic_cast<const CDbapiDeletedEvent*>(&e) != 0 ) {

        RemoveListener(e.GetSource());

        if(dynamic_cast<CStatement*>(e.GetSource()) != 0
           || dynamic_cast<CCursor*>(e.GetSource()) != 0
           || dynamic_cast<CCallableStatement*>(e.GetSource()) != 0 ) {
            _TRACE("Deleting " << GetIdent() << " " << (void*)this);
            delete this;
        }
    }
}
Esempio n. 5
0
  /** \brief Return the value as an integer. 
    
    This function should only be called if you really need an integer value and
    want to make sure your either get one or throw an exception if the value
    can not be implicitely converted into an integer.
  */
  int_type Value::GetInteger() const
  {
    float_type v = m_val.real();

    if (m_cType!='i') //!IsScalar() || (int_type)v-v!=0)
    {
      ErrorContext err;
      err.Errc  = ecTYPE_CONFLICT;
      err.Type1 = m_cType;
      err.Type2 = 'i';
      
      if (GetIdent().length())
      {
        err.Ident = GetIdent();
      }
      else
      {
        stringstream_type ss;
        ss << *this;
        err.Ident = ss.str();
      }

      throw ParserError(err);
    }

    return (int_type)v;
  }
Esempio n. 6
0
  /** \brief Get the imaginary part of the value. 
      \throw ParserError in case this value represents a string or a matrix
  */
  float_type Value::GetImag() const
  {
    if (!IsScalar())
    {
      ErrorContext err;
      err.Errc  = ecTYPE_CONFLICT;
      err.Type1 = m_cType;
      err.Type2 = 'c';
      
      if (GetIdent().length())
      {
        err.Ident = GetIdent();
      }
      else
      {
        stringstream_type ss;
        ss << *this;
        err.Ident = ss.str();
      }

      throw ParserError(err);
    }

    return m_val.imag();
  }
Esempio n. 7
0
  /** \brief Index operator implementation
      \param ret A reference to the return value
      \param a_pArg Pointer to an array with the indices as ptr_val_type
      \param a_iArgc Number of indices (=dimension) actully used in the expression found. This must 
             be 1 or 2 since three dimensional data structures are not supported by muParserX.
  */
  void OprtIndex::At(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
  {
    try
    {
      // The index is -1, thats the actual variable reference
      if (a_iArgc!=a_pArg[-1]->GetDim())
      {
        throw ParserError(ErrorContext(ecINDEX_DIMENSION, -1, GetIdent()));
      }

      switch(a_iArgc)
      {
      case 1:
          ret.Reset(new Variable( &(ret->At(*a_pArg[0], Value(0))) ) );
          break;

      case 2:
          ret.Reset(new Variable( &(ret->At(*a_pArg[0], *a_pArg[1])) ) );
          break;

      default:
          throw ParserError(ErrorContext(ecINDEX_DIMENSION, -1, GetIdent()));
      }
    }
    catch(ParserError &exc)
    {
      exc.GetContext().Pos = GetExprPos();
      throw exc;
    }
  }
Esempio n. 8
0
static SymPtr LookupIdent(char **name)
{
	SymPtr sym=NULL,parent;
	
    /* check this class only */
	if( in_class && Token==tSELF )
	{
		SkipToken(tSELF);
		SkipToken(tPERIOD);
		*name = GetIdent();
		sym = SymFindLevel(*name,(SymGetScope()-1));
	}
    /* check super class only */
	else if( in_class && Token==tSUPER && base_class->super!=NULL )
	{
	    SkipToken(tSUPER);
	    SkipToken(tPERIOD);
	    *name = GetIdent();
	    sym = SymFindLocal(*name,base_class->super);
        
	    if( sym!=NULL && sym->flags&SYM_PRIVATE )
	    {
		    compileError("attempt to access private field '%s'",*name);
		    NextToken();
		    return COMPILE_ERROR;
	    }
	}
	/* check all super classes */
    else if( in_class )
	{
        *name = GetIdent();
        parent=base_class->super;
        while(parent!=NULL)
        {
            sym = SymFindLocal(*name,parent);
            if(sym!=NULL) break;
            parent=parent->super;
        }
	   	if( sym!=NULL && sym->flags&SYM_PRIVATE )
	    {
		    compileError("attempt to access private field '%s'",*name);
		    NextToken();
		    return COMPILE_ERROR;
	    }
	}
    
    /* check globals */
    if( sym==NULL )
	{
		*name = GetIdent();
		sym = SymFind(*name);
	}
    
	return sym;
}
Esempio n. 9
0
  /** \brief Implements the Division operator. 
      \throw ParserError in case one of the arguments if 
             nonnumeric or an array.
  
  */
  void OprtDiv::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int num)
  { 
    assert(num==2);

    if (!a_pArg[0]->IsNonComplexScalar())
      throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, -1, GetIdent(), a_pArg[0]->GetType(), 'f', 1)); 

    if (!a_pArg[1]->IsNonComplexScalar())
      throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, -1, GetIdent(), a_pArg[1]->GetType(), 'f', 2)); 
    
    *ret = a_pArg[0]->GetFloat() / a_pArg[1]->GetFloat();
  }
Esempio n. 10
0
void CDBAPIBulkInsert::Action(const CDbapiEvent& e) 
{
    _TRACE(GetIdent() << " " << (void*)this << ": '" << e.GetName() 
           << "' from " << e.GetSource()->GetIdent());

    if(dynamic_cast<const CDbapiDeletedEvent*>(&e) != 0 ) {
	RemoveListener(e.GetSource());
        if(dynamic_cast<CConnection*>(e.GetSource()) != 0 ) {
            _TRACE("Deleting " << GetIdent() << " " << (void*)this); 
            delete this;
        }
    }
}
Esempio n. 11
0
  //-----------------------------------------------------------
  void OprtMul::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int num)
  { 
    assert(num==2);
    IValue *arg1 = a_pArg[0].Get();
    IValue *arg2 = a_pArg[1].Get();
    if (arg1->GetType()=='m' && arg2->GetType()=='m')
    {
      // Scalar multiplication
      matrix_type a1 = arg1->GetArray();
      matrix_type a2 = arg2->GetArray();

      if (a1.GetRows()!=a2.GetRows())
        throw ParserError(ErrorContext(ecARRAY_SIZE_MISMATCH, -1, GetIdent(), 'm', 'm', 2));

      float_type val(0);
      for (int i=0; i<a1.GetRows(); ++i)
        val += a1.At(i).GetFloat()*a2.At(i).GetFloat();

      *ret = val;
    }
    else if (arg1->GetType()=='m' && arg2->IsNonComplexScalar())
    {
      // Skalar * Vector
      matrix_type out(a_pArg[0]->GetArray());
      for (int i=0; i<out.GetRows(); ++i)
        out.At(i) = out.At(i).GetFloat() * arg2->GetFloat();

      *ret = out; 
    }
    else if (arg2->GetType()=='m' && arg1->IsNonComplexScalar())
    {
      // Vector * Skalar
      matrix_type out(arg2->GetArray());
      for (int i=0; i<out.GetRows(); ++i)
        out.At(i) = out.At(i).GetFloat() * arg1->GetFloat();

      *ret = out; 
    }
    else
    {
      if (!arg1->IsNonComplexScalar())
        throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, -1, GetIdent(), arg1->GetType(), 'f', 1)); 

      if (!arg2->IsNonComplexScalar())
        throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, -1, GetIdent(), arg2->GetType(), 'f', 2)); 

      *ret = arg1->GetFloat() * arg2->GetFloat(); 
    }
  }
  //------------------------------------------------------------------------------
  void FunMax::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
  {
	  if (a_iArgc < 1)
		throw ParserError(ErrorContext(ecTOO_FEW_PARAMS, GetExprPos(), GetIdent()));

	float_type smax(-1e30), sval(0);
	for (int i=0; i<a_iArgc; ++i)
	{
	  switch(a_pArg[i]->GetType())
	  {
	  case 'f': sval = a_pArg[i]->GetFloat();   break;
	  case 'i': sval = a_pArg[i]->GetFloat(); break;
	  case 'n': break; // ignore not in list entries (missing parameter)
	  case 'c':
	  default:
		{
		  ErrorContext err;
		  err.Errc = ecTYPE_CONFLICT_FUN;
		  err.Arg = i+1;
		  err.Type1 = a_pArg[i]->GetType();
		  err.Type2 = 'f';
		  throw ParserError(err);
		}
	  }
	  smax = max(smax, sval);
	}

	*ret = smax;
  }
  /** \brief Returns the minimum value of all values.
	  \param a_pArg Pointer to an array of Values
	  \param a_iArgc Number of values stored in a_pArg
  */
  void FunSum::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
  {
	  if (a_iArgc < 1)
		  throw ParserError(ErrorContext(ecTOO_FEW_PARAMS, GetExprPos(), GetIdent()));

	float_type sum(0);

	for (int i=0; i<a_iArgc; ++i)
	{
	  switch(a_pArg[i]->GetType())
	  {
	  case 'f':
	  case 'i': sum += a_pArg[i]->GetFloat();   break;
	  default:
		{
		  ErrorContext err;
		  err.Errc = ecTYPE_CONFLICT_FUN;
		  err.Arg = i+1;
		  err.Type1 = a_pArg[i]->GetType();
		  err.Type2 = 'f';
		  throw ParserError(err);
		}
	  }
	}

	*ret = sum;
  }
Esempio n. 14
0
File: User.cpp Progetto: b3rend/znc
CString& CUser::ExpandString(const CString& sStr, CString& sRet) const {
	// offset is in hours, so * 60 * 60 gets us seconds
	time_t iUserTime = time(NULL) + (time_t)(m_fTimezoneOffset * 60 * 60);
	char *szTime = ctime(&iUserTime);
	CString sTime;

	if (szTime) {
		sTime = szTime;
		// ctime() adds a trailing newline
		sTime.Trim();
	}

	sRet = sStr;
	sRet.Replace("%user%", GetUserName());
	sRet.Replace("%defnick%", GetNick());
	sRet.Replace("%nick%", GetNick());
	sRet.Replace("%altnick%", GetAltNick());
	sRet.Replace("%ident%", GetIdent());
	sRet.Replace("%realname%", GetRealName());
	sRet.Replace("%vhost%", GetBindHost());
	sRet.Replace("%bindhost%", GetBindHost());
	sRet.Replace("%version%", CZNC::GetVersion());
	sRet.Replace("%time%", sTime);
	sRet.Replace("%uptime%", CZNC::Get().GetUptime());
	// The following lines do not exist. You must be on DrUgS!
	sRet.Replace("%znc%", "All your IRC are belong to ZNC");
	// Chosen by fair zocchihedron dice roll by SilverLeo
	sRet.Replace("%rand%", "42");

	return sRet;
}
Esempio n. 15
0
//-----------------------------------------------------------------------------------------------
string_type Variable::AsciiDump() const
{
    stringstream_type ss;

    ss << g_sCmdCode[ GetCode() ];
    ss << _T(" [addr=0x") << std::hex << this << std::dec;
    ss << _T("; id=\"") << GetIdent() << _T("\"");
    ss << _T("; type=\"") << GetType() << _T("\"");
    ss << _T("; val=");

    switch(GetType())
    {
    case 'i':
        ss << (int_type)GetFloat();
        break;
    case 'f':
        ss << GetFloat();
        break;
    case 'm':
        ss << _T("(array)");
        break;
    case 's':
        ss << _T("\"") << GetString() << _T("\"");
        break;
    }

    ss << ((IsFlagSet(IToken::flVOLATILE)) ? _T("; ") : _T("; not ")) << _T("volatile");
    ss << _T("]");

    return ss.str();
}
Esempio n. 16
0
/** \brief Verify the operator prototype.

  Binary operators have the additional constraint that return type and the types
  of both arguments must be the same. So adding to floats can not produce a string
  and adding a number to a string is impossible.
*/
void IOprtBin::CheckPrototype(const string_type &a_sProt)
{
    if (a_sProt.length()!=4)
        throw ParserError( ErrorContext(ecAPI_INVALID_PROTOTYPE, -1, GetIdent() ) );

    //if (a_sProt[0]!=a_sProt[2] || a_sProt[0]!=a_sProt[3])
    //  throw ParserError( ErrorContext(ecAPI_INVALID_PROTOTYPE, -1, GetIdent() ) );
}
Esempio n. 17
0
void CConnection::Action(const CDbapiEvent& e)
{
    _TRACE(GetIdent() << " " << (void*)this << ": '" << e.GetName()
        << "' received from " << e.GetSource()->GetIdent() << " " << (void*)e.GetSource());

    if(dynamic_cast<const CDbapiClosedEvent*>(&e) != 0 ) {
/*
        CStatement *stmt;
        CCallableStatement *cstmt;
        CCursor *cursor;
        CDBAPIBulkInsert *bulkInsert;
        if( (cstmt = dynamic_cast<CCallableStatement*>(e.GetSource())) != 0 ) {
            if( cstmt == m_cstmt ) {
                _TRACE("CConnection: Clearing cached callable statement " << (void*)m_cstmt);
                m_cstmt = 0;
            }
        }
        else if( (stmt = dynamic_cast<CStatement*>(e.GetSource())) != 0 ) {
            if( stmt == m_stmt ) {
                _TRACE("CConnection: Clearing cached statement " << (void*)m_stmt);
                m_stmt = 0;
            }
        }
        else if( (cursor = dynamic_cast<CCursor*>(e.GetSource())) != 0 ) {
            if( cursor == m_cursor ) {
                _TRACE("CConnection: Clearing cached cursor " << (void*)m_cursor);
                m_cursor = 0;
            }
        }
        else if( (bulkInsert = dynamic_cast<CDBAPIBulkInsert*>(e.GetSource())) != 0 ) {
            if( bulkInsert == m_bulkInsert ) {
                _TRACE("CConnection: Clearing cached bulkinsert " << (void*)m_bulkInsert);
                m_bulkInsert = 0;
            }
        }
*/
        if( m_connCounter == 1 )
            m_connUsed = false;
    }
    else if(dynamic_cast<const CDbapiAuxDeletedEvent*>(&e) != 0 ) {
        if( m_connCounter > 1 ) {
            --m_connCounter;
            _TRACE("Server: " << GetCDB_Connection()->ServerName()
                   <<", connections left: " << m_connCounter);
        }
        else
            m_connUsed = false;
    }
    else if(dynamic_cast<const CDbapiDeletedEvent*>(&e) != 0 ) {
        RemoveListener(e.GetSource());
        if(dynamic_cast<CDataSource*>(e.GetSource()) != 0 ) {
            if( m_ownership == eNoOwnership ) {
                delete this;
            }
        }
    }
}
Token* Tokenizer::GetNext() {
  Token* T = NULL;

  // First check to see if there is an UnGetToken. If there is, use it.
  if (UnGetToken != NULL) {
    T = UnGetToken;
    UnGetToken = NULL;
    return T;
  }

  // Otherwise, crank up the scanner and get a new token.

  // Get rid of any whitespace
  SkipWhiteSpace();

  // test for end of file
  if (buffer.isEOF()) {
    T = new Token(EOFSYM);

  } else {
    
    // Save the starting position of the symbol in a variable,
    // so that nicer error messages can be produced.
    TokenColumn = buffer.CurColumn();
    
    // Check kind of current character
    
    // Note that _'s are now allowed in identifiers.
    if (isalpha(CurrentCh) || '_' == CurrentCh) {
      // grab identifier or reserved word
      T = GetIdent();
    } else if ( '"' == CurrentCh)  {
      T = GetQuotedIdent(); 
    } else if (isdigit(CurrentCh) || '-' == CurrentCh || '.' == CurrentCh) {
      T = GetScalar();
    } else { 
      //
      // Check for other tokens
      //
      
      T = GetPunct();
    }
  }
  
  if (T == NULL) {
    throw ParserFatalException("didn't get a token");
  }

  if (_printTokens) {
    std::cout << "Token read: ";
    T->Print();
    std::cout << std::endl;
  }

  return T;
}
Esempio n. 19
0
CResultSet::~CResultSet()
{
    try {
        Notify(CDbapiClosedEvent(this));
        FreeResources();
        Notify(CDbapiDeletedEvent(this));
        _TRACE(GetIdent() << " " << (void*)this << " deleted.");
    }
    NCBI_CATCH_ALL_X( 6, kEmptyStr )
}
Esempio n. 20
0
  //---------------------------------------------------------------------------
  string_type TokenIfThenElse::AsciiDump() const
  {
    stringstream_type ss;

    ss << GetIdent();
    ss << _T(" [addr=0x") << std::hex << this << std::dec;
    ss << _T("; offset=") << m_nOffset;
    ss << _T("]");
    return ss.str();
  }
Esempio n. 21
0
static SymPtr FieldReference(SymPtr clas)
{
	SymPtr field,parent;
	char *fieldname;
	
	SkipToken(tPERIOD);
	fieldname = GetIdent();
	    
	/* lookup field in class and parents */
	parent=clas;
	while( parent!=NULL )
	{
		field = SymFindLocal(fieldname,parent);
		if( field!=NULL ) break;
		parent = parent->super;
	}

	if( field==NULL )
	{
		compileError("field '%s' not found",fieldname); 
		return NULL;
	}
	
	field->flags |= SYM_FIELD; /* MCC */
	
	if( field->flags&SYM_PRIVATE )
	{
		compileError("attempt to access private field '%s'",fieldname);
		return NULL;
	}
	
	if( field->flags&SYM_PROTECTED && !in_class )
	{
		compileError("attempt to access protected field '%s'",fieldname);
		return NULL;
	}

	NextToken();

	if( is_func_kind(field) )
    {
		return field;
    }
	
	if( is_global_kind(clas) )
	{
		vm_genI(op_getglobal,clas->num);
	}
	else if( is_local_kind(clas) )
	{
		vm_genI(op_getlocal,clas->num);
	}

	return field;
}
Esempio n. 22
0
static void FormalParam(void)
{
	SymPtr sym;
	Pointer param;

	MatchToken(tVARIABLE);
	param = GetIdent();
	sym = SymAdd(param);
	sym->kind = LOCAL_KIND;
	NextToken();
}
 //-----------------------------------------------------------------------------------------------
 int Variable::GetCols() const
 {
     try
     {
         return m_pVal->GetCols();
     }
     catch (ParserError &exc)
     {
         exc.GetContext().Ident = GetIdent();
         throw;
     }
 }
 //-----------------------------------------------------------------------------------------------
 const matrix_type& Variable::GetArray() const
 {
     try
     {
         return m_pVal->GetArray();
     }
     catch (ParserError &exc)
     {
         exc.GetContext().Ident = GetIdent();
         throw;
     }
 }
 //-----------------------------------------------------------------------------------------------
 const string_type& Variable::GetString() const
 {
     try
     {
         return m_pVal->GetString();
     }
     catch (ParserError &exc)
     {
         exc.GetContext().Ident = GetIdent();
         throw;
     }
 }
 //-----------------------------------------------------------------------------------------------
 const cmplx_type& Variable::GetComplex() const
 {
     try
     {
         return m_pVal->GetComplex();
     }
     catch (ParserError &exc)
     {
         exc.GetContext().Ident = GetIdent();
         throw;
     }
 }
  //------------------------------------------------------------------------------
  string_type ICallback::AsciiDump() const
  {
    stringstream_type ss;

    ss << g_sCmdCode[ GetCode() ];
    ss << _T(" [addr=0x") << std::hex << this << std::dec;
    ss << _T("; ident=\"") << GetIdent() << "\"";
    ss << _T("; argc=") << GetArgc() << " (present: " << m_nArgsPresent << ")";
    ss << _T("]");

    return ss.str();
  }
Esempio n. 28
0
  //-----------------------------------------------------------
  void OprtOr::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int num)
  {
	assert(num==2);

	if (!a_pArg[0]->IsScalar())
	  throw ParserError(ErrorContext(ecTYPE_CONFLICT_FUN, -1, GetIdent(), a_pArg[0]->GetType(), 'i', 1));

	if (!a_pArg[1]->IsScalar())
	  throw ParserError(ErrorContext(ecTYPE_CONFLICT_FUN, -1, GetIdent(), a_pArg[1]->GetType(), 'i', 2));

	float_type a = a_pArg[0]->GetFloat(),
			   b = a_pArg[1]->GetFloat();

	if (a!=(int_type)a)
	  throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, -1, a_pArg[0]->GetIdent(), a_pArg[0]->GetType(), 'i', 1) );

	if (b!=(int_type)b)
	  throw ParserError( ErrorContext(ecTYPE_CONFLICT_FUN, -1, a_pArg[1]->GetIdent(), a_pArg[1]->GetType(), 'i', 2) );

	*ret = (int_type)a | (int_type)(b);
  }
Esempio n. 29
0
//------------------------------------------------------------------------------
string_type IOprtIndex::AsciiDump() const
{
    stringstream_type ss;

    ss << g_sCmdCode[ GetCode() ];
    ss << _T(" [addr=0x") << std::hex << this << std::dec;
    ss << _T("; ident=\"") << GetIdent() << _T("\"");
    ss << _T("; argc=") << GetArgc();
    ss << _T("]");

    return ss.str();
}
 //-----------------------------------------------------------------------------------------------
 IValue& Variable::At(const IValue &row, const IValue &col)
 {
   try
   {
     return m_pVal->At(row, col);
   }
   catch(ParserError &exc)
   {
     // add the identifier to the error context
     exc.GetContext().Ident = GetIdent();
     throw exc;
   }
 }