MetaCC::Compilation Class Reference

#include <metacc_compilation.h>

Collaboration diagram for MetaCC::Compilation:

Collaboration graph
[legend]
List of all members.

Detailed Description

This is compilation of data parsed from input file.

Todo:
the Compilation class is becoming huge mess. Need to refactor it.

Definition at line 268 of file metacc_compilation.h.

Public Member Functions

 Compilation ()
 Construct compilation object.
void set_output_file_names (const std::string &out_header_filename, const std::string &out_cpp_filename)
 Specify output file names.
bool bitfield_exist (std::string bitfield_name)
 Returns true if bitfield with specified name exist in the compilation.
bool template_exist (std::string template_name)
 Returns true if template with specified name exist in the compilation.
unsigned int patterns_count ()
 Returns total count of patterns currently in the compilation.
Bitfieldget_bitfield (std::string bitfield_name)
 Retrieve bitfield by name.
Templateget_template (std::string template_name)
 Retrieve template by name.
Patternget_pattern (unsigned int pattern_index)
 Retrieve pattern by index (also see patterns_count() function).
CodeSnippetprivate_code ()
 Return reference to std::vector<std::string> containing the code which will be placed in "private:" (private) section of the generated class.
CodeSnippetpublic_code ()
 Return reference to std::vector<std::string> containing the code which will be placed in "public:" (interface) section of the generated class.
CodeSnippetsCollectionerror_code ()
 Return reference to std::vector<std::string> containing the code which will be placed in "case" block which is executed when decoder can't match any pattern (in current domain) with the bytecode stream.
void set_error_block_text_pos (int row, int col)
 Remember row and column where we seen "error"" block in the parser (for error reporting).
void set_class_name (const std::string &class_name)
 Set class name used for code generation.
bool domain_exist (std::string domain_name)
 Find out whether given domain exist in list of domains in this compilation.
std::vector< std::string > & declared_exec_func_names ()
 Returns reference to vector of strings, each describing exec func name declared in the input script.
const std::vector< std::string > & declared_exec_func_names () const
 Returns reference to vector of strings, each describing exec func name declared in the input script (const).
bool declared_exec_func_exist (std::string exec_func_name) const
 Returns true only if given exec func name exist among declared_exec_func()'s.
void add_domain (std::string domain_name, int domain_id=0)
 Add domain name and it's ID.
bool declare (std::string bitfield_name, const Bitfield &bitfld)
 Add new bitfield to the compilation.
bool declare (std::string template_name, const Template &tmpl)
 Add new template to the compilation.
void declare (const Pattern &patt)
 Add new pattern to the compilation.
void expand_templates ()
 Perform pattern expansion for all the patterns/templates combinations.
void prepare_state_table ()
 Prepare state table, based on information from patterns list.
void generate_code_for_domain_table (FILE *stream)
 Generate C code for representing domain start node IDs table.
void generate_code_for_state_table (FILE *stream)
 Generate C code for representing state table as C++ static array.
void generate_code_for_domains (FILE *stream)
 Generate C code for domains support declarations and functions.
void generate_code_for_recognition_step_function (std::string func_name, FILE *stream)
 Generate C code for recognition step function.
void generate_code_for_recognition_function (std::string func_name, std::string step_func_name, FILE *stream)
 Generate C code for recognition function.
void generate_code_for_exec_function (std::string exec_func_name, std::string recognition_func_name, FILE *stream)
 Generate C code for exec() function.
void generate_code ()
 Generate C++ code based on the database information.


Constructor & Destructor Documentation

MetaCC::Compilation::Compilation (  ) 

Construct compilation object.

Definition at line 216 of file metacc_compilation.cpp.


Member Function Documentation

void MetaCC::Compilation::set_output_file_names ( const std::string &  out_header_filename,
const std::string &  out_cpp_filename 
) [inline]

Specify output file names.

Note:
If not specified, or are empty string -- output would go to stdout stream of the process

Definition at line 311 of file metacc_compilation.h.

bool MetaCC::Compilation::bitfield_exist ( std::string  bitfield_name  ) 

Returns true if bitfield with specified name exist in the compilation.

Definition at line 888 of file metacc_compilation.cpp.

Referenced by declare(), and get_bitfield().

bool MetaCC::Compilation::template_exist ( std::string  template_name  ) 

Returns true if template with specified name exist in the compilation.

Definition at line 893 of file metacc_compilation.cpp.

Referenced by declare(), and get_template().

unsigned int MetaCC::Compilation::patterns_count (  ) 

Returns total count of patterns currently in the compilation.

Note:
Can be used as max index with get_pattern() function.

Definition at line 898 of file metacc_compilation.cpp.

Referenced by get_pattern().

Bitfield & MetaCC::Compilation::get_bitfield ( std::string  bitfield_name  ) 

Retrieve bitfield by name.

Definition at line 903 of file metacc_compilation.cpp.

Template & MetaCC::Compilation::get_template ( std::string  template_name  ) 

Retrieve template by name.

Definition at line 909 of file metacc_compilation.cpp.

Pattern & MetaCC::Compilation::get_pattern ( unsigned int  pattern_index  ) 

Retrieve pattern by index (also see patterns_count() function).

Definition at line 915 of file metacc_compilation.cpp.

CodeSnippet& MetaCC::Compilation::private_code (  )  [inline]

Return reference to std::vector<std::string> containing the code which will be placed in "private:" (private) section of the generated class.

Definition at line 338 of file metacc_compilation.h.

CodeSnippet& MetaCC::Compilation::public_code (  )  [inline]

Return reference to std::vector<std::string> containing the code which will be placed in "public:" (interface) section of the generated class.

Definition at line 341 of file metacc_compilation.h.

CodeSnippetsCollection& MetaCC::Compilation::error_code (  )  [inline]

Return reference to std::vector<std::string> containing the code which will be placed in "case" block which is executed when decoder can't match any pattern (in current domain) with the bytecode stream.

Definition at line 344 of file metacc_compilation.h.

void MetaCC::Compilation::set_error_block_text_pos ( int  row,
int  col 
) [inline]

Remember row and column where we seen "error"" block in the parser (for error reporting).

Definition at line 347 of file metacc_compilation.h.

void MetaCC::Compilation::set_class_name ( const std::string &  class_name  )  [inline]

Set class name used for code generation.

Definition at line 354 of file metacc_compilation.h.

Referenced by MetaCC::Parser::Parser().

bool MetaCC::Compilation::domain_exist ( std::string  domain_name  )  [inline]

Find out whether given domain exist in list of domains in this compilation.

Definition at line 357 of file metacc_compilation.h.

std::vector<std::string>& MetaCC::Compilation::declared_exec_func_names (  )  [inline]

Returns reference to vector of strings, each describing exec func name declared in the input script.

Definition at line 367 of file metacc_compilation.h.

Referenced by generate_code().

const std::vector<std::string>& MetaCC::Compilation::declared_exec_func_names (  )  const [inline]

Returns reference to vector of strings, each describing exec func name declared in the input script (const).

Definition at line 373 of file metacc_compilation.h.

bool MetaCC::Compilation::declared_exec_func_exist ( std::string  exec_func_name  )  const [inline]

Returns true only if given exec func name exist among declared_exec_func()'s.

Definition at line 379 of file metacc_compilation.h.

void MetaCC::Compilation::add_domain ( std::string  domain_name,
int  domain_id = 0 
) [inline]

Add domain name and it's ID.

Note:
doesn't check for duplicate entries!

Definition at line 390 of file metacc_compilation.h.

Referenced by Compilation().

bool MetaCC::Compilation::declare ( std::string  bitfield_name,
const Bitfield bitfld 
)

Add new bitfield to the compilation.

If bitfield with the same name already exist in the compilation will return false and NOT add the bitfield, otherwise will return true.

Definition at line 921 of file metacc_compilation.cpp.

bool MetaCC::Compilation::declare ( std::string  template_name,
const Template tmpl 
)

Add new template to the compilation.

If template with the same name already exist in the compilation will return false and NOT add the template, otherwise will return true.

Definition at line 929 of file metacc_compilation.cpp.

void MetaCC::Compilation::declare ( const Pattern patt  ) 

Add new pattern to the compilation.

Definition at line 937 of file metacc_compilation.cpp.

void MetaCC::Compilation::expand_templates (  ) 

Perform pattern expansion for all the patterns/templates combinations.

After running this routine, number of patterns in compilation may increase, and no pattern will contain templates anymore, they all will be replaced by the values. In addition, the {name} tags in all C++ text blocks will be replaced by the corresponding values, so no more such tags will exist.

Definition at line 942 of file metacc_compilation.cpp.

void MetaCC::Compilation::prepare_state_table (  ) 

Prepare state table, based on information from patterns list.

Should be called after expand_templates(). Detects fatal collisions between patterns. Takes into account separation of patterns into domains.

Note:
patterns from different domains, even if similar, won't collide.

Definition at line 328 of file metacc_compilation.cpp.

void MetaCC::Compilation::generate_code_for_domain_table ( FILE *  stream  ) 

Generate C code for representing domain start node IDs table.

Definition at line 588 of file metacc_compilation.cpp.

Referenced by generate_code_for_domains().

void MetaCC::Compilation::generate_code_for_state_table ( FILE *  stream  ) 

Generate C code for representing state table as C++ static array.

Definition at line 600 of file metacc_compilation.cpp.

Referenced by generate_code_for_recognition_step_function().

void MetaCC::Compilation::generate_code_for_domains ( FILE *  stream  ) 

Generate C code for domains support declarations and functions.

Definition at line 631 of file metacc_compilation.cpp.

Referenced by generate_code().

void MetaCC::Compilation::generate_code_for_recognition_step_function ( std::string  func_name,
FILE *  stream 
)

Generate C code for recognition step function.

Definition at line 667 of file metacc_compilation.cpp.

Referenced by generate_code().

void MetaCC::Compilation::generate_code_for_recognition_function ( std::string  func_name,
std::string  step_func_name,
FILE *  stream 
)

Generate C code for recognition function.

Definition at line 688 of file metacc_compilation.cpp.

Referenced by generate_code().

void MetaCC::Compilation::generate_code_for_exec_function ( std::string  exec_func_name,
std::string  recognition_func_name,
FILE *  stream 
)

Generate C code for exec() function.

Definition at line 703 of file metacc_compilation.cpp.

Referenced by generate_code().

void MetaCC::Compilation::generate_code (  ) 

Generate C++ code based on the database information.

Definition at line 754 of file metacc_compilation.cpp.


The documentation for this class was generated from the following files:
Generated on Sat Sep 9 03:50:56 2006 for Openem APIs by  doxygen 1.4.7