diff options
Diffstat (limited to 'src/asmjs/asmangle.cpp')
-rw-r--r-- | src/asmjs/asmangle.cpp | 96 |
1 files changed, 21 insertions, 75 deletions
diff --git a/src/asmjs/asmangle.cpp b/src/asmjs/asmangle.cpp index 0453139b3..743603023 100644 --- a/src/asmjs/asmangle.cpp +++ b/src/asmjs/asmangle.cpp @@ -17,7 +17,6 @@ #include "asmjs/asmangle.h" #include <assert.h> - namespace wasm { std::string asmangle(std::string name) { @@ -49,10 +48,7 @@ std::string asmangle(std::string name) { break; } default: { - if ( - !(ch >= 'a' && ch <= 'z') && - !(ch >= 'A' && ch <= 'Z') - ) { + if (!(ch >= 'a' && ch <= 'z') && !(ch >= 'A' && ch <= 'Z')) { name = "$" + name.substr(1); mightBeKeyword = false; } @@ -79,10 +75,7 @@ std::string asmangle(std::string name) { break; } default: { - if ( - !(ch >= 'a' && ch <= 'z') && - !(ch >= 'A' && ch <= 'Z') - ) { + if (!(ch >= 'a' && ch <= 'z') && !(ch >= 'A' && ch <= 'Z')) { name = name.substr(0, i) + "_" + name.substr(i + 1); mightBeKeyword = false; } @@ -106,59 +99,36 @@ std::string asmangle(std::string name) { break; } case 'c': { - if ( - name == "case" || - name == "continue" || - name == "catch" || - name == "const" || - name == "class" - ) { + if (name == "case" || name == "continue" || name == "catch" || + name == "const" || name == "class") { goto mangleKeyword; } break; } case 'd': { - if ( - name == "do" || - name == "default" || - name == "debugger" - ) { + if (name == "do" || name == "default" || name == "debugger") { goto mangleKeyword; } break; } case 'e': { - if ( - name == "else" || - name == "enum" || - name == "eval" || // to be sure - name == "export" || - name == "extends" - ) { + if (name == "else" || name == "enum" || name == "eval" || // to be sure + name == "export" || name == "extends") { goto mangleKeyword; } break; } case 'f': { - if ( - name == "for" || - name == "false" || - name == "finally" || - name == "function" - ) { + if (name == "for" || name == "false" || name == "finally" || + name == "function") { goto mangleKeyword; } break; } case 'i': { - if ( - name == "if" || - name == "in" || - name == "import" || - name == "interface" || - name == "implements" || - name == "instanceof" - ) { + if (name == "if" || name == "in" || name == "import" || + name == "interface" || name == "implements" || + name == "instanceof") { goto mangleKeyword; } break; @@ -170,21 +140,14 @@ std::string asmangle(std::string name) { break; } case 'n': { - if ( - name == "new" || - name == "null" - ) { + if (name == "new" || name == "null") { goto mangleKeyword; } break; } case 'p': { - if ( - name == "public" || - name == "package" || - name == "private" || - name == "protected" - ) { + if (name == "public" || name == "package" || name == "private" || + name == "protected") { goto mangleKeyword; } break; @@ -196,41 +159,26 @@ std::string asmangle(std::string name) { break; } case 's': { - if ( - name == "super" || - name == "static" || - name == "switch" - ) { + if (name == "super" || name == "static" || name == "switch") { goto mangleKeyword; } break; } case 't': { - if ( - name == "try" || - name == "this" || - name == "true" || - name == "throw" || - name == "typeof" - ) { + if (name == "try" || name == "this" || name == "true" || + name == "throw" || name == "typeof") { goto mangleKeyword; } break; } case 'v': { - if ( - name == "var" || - name == "void" - ) { + if (name == "var" || name == "void") { goto mangleKeyword; } break; } case 'w': { - if ( - name == "with" || - name == "while" - ) { + if (name == "with" || name == "while") { goto mangleKeyword; } break; @@ -241,9 +189,7 @@ std::string asmangle(std::string name) { } break; } - mangleKeyword: { - name = name + "_"; - } + mangleKeyword : { name = name + "_"; } } } return name; |