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

A container for error information reported by the various components of the Bond compiler. More...

#include <bond/compiler/compilererror.h>

Public Types

enum  Type {
  NO_ERROR , INVALID_ESCAPE , MISSING_HEX_ESCAPE , OCTAL_ESCAPE_RANGE ,
  HEX_ESCAPE_RANGE , INVALID_OCTAL_INT , INVALID_HEX_INT , INVALID_INT ,
  INVALID_FLOAT , EMPTY_CHARACTER_CONSTANT , MULTI_CHARACTER_CONSTANT , UNTERMINATED_CHARACTER ,
  UNTERMINATED_STRING , UNTERMINATED_COMMENT , DUPLICATE_CONST , PARSE_ERROR ,
  SIZE_AND_ALIGNMENT_NOT_ALLOWED , VOID_NOT_ALLOWED , ARRAY_OF_VOID , MULTIDIMENTIONAL_ARRAY_BOUNDS ,
  INITIALIZER_NOT_ALLOWED , CONST_NON_MEMBER_FUNCTION , NATIVE_FUNCTION_DEFINITION , NON_NATIVE_FUNCTION_DECLARATION ,
  FUNCTION_RETURNS_ARRAY , EMPTY_SWITCH_STATEMENT , EMPTY_SWITCH_LABEL_LIST , UNTERMINATED_SWITCH_SECTION ,
  DUPLICATE_DEFAULT_IN_SWITCH , DUPLICATE_CASE_IN_SWITCH , INVALID_OPERATOR_IN_CONST_EXPRESSION , FUNCTION_CALL_IN_CONST_EXPRESSION ,
  DUPLICATE_SYMBOL , UNEXPECTED_TOKEN , SYMBOL_IS_NOT_DEFINED , NATIVE_STRUCT_IS_NOT_DEFINED ,
  DUPLICATE_NATIVE_STRUCT_STUB , SYMBOL_IS_NOT_A_TYPE , INVALID_SYMBOL_IN_EXPRESSION , NON_STRUCT_MEMBER_REQUEST ,
  INVALID_MEMBER_REQUEST , NON_CONST_MEMBER_FUNCTION_REQUEST , THIS_IN_NON_MEMBER_FUNCTION , EXPRESSION_IS_NOT_CALLABLE ,
  INCORRECT_NUMBER_OF_ARGS , INVALID_TYPE_FOR_OPERATOR , INVALID_TYPE_FOR_POINTER_OPERATOR , INVALID_TYPE_FOR_INDEX_OPERATOR ,
  INVALID_TYPE_CONVERSION , INVALID_RETURN_TYPE_CONVERSION , INVALID_TYPE_ASSIGNMENT , ENUMERATOR_VALUE_IS_NOT_CONST_INTEGER ,
  ARRAY_SIZE_IS_NOT_CONST_INTEGER , ARRAY_SIZE_IS_ZERO , ARRAY_SIZE_IS_UNSPECIFIED , SWITCH_CONTROL_IS_NOT_INTEGER ,
  SWITCH_LABEL_IS_NOT_CONST_INTEGER , IF_CONDITION_IS_NOT_BOOLEAN , WHILE_CONDITION_IS_NOT_BOOLEAN , FOR_CONDITION_IS_NOT_BOOLEAN ,
  TERNARY_OPERAND_TYPE_MISMATCH , UNINITIALIZED_CONST , NON_CONST_DECLARATION , NON_LVALUE_TYPE ,
  NON_LVALUE_ASSIGNMENT , UNASSIGNABLE_TYPE , VOID_POINTER_DEREFERENCE , INVALID_COMPARISON ,
  TOO_MANY_INITIALIZERS , CANNOT_INITIALIZE_NATIVE_TYPE_WITH_INITIALIZER_LIST , MISSING_BRACES_IN_INITIALIZER , BRACES_AROUND_SCALAR_INITIALIZER ,
  RECURSIVE_STRUCT , CANNOT_RESOLVE_SYMBOL_VALUE , INVALID_STRUCT_SIZE , INVALID_STRUCT_ALIGNMENT ,
  STRUCT_SIZE_ALIGNMENT_MISMATCH , DECLARATION_OF_UNDEFINED_SIZE , RETURN_OF_UNDEFINED_SIZE , ASSIGNMENT_OF_UNDEFINED_SIZE ,
  POINTER_ARITHMETIC_OF_UNDEFINED_SIZE , NOT_ALL_PATHS_RETURN_A_VALUE , INVALID_BREAK , INVALID_CONTINUE ,
  UNREACHABLE_CODE , LOSSY_CONVERSION , VALUE32_TABLE_OVERFLOW , VALUE64_TABLE_OVERFLOW ,
  STRING_TABLE_OVERFLOW , QUALIFIED_NAME_TABLE_OVERFLOW , STRING_OVERFLOW , INTERNAL_ERROR
}
 An enumeration identifying all types of compiler errors. More...
 

Public Member Functions

 CompilerError ()
 Default constructs an empty CompilerError object with the NO_ERROR error type. More...
 
 CompilerError (Type type, const Token *context, intptr_t arg0, intptr_t arg1)
 Constructs a CompilerError object with the given type and arguments supplied by the compiler to format the error message. More...
 
Type GetType () const
 Returns the error's type. More...
 
const TokenGetContext () const
 Returns the context Token providing the location of the error in the Bond source. More...
 
const char * GetFormat () const
 Returns the error message format string for the CompilerError's type. More...
 
const char * GetErrorName () const
 Returns a string representation of the CompilerError's type. More...
 
void Print (OutputStream &stream) const
 Prints a formatted error message to the given OutputStream. More...
 

Static Public Member Functions

static const char * GetFormat (Type type)
 Returns the error message format string for the given error type. More...
 
static const char * GetErrorName (Type type)
 Returns a string representation of the given error type. More...
 

Detailed Description

A container for error information reported by the various components of the Bond compiler.

A CompilerError contains information regarding an error reported by some component of the Bond compiler, namely the Lexer, Parser, SemanticAnalyzer and CodeGenerator. The information includes the type of error, a token corresponding to the location in the source code where the error was detected as well as a couple of other arguments giving contextual information about the nature of the error.

CompilerError instances are seldom manipulated individually, since the compiler populates a CompilerErrorBuffer which implements functionality for dumping out information about all errors it contains.

See also
CodeGenerator, CompilerErrorBuffer, Lexer, Parser, SemanticAnalyzer

Member Enumeration Documentation

◆ Type

An enumeration identifying all types of compiler errors.

Enumerator
NO_ERROR 
INVALID_ESCAPE 
MISSING_HEX_ESCAPE 
OCTAL_ESCAPE_RANGE 
HEX_ESCAPE_RANGE 
INVALID_OCTAL_INT 
INVALID_HEX_INT 
INVALID_INT 
INVALID_FLOAT 
EMPTY_CHARACTER_CONSTANT 
MULTI_CHARACTER_CONSTANT 
UNTERMINATED_CHARACTER 
UNTERMINATED_STRING 
UNTERMINATED_COMMENT 
DUPLICATE_CONST 
PARSE_ERROR 
SIZE_AND_ALIGNMENT_NOT_ALLOWED 
VOID_NOT_ALLOWED 
ARRAY_OF_VOID 
MULTIDIMENTIONAL_ARRAY_BOUNDS 
INITIALIZER_NOT_ALLOWED 
CONST_NON_MEMBER_FUNCTION 
NATIVE_FUNCTION_DEFINITION 
NON_NATIVE_FUNCTION_DECLARATION 
FUNCTION_RETURNS_ARRAY 
EMPTY_SWITCH_STATEMENT 
EMPTY_SWITCH_LABEL_LIST 
UNTERMINATED_SWITCH_SECTION 
DUPLICATE_DEFAULT_IN_SWITCH 
DUPLICATE_CASE_IN_SWITCH 
INVALID_OPERATOR_IN_CONST_EXPRESSION 
FUNCTION_CALL_IN_CONST_EXPRESSION 
DUPLICATE_SYMBOL 
UNEXPECTED_TOKEN 
SYMBOL_IS_NOT_DEFINED 
NATIVE_STRUCT_IS_NOT_DEFINED 
DUPLICATE_NATIVE_STRUCT_STUB 
SYMBOL_IS_NOT_A_TYPE 
INVALID_SYMBOL_IN_EXPRESSION 
NON_STRUCT_MEMBER_REQUEST 
INVALID_MEMBER_REQUEST 
NON_CONST_MEMBER_FUNCTION_REQUEST 
THIS_IN_NON_MEMBER_FUNCTION 
EXPRESSION_IS_NOT_CALLABLE 
INCORRECT_NUMBER_OF_ARGS 
INVALID_TYPE_FOR_OPERATOR 
INVALID_TYPE_FOR_POINTER_OPERATOR 
INVALID_TYPE_FOR_INDEX_OPERATOR 
INVALID_TYPE_CONVERSION 
INVALID_RETURN_TYPE_CONVERSION 
INVALID_TYPE_ASSIGNMENT 
ENUMERATOR_VALUE_IS_NOT_CONST_INTEGER 
ARRAY_SIZE_IS_NOT_CONST_INTEGER 
ARRAY_SIZE_IS_ZERO 
ARRAY_SIZE_IS_UNSPECIFIED 
SWITCH_CONTROL_IS_NOT_INTEGER 
SWITCH_LABEL_IS_NOT_CONST_INTEGER 
IF_CONDITION_IS_NOT_BOOLEAN 
WHILE_CONDITION_IS_NOT_BOOLEAN 
FOR_CONDITION_IS_NOT_BOOLEAN 
TERNARY_OPERAND_TYPE_MISMATCH 
UNINITIALIZED_CONST 
NON_CONST_DECLARATION 
NON_LVALUE_TYPE 
NON_LVALUE_ASSIGNMENT 
UNASSIGNABLE_TYPE 
VOID_POINTER_DEREFERENCE 
INVALID_COMPARISON 
TOO_MANY_INITIALIZERS 
CANNOT_INITIALIZE_NATIVE_TYPE_WITH_INITIALIZER_LIST 
MISSING_BRACES_IN_INITIALIZER 
BRACES_AROUND_SCALAR_INITIALIZER 
RECURSIVE_STRUCT 
CANNOT_RESOLVE_SYMBOL_VALUE 
INVALID_STRUCT_SIZE 
INVALID_STRUCT_ALIGNMENT 
STRUCT_SIZE_ALIGNMENT_MISMATCH 
DECLARATION_OF_UNDEFINED_SIZE 
RETURN_OF_UNDEFINED_SIZE 
ASSIGNMENT_OF_UNDEFINED_SIZE 
POINTER_ARITHMETIC_OF_UNDEFINED_SIZE 
NOT_ALL_PATHS_RETURN_A_VALUE 
INVALID_BREAK 
INVALID_CONTINUE 
UNREACHABLE_CODE 
LOSSY_CONVERSION 
VALUE32_TABLE_OVERFLOW 
VALUE64_TABLE_OVERFLOW 
STRING_TABLE_OVERFLOW 
QUALIFIED_NAME_TABLE_OVERFLOW 
STRING_OVERFLOW 
INTERNAL_ERROR 

Constructor & Destructor Documentation

◆ CompilerError() [1/2]

Bond::CompilerError::CompilerError ( )
inline

Default constructs an empty CompilerError object with the NO_ERROR error type.

◆ CompilerError() [2/2]

Bond::CompilerError::CompilerError ( Type  type,
const Token context,
intptr_t  arg0,
intptr_t  arg1 
)
inline

Constructs a CompilerError object with the given type and arguments supplied by the compiler to format the error message.

Parameters
typeAn enumerator identifying what type of error the compiler has detected.
contextA Token identifying where in the source code the error was detected.
arg0An argument supplying information to be inserted into the format string for the error message. Can be an integer, a C-style string, a pointer to a Token, or a pointer to a ParseNode depending on the requirements of the error message.
arg1An additional argument used in the same way as arg0.

Member Function Documentation

◆ GetContext()

const Token * Bond::CompilerError::GetContext ( ) const
inline

Returns the context Token providing the location of the error in the Bond source.

◆ GetErrorName() [1/2]

const char * Bond::CompilerError::GetErrorName ( ) const

Returns a string representation of the CompilerError's type.

◆ GetErrorName() [2/2]

static const char * Bond::CompilerError::GetErrorName ( Type  type)
static

Returns a string representation of the given error type.

◆ GetFormat() [1/2]

const char * Bond::CompilerError::GetFormat ( ) const

Returns the error message format string for the CompilerError's type.

◆ GetFormat() [2/2]

static const char * Bond::CompilerError::GetFormat ( Type  type)
static

Returns the error message format string for the given error type.

◆ GetType()

Type Bond::CompilerError::GetType ( ) const
inline

Returns the error's type.

◆ Print()

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

Prints a formatted error message to the given OutputStream.

Parameters
streamThe OutputStream to which the error message is printed.

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