Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::CompilerErrorBuffer Class Reference

A container for CompilerError instances generated by the various components of the Bond compiler. More...

#include <bond/compiler/compilererror.h>

Public Member Functions

 CompilerErrorBuffer ()
 Default constructs an empty CompilerErrorBuffer object. More...
 
void Reset ()
 Clears the contents of the error buffer. More...
 
void PushError (CompilerError::Type type, const Token *context=nullptr, const void *arg0=nullptr, const void *arg1=nullptr)
 Constructs a CompilerError object with the given type and arguments to format the error message and adds it to the buffer. More...
 
void PushErrorInt (CompilerError::Type type, const Token *context=nullptr, intptr_t arg0=0, intptr_t arg1=0)
 Constructs a CompilerError object with the given type and arguments to format the error message and adds it to the buffer. More...
 
bool HasErrors () const
 Returns whether the buffer contains any errors. More...
 
size_t GetNumErrors () const
 Returns the number of errors in the buffer. More...
 
const CompilerErrorGetError (size_t index) const
 Returns the CompilerError at the specified index in the buffer. More...
 
void CopyFrom (const CompilerErrorBuffer &other)
 Appends the contents of the given CompilerErrorBuffer to this one. More...
 
void Print (OutputStream &stream) const
 Prints a formatted error message for each error to the given OutputStream. More...
 

Detailed Description

A container for CompilerError instances generated by the various components of the Bond compiler.

A CompilerErrorBuffer is used by the Lexer, Parser, SemanticAnalyzer and CodeGenerator of the Bond compiler to collect the errors that they detect. The CompilerErrorBuffer provides functionality for printing formatted error messages to an OutputStream.

The size of the buffer is fixed, and no memory allocations are incurred. If the buffer overflows, any additional errors are dropped since they are not considered relevant because they are most likely the consequence of the compiler being confused by the initial set of errors that caused the buffer to fill up.

See also
CodeGenerator, CompilerError, Lexer, Parser, SemanticAnalyzer

Constructor & Destructor Documentation

◆ CompilerErrorBuffer()

Bond::CompilerErrorBuffer::CompilerErrorBuffer ( )

Default constructs an empty CompilerErrorBuffer object.

Member Function Documentation

◆ CopyFrom()

void Bond::CompilerErrorBuffer::CopyFrom ( const CompilerErrorBuffer other)

Appends the contents of the given CompilerErrorBuffer to this one.

Parameters
otherThe CompilerErrorBuffer whose contents are appended.

◆ GetError()

const CompilerError & Bond::CompilerErrorBuffer::GetError ( size_t  index) const
inline

Returns the CompilerError at the specified index in the buffer.

Parameters
indexThe index of the error to be retrieved.

◆ GetNumErrors()

size_t Bond::CompilerErrorBuffer::GetNumErrors ( ) const
inline

Returns the number of errors in the buffer.

◆ HasErrors()

bool Bond::CompilerErrorBuffer::HasErrors ( ) const
inline

Returns whether the buffer contains any errors.

◆ Print()

void Bond::CompilerErrorBuffer::Print ( OutputStream stream) const

Prints a formatted error message for each error to the given OutputStream.

Parameters
streamThe OutputStream to which the error messages are printed.

◆ PushError()

void Bond::CompilerErrorBuffer::PushError ( CompilerError::Type  type,
const Token context = nullptr,
const void *  arg0 = nullptr,
const void *  arg1 = nullptr 
)

Constructs a CompilerError object with the given type and arguments to format the error message and adds it to the buffer.

See also
CompilerError::CompilerError.

◆ PushErrorInt()

void Bond::CompilerErrorBuffer::PushErrorInt ( CompilerError::Type  type,
const Token context = nullptr,
intptr_t  arg0 = 0,
intptr_t  arg1 = 0 
)

Constructs a CompilerError object with the given type and arguments to format the error message and adds it to the buffer.

See also
CompilerError::CompilerError.

◆ Reset()

void Bond::CompilerErrorBuffer::Reset ( )

Clears the contents of the error buffer.


The documentation for this class was generated from the following file: