Created
October 23, 2016 08:28
-
-
Save nesteruk/a3ef6f38c0d4231c608095d47124ba1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wstring type_name(const wstring& tlon_type_name) override | |
{ | |
auto it = known_types.find(tlon_type_name); | |
if (it != known_types.end()) | |
return known_types[tlon_type_name]; | |
if (tlon_type_name.length() > 1 && | |
(tlon_type_name[0] == L'u' || tlon_type_name[0] == L'i')) | |
{ | |
try | |
{ | |
auto count = lexical_cast<int>(tlon_type_name.substr(1)); | |
wostringstream buffer; | |
buffer << "integer range "; | |
if (tlon_type_name[0] == L'u') | |
{ | |
// 0 to 2^n | |
buffer << "0 to " << (1 << count); | |
} | |
else | |
{ | |
// -2^(n-1) to 2^(n-1) - 1 | |
buffer << "-" << (1 << (count - 1)) << " to " | |
<< (1 << (count - 1)) - 1; | |
} | |
return buffer.str(); | |
} | |
catch (bad_cast) | |
{ | |
} | |
} | |
// MSVC compiles the function even with the next line uncommented | |
//return tlon_type_name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment