Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::codegen::CodeGenerator Class Reference

The code generator interface. More...

#include <gen.h>

Public Member Functions

 CodeGenerator (const AttrOpFunctionInfos *attr_op_function_infos)
virtual ~CodeGenerator ()=default
std::string GenerateCode () const
 Generates code.
virtual void EmitHeader (std::string *out) const
 Emits the header for the generated code.
virtual void EmitElements (absl::Span< const absl::string_view > elements, std::string *out) const
 Emits code for elements.
virtual void EmitAttributes (absl::Span< const CodegenAttrTypeDescriptor > descriptors, std::string *out) const
virtual void StartAttrType (const CodegenAttrTypeDescriptor &descriptor, std::string *out) const
 Called before generating code for an attribute type.
virtual void EmitAttrOp (absl::string_view op_name, const CodegenAttrTypeDescriptor &descriptor, const AttrOpFunctionInfo &info, std::string *out) const
 Emits code for operation info for attribute described by descriptor.

Detailed Description

The code generator interface.

Definition at line 99 of file gen.h.

Constructor & Destructor Documentation

◆ CodeGenerator()

operations_research::math_opt::codegen::CodeGenerator::CodeGenerator ( const AttrOpFunctionInfos * attr_op_function_infos)
inlineexplicit

Definition at line 101 of file gen.h.

◆ ~CodeGenerator()

virtual operations_research::math_opt::codegen::CodeGenerator::~CodeGenerator ( )
virtualdefault

Member Function Documentation

◆ EmitAttributes()

void operations_research::math_opt::codegen::CodeGenerator::EmitAttributes ( absl::Span< const CodegenAttrTypeDescriptor > descriptors,
std::string * out ) const
virtual

Emits code for attributes. By default, this iterates attributes and for each attribute:

  • calls StartAttrType, and
  • calls EmitAttrOp for each operation.

Definition at line 127 of file gen.cc.

◆ EmitAttrOp()

virtual void operations_research::math_opt::codegen::CodeGenerator::EmitAttrOp ( absl::string_view op_name,
const CodegenAttrTypeDescriptor & descriptor,
const AttrOpFunctionInfo & info,
std::string * out ) const
inlinevirtual

Emits code for operation info for attribute described by descriptor.

Definition at line 129 of file gen.h.

◆ EmitElements()

virtual void operations_research::math_opt::codegen::CodeGenerator::EmitElements ( absl::Span< const absl::string_view > elements,
std::string * out ) const
inlinevirtual

Emits code for elements.

Definition at line 113 of file gen.h.

◆ EmitHeader()

virtual void operations_research::math_opt::codegen::CodeGenerator::EmitHeader ( std::string * out) const
inlinevirtual

Emits the header for the generated code.

Definition at line 110 of file gen.h.

◆ GenerateCode()

std::string operations_research::math_opt::codegen::CodeGenerator::GenerateCode ( ) const

Generates code.

Generate elements.

Generate attributes.

Definition at line 138 of file gen.cc.

◆ StartAttrType()

virtual void operations_research::math_opt::codegen::CodeGenerator::StartAttrType ( const CodegenAttrTypeDescriptor & descriptor,
std::string * out ) const
inlinevirtual

Called before generating code for an attribute type.

Definition at line 125 of file gen.h.


The documentation for this class was generated from the following files:
  • ortools/math_opt/elemental/codegen/gen.h
  • ortools/math_opt/elemental/codegen/gen.cc