15#ifndef ORTOOLS_MATH_OPT_ELEMENTAL_CODEGEN_GEN_H_
16#define ORTOOLS_MATH_OPT_ELEMENTAL_CODEGEN_GEN_H_
23#include "absl/strings/string_view.h"
24#include "absl/types/span.h"
65 static std::shared_ptr<Type>
Named(std::string name);
67 static std::shared_ptr<Type>
Pointer(std::shared_ptr<Type> pointee);
76 virtual void Print(absl::string_view attr_value_type,
77 std::string* out)
const = 0;
90 std::shared_ptr<Type>
type;
102 : attr_op_function_infos_(*attr_op_function_infos) {}
113 virtual void EmitElements(absl::Span<const absl::string_view> elements,
114 std::string* out)
const {}
121 absl::Span<const CodegenAttrTypeDescriptor> descriptors,
122 std::string* out)
const;
126 std::string* out)
const {}
132 std::string* out)
const {}
136 std::string* out)
const;
std::string GenerateCode() const
CodeGenerator(const AttrOpFunctionInfos *attr_op_function_infos)
virtual void EmitElements(absl::Span< const absl::string_view > elements, std::string *out) const
virtual void StartAttrType(const CodegenAttrTypeDescriptor &descriptor, std::string *out) const
virtual void EmitAttributes(absl::Span< const CodegenAttrTypeDescriptor > descriptors, std::string *out) const
virtual void EmitAttrOp(absl::string_view op_name, const CodegenAttrTypeDescriptor &descriptor, const AttrOpFunctionInfo &info, std::string *out) const
virtual void EmitHeader(std::string *out) const
virtual ~CodeGenerator()=default
static std::shared_ptr< Type > Named(std::string name)
static std::shared_ptr< Type > Pointer(std::shared_ptr< Type > pointee)
virtual void Print(absl::string_view attr_value_type, std::string *out) const =0
static std::shared_ptr< Type > AttrValueType()
static constexpr int kNumAttrOps
std::array< AttrOpFunctionInfo, kNumAttrOps > AttrOpFunctionInfos
std::shared_ptr< Type > return_type
std::vector< ExtraParameter > extra_parameters
std::vector< absl::string_view > attribute_names