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

A code generator for the Bond scripting language. More...

#include <bond/compiler/codegenerator.h>

Public Member Functions

 CodeGenerator (Allocator &allocator, CompilerErrorBuffer &errorBuffer, PointerSize pointerSize=BOND_NATIVE_POINTER_SIZE)
 Constructs a CodeGenerator object. More...
 
 ~CodeGenerator ()
 
void Generate (const TranslationUnit *translationUnitList, OutputStream &stream)
 Generates bytecode for a list of parse trees. More...
 

Detailed Description

A code generator for the Bond scripting language.

The CodeGenerator traverses the given parse tree and compiles it to bytecode that can be interpreted by a virtual machine. The bytecode is written to the given OutputStream in the CBO file format.

See also
ParseNode

Constructor & Destructor Documentation

◆ CodeGenerator()

Bond::CodeGenerator::CodeGenerator ( Allocator allocator,
CompilerErrorBuffer errorBuffer,
PointerSize  pointerSize = BOND_NATIVE_POINTER_SIZE 
)
inline

Constructs a CodeGenerator object.

Parameters
allocatorAllocator used for temporary memory allocations made by the Generate method.
errorBufferBuffer where error messages are pushed when code generation errors are encountered.
pointerSizeSize of pointers used by the target virtual machine that will execute the Bond bytecode. It is required to generate correct pointer arithmetic instructions for the target platform.

◆ ~CodeGenerator()

Bond::CodeGenerator::~CodeGenerator ( )
inline

Member Function Documentation

◆ Generate()

void Bond::CodeGenerator::Generate ( const TranslationUnit translationUnitList,
OutputStream stream 
)

Generates bytecode for a list of parse trees.

Parameters
translationUnitListA linked list of parse trees to be compiled to bytecode.
streamOutputStream to which the generated bytecode is written in the CBO file format.

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