Esempio n. 1
0
 ///\brief Get reference to parent node.
 ///
 /// Returns reference to parent node, if exists.
 /// Throws node::AddressError exception in other way.
 ///
 Node& Node::getTop() const 
 {
   if (this->top != 0)
     return *(this->top);
   else
     throw AddressError(this);
 }
Esempio n. 2
0
 ///\brief Get reference to left child.
 ///
 /// Returns reference to left child, if exists.
 /// Throws node::AddressError exception in other way.
 Node& Node::getLeft() const 
 {
   if (this->left != 0)
     return *(this->left);
   else 
     throw AddressError(this);
 }
Esempio n. 3
0
 ///\brief Get reference to right child.
 ///
 /// Returns reference to right child, if exists.
 /// Throws node::AddressError exception in other way.
 Node& Node::getRight() const 
 {
   if (this->right != 0)
     return *(this->right);
   else
     throw AddressError(this);
 }
static void Push( int value )
{
    if ( SP >= STACKSIZE-1 )  {
        AddressError( "Stack Overflow" );
        exit( EXIT_FAILURE );
    }
    else  {
        SP++;
        Dmem[SP] = value;
    }
}
static int  DataAddr( int addr )
{
    char buffer[80];

    if ( addr < 0 || addr > STACKSIZE )  {
        sprintf( buffer, "Illegal data address %d", addr );
        AddressError( buffer );
        exit( EXIT_FAILURE );
    }
    return addr;
}
static int  CodeAddr( int addr )
{
    char buffer[80];

    if ( addr < 0 || addr > CODESIZE )  {
        sprintf( buffer, "Illegal code address %d", addr );
        AddressError( buffer );
        exit( EXIT_FAILURE );
    }
    return addr;
}
static int  Decrement( int currentSP, int amount )
{
    int newSP;
    char buffer[80];

    newSP = currentSP - amount;
    if ( newSP < -1 ) {
        sprintf( buffer, "Illegal stack pointer address %d", newSP );
        AddressError( buffer );
        exit( EXIT_FAILURE );
    }
    return newSP;
}
static int  Pop( void )
{
    int temp;

    if ( SP < 0 )  {
        AddressError( "Stack Underflow" );
        exit( EXIT_FAILURE );
    }
    else  {
        temp = Dmem[SP];
        SP--;
    }
    return temp;
}