diff options
Diffstat (limited to 'gcc/go/gofrontend/runtime.cc')
-rw-r--r-- | gcc/go/gofrontend/runtime.cc | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/gcc/go/gofrontend/runtime.cc b/gcc/go/gofrontend/runtime.cc index a921449..bb30cc1 100644 --- a/gcc/go/gofrontend/runtime.cc +++ b/gcc/go/gofrontend/runtime.cc @@ -438,26 +438,18 @@ Runtime::name_to_code(const std::string& name) { Function code = Runtime::NUMBER_OF_FUNCTIONS; - // Aliases seen in function declaration code. - // TODO(cmang): Add other aliases. - if (name == "new") - code = Runtime::NEW; - else if (name == "close") - code = Runtime::CLOSE; - else if (name == "copy") - code = Runtime::SLICECOPY; - else if (name == "append") - code = Runtime::GROWSLICE; - else if (name == "delete") - code = Runtime::MAPDELETE; - else + // Look through the known names for a match. + for (size_t i = 0; i < Runtime::NUMBER_OF_FUNCTIONS; i++) { - // Look through the known names for a match. - for (size_t i = 0; i < Runtime::NUMBER_OF_FUNCTIONS; i++) - { - if (strcmp(runtime_functions[i].name, name.c_str()) == 0) - code = static_cast<Runtime::Function>(i); - } + const char* runtime_function_name = runtime_functions[i].name; + if (strcmp(runtime_function_name, name.c_str()) == 0) + code = static_cast<Runtime::Function>(i); + // The names in the table have "runtime." prefix. We may be + // called with a name without the prefix. Try matching + // without the prefix as well. + if (strncmp(runtime_function_name, "runtime.", 8) == 0 + && strcmp(runtime_function_name + 8, name.c_str()) == 0) + code = static_cast<Runtime::Function>(i); } return code; } |