changed: SetCommentary() methods from Pattern were moved to PatternParser and Generator

added:   caching functions and blocks
         caching is added into Pattern and Blocks
         methods: CacheFunctions() and CacheBlocks()
		 




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@975 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2014-10-19 05:42:25 +00:00
parent ad2fb11a5c
commit 2fca5f3492
12 changed files with 366 additions and 132 deletions

View File

@@ -112,6 +112,10 @@ public:
void Generate(std::vector<StreamType> & o);
void Generate(std::vector<StreamType*> & o);
void SetCommentary(const char * com_start, const char * com_stop);
void SetCommentary(const std::string & com_start, const std::string & com_stop);
void SetCommentary(const wchar_t * com_start, const wchar_t * com_stop);
void SetCommentary(const std::wstring & com_start, const std::wstring & com_stop);
private:
@@ -215,6 +219,8 @@ private:
// a stack for [for] statements
std::vector<Stack> stack_tab;
std::wstring commentary_start, commentary_stop;
void ResizeFilterTab();
void ResizeStack();
@@ -280,6 +286,7 @@ private:
void WriteTmpStreamToStreams();
void CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg = 0);
void CreateMsg(const wchar_t * type, const wchar_t * arg = 0);
void CreateMsg(const std::wstring & type, const std::wstring & arg);
void CreateMsg(const std::wstring & type);
@@ -398,6 +405,42 @@ Generator<StreamType>::~Generator()
}
template<class StreamType>
void Generator<StreamType>::SetCommentary(const char * com_start, const char * com_stop)
{
PT::UTF8ToWide(com_start, commentary_start);
PT::UTF8ToWide(com_stop, commentary_stop);
}
template<class StreamType>
void Generator<StreamType>::SetCommentary(const std::string & com_start, const std::string & com_stop)
{
PT::UTF8ToWide(com_start, commentary_start);
PT::UTF8ToWide(com_stop, commentary_stop);
}
template<class StreamType>
void Generator<StreamType>::SetCommentary(const wchar_t * com_start, const wchar_t * com_stop)
{
commentary_start = com_start;
commentary_stop = com_stop;
}
template<class StreamType>
void Generator<StreamType>::SetCommentary(const std::wstring & com_start, const std::wstring & com_stop)
{
commentary_start = com_start;
commentary_stop = com_stop;
}
template<class StreamType>
void Generator<StreamType>::SetPattern(Pattern & pattern)
{
@@ -520,7 +563,7 @@ void Generator<StreamType>::ClearStream(StreamType & str)
template<class StreamType>
void Generator<StreamType>::RemoveStackFunData(Stack & s)
{
if( s.fun_data && s.remove )
if( s.fun_data && s.auto_remove )
{
delete s.fun_data;
s.fun_data = 0;
@@ -963,6 +1006,7 @@ std::wstring * variable;
{
// in c++11 we can use std::move here
parameters[i] = item_fun.parameters[i]->par;
item_fun.parameters[i]->par.clear();
}
}
@@ -1200,13 +1244,30 @@ void Generator<StreamType>::WriteTmpStreamToStreams()
template<class StreamType>
void Generator<StreamType>::CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg)
{
out = commentary_start;
out += L"Ezc runtime error: ";
out += type;
if( arg )
{
out += ' ';
out += arg;
}
out += commentary_stop;
}
template<class StreamType>
void Generator<StreamType>::CreateMsg(const wchar_t * type, const wchar_t * arg)
{
if( output_stream )
{
ppattern->CreateMsg(temp_msg, type, arg);
CreateMsg(temp_msg, type, arg);
output_stream->write(temp_msg.c_str(), temp_msg.size());
}
}