LIBINT 2.7.2
Public Member Functions | List of all members
libint2::CppCodeContext Class Reference

CppCodeContext is an implementation of CodeContext for C++. More...

#include <context.h>

Inheritance diagram for libint2::CppCodeContext:
Inheritance graph
[legend]
Collaboration diagram for libint2::CppCodeContext:
Collaboration graph
[legend]

Public Member Functions

 CppCodeContext (const SafePtr< CompilationParameters > &cparams, bool vectorize=false)
 
std::string code_prefix () const override
 Implementation of CodeContext::code_prefix() More...
 
std::string code_postfix () const override
 Implementation of CodeContext::code_postfix() More...
 
std::string copyright () const override
 Implementation of CodeContext::copyright() More...
 
std::string std_header () const override
 Implementation of CodeContext::std_header() More...
 
std::string std_function_header () const override
 Implementation of CodeContext::std_function_header() More...
 
std::string label_to_name (const std::string &label) const override
 Implementation of CodeContext::label_to_name(label) More...
 
std::string declare (const std::string &type, const std::string &name) const override
 Implementation of CodeContext::declare() More...
 
std::string declare_v (const std::string &type, const std::string &name, const std::string &nelem) const override
 Implementation of CodeContext::declare_v() More...
 
std::string decldef (const std::string &type, const std::string &name, const std::string &value) override
 decldef returns a statement which declares variable named 'name' of type 'type' and defines its value to be 'value' More...
 
std::string assign (const std::string &name, const std::string &value) override
 Implementation of CodeContext::assign() More...
 
std::string accumulate (const std::string &name, const std::string &value) override
 Implementation of CodeContext::accumulate() More...
 
std::string assign_binary_expr (const std::string &name, const std::string &left, const std::string &oper, const std::string &right) override
 Implementation of CodeContext::assign_binary_expr() More...
 
std::string assign_ternary_expr (const std::string &name, const std::string &arg1, const std::string &oper1, const std::string &arg2, const std::string &oper2, const std::string &arg3) override
 assign_ternary_expr returns a statement which assigns ternary expression 'arg1 oper1 arg2 oper2 arg3' to variable 'name' More...
 
std::string accumulate_binary_expr (const std::string &name, const std::string &left, const std::string &oper, const std::string &right) override
 Implementation of CodeContext::accumulate_binary_expr() More...
 
std::string accumulate_ternary_expr (const std::string &name, const std::string &arg1, const std::string &oper1, const std::string &arg2, const std::string &oper2, const std::string &arg3) override
 accumulate_ternary_expr returns a statement which accumulates ternary expression 'arg1 oper1 arg2 oper2 arg3' to variable 'name' More...
 
std::string stack_address (const DGVertex::Address &a) const override
 Implementation of CodeContext::stack_address() More...
 
std::string macro_define (const std::string &name) const override
 Implementation of CodeContext::macro_define() More...
 
std::string macro_define (const std::string &name, const std::string &value) const override
 Implementation of CodeContext::macro_define() More...
 
std::string macro_if (const std::string &name) const override
 Implementation of CodeContext::macro_if() More...
 
std::string macro_ifdef (const std::string &name) const override
 Implementation of CodeContext::macro_ifdef() More...
 
std::string macro_endif () const override
 Implementation of CodeContext::macro_endif() More...
 
std::string comment (const std::string &statement) const override
 Implementation of CodeContext::comment(statement) More...
 
std::string open_block () const override
 Implementation of CodeContext::open_block() More...
 
std::string close_block () const override
 Implementation of CodeContext::close_block() More...
 
std::string end_of_stat () const override
 Implementation of CodeContext::end_of_stat() More...
 
std::string value_to_pointer (const std::string &val) const override
 Implementation of CodeContext::value_to_pointer() More...
 
SafePtr< ForLoopfor_loop (std::string &varname, const SafePtr< Entity > &less_than, const SafePtr< Entity > &start_at) const override
 Implementation of CodeContext::for_loop() More...
 
std::string inteval_type_name (const std::string &task) const override
 Implementation of CodeContext::inteval_type_name() More...
 
std::string inteval_spec_type_name (const std::string &task) const override
 Implementation of CodeContext::inteval_spec_type_name() More...
 
std::string inteval_gen_type_name () const override
 Implementation of CodeContext::inteval_spec_type_name() More...
 
- Public Member Functions inherited from libint2::CodeContext
const SafePtr< CompilationParameters > & cparams () const
 Returns the CompilationParameters used to create this context.
 
void turn_comments (bool on)
 turn comments on and off (the default is on)
 
bool comments_on () const
 returns true if to print comments
 
virtual void reset ()
 this function resets the context to be used for the next source file
 
virtual std::string code_prefix () const =0
 produces prefix to function declarations or definitions More...
 
virtual std::string code_postfix () const =0
 produces postfix to function declarations or definitions More...
 
virtual std::string copyright () const =0
 copyright() returns the copyright statement More...
 
virtual std::string std_header () const =0
 std_header() returns declarations necessary for every source file More...
 
virtual std::string std_function_header () const =0
 std_function_header() returns declarations and definitions necessary for every function More...
 
virtual std::string label_to_name (const std::string &label) const =0
 label_to_name(label) converts label to a name valid within the context of the language More...
 
virtual std::string declare (const std::string &type, const std::string &name) const =0
 declare returns a statement which declares variable named 'name' of type 'type' More...
 
virtual std::string declare_v (const std::string &type, const std::string &name, const std::string &nelem) const =0
 declare_v returns a statement which declares a vector 'name' of 'nelem' elements of type 'type' More...
 
virtual std::string decldef (const std::string &type, const std::string &name, const std::string &value)=0
 decldef returns a statement which declares variable named 'name' of type 'type' and defines its value to be 'value' More...
 
virtual std::string assign (const std::string &name, const std::string &value)=0
 assign returns a statement which assigns variable 'value' to variable 'name' More...
 
virtual std::string accumulate (const std::string &name, const std::string &value)=0
 accumulate returns a statement which assigns variable 'value' to variable 'name' More...
 
virtual std::string assign_binary_expr (const std::string &name, const std::string &left, const std::string &oper, const std::string &right)=0
 assign_binary_expr returns a statement which assigns binary expression 'left oper right' to variable 'name' More...
 
virtual std::string assign_ternary_expr (const std::string &name, const std::string &arg1, const std::string &oper1, const std::string &arg2, const std::string &oper2, const std::string &arg3)=0
 assign_ternary_expr returns a statement which assigns ternary expression 'arg1 oper1 arg2 oper2 arg3' to variable 'name' More...
 
virtual std::string accumulate_binary_expr (const std::string &name, const std::string &left, const std::string &oper, const std::string &right)=0
 accumulate_binary_expr returns a statement which accumulates binary expression 'left oper right' to variable 'name' More...
 
virtual std::string accumulate_ternary_expr (const std::string &name, const std::string &arg1, const std::string &oper1, const std::string &arg2, const std::string &oper2, const std::string &arg3)=0
 accumulate_ternary_expr returns a statement which accumulates ternary expression 'arg1 oper1 arg2 oper2 arg3' to variable 'name' More...
 
virtual std::string stack_address (const DGVertex::Address &a) const =0
 converts an address on the stack to its string representation More...
 
virtual std::string macro_define (const std::string &name) const =0
 #define a macro More...
 
virtual std::string macro_define (const std::string &name, const std::string &value) const =0
 #define a macro More...
 
virtual std::string macro_if (const std::string &name) const =0
 #if macro More...
 
virtual std::string macro_ifdef (const std::string &name) const =0
 #ifdef macro More...
 
virtual std::string macro_endif () const =0
 #endif More...
 
virtual std::string comment (const std::string &statement) const =0
 comment(statement) returns commented statement More...
 
virtual std::string open_block () const =0
 open a code block More...
 
virtual std::string close_block () const =0
 close a code block More...
 
virtual std::string end_of_stat () const =0
 end a statement More...
 
virtual std::string value_to_pointer (const std::string &val) const =0
 converts a value to a pointer More...
 
virtual SafePtr< ForLoopfor_loop (std::string &varname, const SafePtr< Entity > &less_than, const SafePtr< Entity > &start_at=SafePtr< Entity >(new CTimeEntity< int >(0))) const =0
 returns a ForLoop object. More...
 
template<typename T >
std::string unique_name () const
 unique_name<T> returns a unique name for a variable of type T
 
template<typename T >
std::string type_name () const
 type_name<T> returns name for type T
 
virtual std::string inteval_type_name (const std::string &task) const =0
 returns the name of the evaluator type for task 'task' More...
 
virtual std::string inteval_spec_type_name (const std::string &task) const =0
 returns the name of the specialized evaluator type for task 'task' More...
 
virtual std::string inteval_gen_type_name () const =0
 returns the name of the generic evaluator type (works for any task) More...
 
virtual std::string const_modifier () const =0
 returns the modifier for constant variables
 
virtual std::string mutable_modifier () const =0
 returns the modifier for mutable variables
 
template<>
std::string type_name () const
 
template<>
std::string type_name () const
 
template<>
std::string type_name () const
 
template<>
std::string type_name () const
 
template<>
std::string type_name () const
 
template<>
std::string type_name () const
 
template<>
std::string type_name () const
 
template<>
std::string type_name () const
 

Additional Inherited Members

- Protected Member Functions inherited from libint2::CodeContext
 CodeContext (const SafePtr< CompilationParameters > &cparams)
 Lone constructor takes CompilationParams.
 
virtual std::string unique_fp_name () const =0
 generates a unique name for a floating-point variable
 
virtual std::string unique_int_name () const =0
 generates a unique name for an integer
 
unsigned int next_fp_index () const
 next fp index
 
unsigned int next_int_index () const
 next int index
 
virtual std::string void_type () const =0
 returns name of void type
 
virtual std::string int_type () const =0
 returns name of integer type
 
virtual std::string size_type () const =0
 returns name of array size type (e.g. size_t)
 
virtual std::string fp_type () const =0
 returns name of floating-point type
 
virtual std::string ptr_fp_type () const =0
 returns name of pointer to floating-point type
 
- Static Protected Member Functions inherited from libint2::CodeContext
static std::string replace_chars (const std::string &S, const std::string &From, const std::string &To)
 replaces every appearance of From with To in S
 

Detailed Description

CppCodeContext is an implementation of CodeContext for C++.

Member Function Documentation

◆ accumulate()

std::string CppCodeContext::accumulate ( const std::string &  name,
const std::string &  value 
)
overridevirtual

Implementation of CodeContext::accumulate()

Implements libint2::CodeContext.

◆ accumulate_binary_expr()

std::string CppCodeContext::accumulate_binary_expr ( const std::string &  name,
const std::string &  left,
const std::string &  oper,
const std::string &  right 
)
overridevirtual

◆ accumulate_ternary_expr()

std::string CppCodeContext::accumulate_ternary_expr ( const std::string &  name,
const std::string &  arg1,
const std::string &  oper1,
const std::string &  arg2,
const std::string &  oper2,
const std::string &  arg3 
)
overridevirtual

accumulate_ternary_expr returns a statement which accumulates ternary expression 'arg1 oper1 arg2 oper2 arg3' to variable 'name'

Implements libint2::CodeContext.

◆ assign()

std::string CppCodeContext::assign ( const std::string &  name,
const std::string &  value 
)
overridevirtual

Implementation of CodeContext::assign()

Implements libint2::CodeContext.

Referenced by decldef().

◆ assign_binary_expr()

std::string CppCodeContext::assign_binary_expr ( const std::string &  name,
const std::string &  left,
const std::string &  oper,
const std::string &  right 
)
overridevirtual

◆ assign_ternary_expr()

std::string CppCodeContext::assign_ternary_expr ( const std::string &  name,
const std::string &  arg1,
const std::string &  oper1,
const std::string &  arg2,
const std::string &  oper2,
const std::string &  arg3 
)
overridevirtual

assign_ternary_expr returns a statement which assigns ternary expression 'arg1 oper1 arg2 oper2 arg3' to variable 'name'

Implements libint2::CodeContext.

◆ close_block()

std::string CppCodeContext::close_block ( ) const
overridevirtual

Implementation of CodeContext::close_block()

Implements libint2::CodeContext.

◆ code_postfix()

std::string CppCodeContext::code_postfix ( ) const
overridevirtual

◆ code_prefix()

std::string CppCodeContext::code_prefix ( ) const
overridevirtual

◆ comment()

std::string CppCodeContext::comment ( const std::string &  statement) const
overridevirtual

Implementation of CodeContext::comment(statement)

Implements libint2::CodeContext.

◆ copyright()

std::string CppCodeContext::copyright ( ) const
overridevirtual

Implementation of CodeContext::copyright()

Implements libint2::CodeContext.

◆ declare()

std::string CppCodeContext::declare ( const std::string &  type,
const std::string &  name 
) const
overridevirtual

Implementation of CodeContext::declare()

Implements libint2::CodeContext.

References end_of_stat().

◆ declare_v()

std::string CppCodeContext::declare_v ( const std::string &  type,
const std::string &  name,
const std::string &  nelem 
) const
overridevirtual

Implementation of CodeContext::declare_v()

Implements libint2::CodeContext.

References end_of_stat().

◆ decldef()

std::string CppCodeContext::decldef ( const std::string &  type,
const std::string &  name,
const std::string &  value 
)
overridevirtual

decldef returns a statement which declares variable named 'name' of type 'type' and defines its value to be 'value'

Implements libint2::CodeContext.

References assign().

◆ end_of_stat()

std::string CppCodeContext::end_of_stat ( ) const
overridevirtual

Implementation of CodeContext::end_of_stat()

Implements libint2::CodeContext.

Referenced by declare(), and declare_v().

◆ for_loop()

SafePtr< ForLoop > CppCodeContext::for_loop ( std::string &  varname,
const SafePtr< Entity > &  less_than,
const SafePtr< Entity > &  start_at 
) const
overridevirtual

Implementation of CodeContext::for_loop()

Implements libint2::CodeContext.

◆ inteval_gen_type_name()

std::string CppCodeContext::inteval_gen_type_name ( ) const
overridevirtual

◆ inteval_spec_type_name()

std::string CppCodeContext::inteval_spec_type_name ( const std::string &  task) const
overridevirtual

◆ inteval_type_name()

std::string CppCodeContext::inteval_type_name ( const std::string &  task) const
overridevirtual

◆ label_to_name()

std::string CppCodeContext::label_to_name ( const std::string &  label) const
overridevirtual

Implementation of CodeContext::label_to_name(label)

Implements libint2::CodeContext.

References libint2::CodeContext::replace_chars().

◆ macro_define() [1/2]

std::string CppCodeContext::macro_define ( const std::string &  name) const
overridevirtual

Implementation of CodeContext::macro_define()

Implements libint2::CodeContext.

◆ macro_define() [2/2]

std::string CppCodeContext::macro_define ( const std::string &  name,
const std::string &  value 
) const
overridevirtual

Implementation of CodeContext::macro_define()

Implements libint2::CodeContext.

◆ macro_endif()

std::string CppCodeContext::macro_endif ( ) const
overridevirtual

Implementation of CodeContext::macro_endif()

Implements libint2::CodeContext.

◆ macro_if()

std::string CppCodeContext::macro_if ( const std::string &  name) const
overridevirtual

Implementation of CodeContext::macro_if()

Implements libint2::CodeContext.

◆ macro_ifdef()

std::string CppCodeContext::macro_ifdef ( const std::string &  name) const
overridevirtual

Implementation of CodeContext::macro_ifdef()

Implements libint2::CodeContext.

◆ open_block()

std::string CppCodeContext::open_block ( ) const
overridevirtual

Implementation of CodeContext::open_block()

Implements libint2::CodeContext.

◆ stack_address()

std::string CppCodeContext::stack_address ( const DGVertex::Address a) const
overridevirtual

Implementation of CodeContext::stack_address()

Implements libint2::CodeContext.

◆ std_function_header()

std::string CppCodeContext::std_function_header ( ) const
overridevirtual

◆ std_header()

std::string CppCodeContext::std_header ( ) const
overridevirtual

Implementation of CodeContext::std_header()

Implements libint2::CodeContext.

◆ value_to_pointer()

std::string CppCodeContext::value_to_pointer ( const std::string &  val) const
overridevirtual

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