"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/binvar.cc" between
ragel-7.0.0.11.tar.gz and ragel-7.0.0.12.tar.gz

About: Ragel compiles executable finite state machines from regular languages (C, C++, Obj-C, C#, D, Java, Go and Ruby). Development version.

binvar.cc  (ragel-7.0.0.11):binvar.cc  (ragel-7.0.0.12)
skipping to change at line 31 skipping to change at line 31
*/ */
#include "binvar.h" #include "binvar.h"
#include "parsedata.h" #include "parsedata.h"
#include "inputdata.h" #include "inputdata.h"
void BinVar::LOCATE_TRANS() void BinVar::LOCATE_TRANS()
{ {
out << out <<
" " << keys << " = " << OFFSET( ARR_REF( transKeys ), ARR_R EF( keyOffsets ) + "[" + vCS() + "]" ) << ";\n" " " << keys << " = " << OFFSET( ARR_REF( transKeys ), ARR_R EF( keyOffsets ) + "[" + vCS() + "]" ) << ";\n"
" " << trans << " = " << CAST( UINT() ) << ARR_REF( indexOf " " << trans << " = " << CAST(UINT()) << ARR_REF( indexOffs
fsets ) << "[" << vCS() << "];\n" ets ) << "[" << vCS() << "];\n"
" _have = 0;\n"
"\n" "\n"
" " << klen << " = " << CAST( "int" ) << ARR_REF( singleLen s ) << "[" << vCS() << "];\n" " " << klen << " = " << CAST( "int" ) << ARR_REF( singleLen s ) << "[" << vCS() << "];\n"
" " << have << " = 0;\n"
" if ( " << klen << " > 0 ) {\n" " if ( " << klen << " > 0 ) {\n"
" " << INDEX( ALPH_TYPE(), "_lower" ) << " = " << k eys << ";\n" " " << INDEX( ALPH_TYPE(), "_lower" ) << " = " << k eys << ";\n"
" " << INDEX( ALPH_TYPE(), "_upper" ) << " = " << k eys << " + " << klen << " - 1;\n" " " << INDEX( ALPH_TYPE(), "_upper" ) << " = " << k eys << " + " << klen << " - 1;\n"
" " << INDEX( ALPH_TYPE(), "_mid" ) << ";\n" " " << INDEX( ALPH_TYPE(), "_mid" ) << ";\n"
" while ( _upper >= _lower && _have == 0 ) {\n" " _bsc = 1;\n"
" while ( _bsc == 1 ) {\n"
" if ( _upper < _lower ) {\n"
" " << keys << " += " << klen << ";
\n"
" " << trans << " += " << CAST( UIN
T() ) << "" << klen << ";\n"
" _bsc = 0;\n"
" }\n"
" else {\n"
" _mid = _lower + ((_upper-_lower) >> 1);\n " " _mid = _lower + ((_upper-_lower) >> 1);\n "
" if ( " << GET_KEY() << " < " << DEREF( AR R_REF( transKeys ), "_mid" ) << " )\n" " if ( " << GET_KEY() << " < " << DEREF( AR R_REF( transKeys ), "_mid" ) << " )\n"
" _upper = _mid - 1;\n" " _upper = _mid - 1;\n"
" else if ( " << GET_KEY() << " > " << DERE F( ARR_REF( transKeys ), "_mid" ) << " )\n" " else if ( " << GET_KEY() << " > " << DERE F( ARR_REF( transKeys ), "_mid" ) << " )\n"
" _lower = _mid + 1;\n" " _lower = _mid + 1;\n"
" else {\n" " else {\n"
" " << have << " = 1;\n"
" " << trans << " += " << CAST( UIN T() ) << "(_mid - " << keys << ");\n" " " << trans << " += " << CAST( UIN T() ) << "(_mid - " << keys << ");\n"
" _have = 1;\n" " _bsc = 0;\n"
" }\n"
" }\n" " }\n"
" }\n"
" if ( _have == 0 ) {\n"
" " << keys << " += " << klen << ";\n"
" " << trans << " += " << CAST( UINT() ) <<
"" << klen << ";\n"
" }\n" " }\n"
" }\n" " }\n"
"\n" "\n"
" if ( _have == 0 ) {\n" " " << klen << " = " << CAST("int") << ARR_REF( rangeLens )
" " << klen << " = " << CAST( "int" ) << ARR_REF( rangeLens << "[" << vCS() << "];\n"
) << "[" << vCS() << "];\n" " if ( " << have << " == 0 && " << klen << " > 0 ) {\n"
" if ( " << klen << " > 0 ) {\n" " " << INDEX( ALPH_TYPE(), "_lower" ) << " = " << k
" " << INDEX ( ALPH_TYPE(), "_lower" ) << " = " << eys << ";\n"
keys << ";\n" " " << INDEX( ALPH_TYPE(), "_upper" ) << " = " << k
" " << INDEX ( ALPH_TYPE(), "_mid" ) << ";\n" eys << " + (" << klen << "<<1) - 2;\n"
" " << INDEX ( ALPH_TYPE(), "_upper" ) << " = " << " " << INDEX( ALPH_TYPE(), "_mid" ) << ";\n"
keys << " + (" << klen << "<<1) - 2;\n" " _bsc = 1;\n"
" while ( _have == 0 && _lower <= _upper ) {\n" " while ( _bsc == 1 ) {\n"
" if ( _upper < _lower ) {\n"
" " << trans << " += " << CAST( UIN
T() ) << "" << klen << ";\n"
" _bsc = 0;\n"
" }\n"
" else {\n"
" _mid = _lower + (((_upper-_lower) >> 1) & ~1);\n" " _mid = _lower + (((_upper-_lower) >> 1) & ~1);\n"
" if ( " << GET_KEY() << " < " << DEREF( AR R_REF( transKeys ), "_mid" ) << " )\n" " if ( " << GET_KEY() << " < " << DEREF( AR R_REF( transKeys ), "_mid" ) << " )\n"
" _upper = _mid - 2;\n" " _upper = _mid - 2;\n"
" else if ( " << GET_KEY() << " > " << DERE F( ARR_REF( transKeys ), "_mid + 1" ) << " )\n" " else if ( " << GET_KEY() << " > " << DERE F( ARR_REF( transKeys ), "_mid + 1" ) << " )\n"
" _lower = _mid + 2;\n" " _lower = _mid + 2;\n"
" else {\n" " else {\n"
" " << trans << " += " << CAST( UIN T() ) << "((_mid - " << keys << ")>>1);\n" " " << trans << " += " << CAST( UIN T() ) << "((_mid - " << keys << ")>>1);\n"
" _have = 1;\n" " _bsc = 0;\n"
" }\n" " }\n"
" }\n"
" if ( _have == 0 )\n"
" " << trans << " += " << CAST( UINT() ) <<
"" << klen << ";\n"
" }\n"
" }\n"
"\n";
if ( red->condSpaceList.length() > 0 )
LOCATE_COND();
}
void BinVar::COND_BIN_SEARCH( Variable &var, TableArray &keys, std::string ok, s
td::string error )
{
out <<
" {\n"
" " << INDEX( ARR_TYPE( keys ), "_lower" ) << ";\n"
" " << INDEX( ARR_TYPE( keys ), "_mid" ) << ";\n"
" " << INDEX( ARR_TYPE( keys ), "_upper" ) << ";\n"
" _lower = " << var << ";\n"
" _upper = " << var << " + " << klen << " - 1;\n"
" while ( _have == 0 && _lower <= _upper ) {\n"
" _mid = _lower + ((_upper-_lower) >> 1);\n
"
" if ( " << cpc << " < " << CAST( "int" ) <
< DEREF( ARR_REF( keys ), "_mid" ) << " )\n"
" _upper = _mid - 1;\n"
" else if ( " << cpc << " > " << CAST("int"
) << DEREF( ARR_REF( keys ), "_mid" ) << " )\n"
" _lower = _mid + 1;\n"
" else {\n"
" " << ok <<
" _have = 1;\n"
" }\n" " }\n"
" }\n" " }\n"
" if ( _have == 0 ) {\n"
" " << vCS() << " = " << ERROR_STATE() << "
;\n"
" _cont = 0;\n"
" }\n"
" }\n" " }\n"
; "\n";
} }
void BinVar::LOCATE_COND() void BinVar::LOCATE_COND()
{ {
out << if ( red->condSpaceList.length() > 0 ) {
" " << ckeys << " = " << OFFSET( ARR_REF( condKeys ), ARR_R std::stringstream success, error;
EF( transOffsets ) + "[" + string(trans) + "]" ) << ";\n"
" " << klen << " = " << CAST( "int" ) << ARR_REF( transLeng
ths ) << "[" << trans << "];\n"
" " << cond << " = " << CAST( UINT() ) << ARR_REF( transOff
sets ) << "[" << trans << "];\n"
" _have = 0;\n"
"\n";
out <<
" " << cpc << " = 0;\n";
if ( red->condSpaceList.length() > 0 )
COND_EXEC( ARR_REF( transCondSpaces ) + "[" + string(trans) + "]"
);
COND_BIN_SEARCH( ckeys, condKeys, out <<
string(cond) + " += " + CAST( UINT() ) + "(_mid - " + str " " << ckeys << " = " << OFFSET( ARR_REF( condKeys
ing(ckeys) + ");\n", ), ARR_REF( transOffsets ) + "[" + string(trans) + "]" ) << ";\n"
"" " " << klen << " = " << CAST( "int" ) << ARR_REF( t
); ransLengths ) << "[" << trans << "];\n"
" " << cond << " = " << CAST( UINT() ) << ARR_REF(
outLabelUsed = true; transOffsets ) << "[" << trans << "];\n"
"\n";
out <<
" " << cpc << " = 0;\n";
if ( red->condSpaceList.length() > 0 )
COND_EXEC( ARR_REF( transCondSpaces ) + "[" + string(tran
s) + "]" );
success <<
cond << " += " << CAST( UINT() ) << "(_mid - " << ckeys <
< ");\n";
error <<
cond << " = " << errCondOffset << ";\n";
out <<
" {\n"
" " << INDEX( ARR_TYPE( condKeys ), "_lower
" ) << " = " << ckeys << ";\n"
" " << INDEX( ARR_TYPE( condKeys ), "_upper
" ) << " = " << ckeys << " + " << klen << " - 1;\n"
" " << INDEX( ARR_TYPE( condKeys ), "_mid"
) << ";\n"
" _bsc = 1;\n"
" while ( _bsc == 1 ) {\n"
" if ( _upper < _lower ) {\n"
" " << error.str() << "\n"
" _bsc = 0;\n"
" }\n"
" else {\n"
" _mid = _lower + ((_upper-_lower)
>> 1);\n"
" if ( " << cpc << " < " << CAST("i
nt") << DEREF( ARR_REF( condKeys ), "_mid" ) << " )\n"
" _upper = _mid - 1;\n"
" else if ( " << cpc << " > " << CA
ST( "int" ) << DEREF( ARR_REF( condKeys ), "_mid" ) << " )\n"
" _lower = _mid + 1;\n"
" else {\n"
" " << success.str() << "\n
"
" _bsc = 0;\n"
" }\n"
" }\n"
" }\n"
" }\n"
;
}
} }
 End of changes. 13 change blocks. 
84 lines changed or deleted 92 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)