diff options
Diffstat (limited to 'src/codegen/codegen_utils.c')
| -rw-r--r-- | src/codegen/codegen_utils.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/codegen/codegen_utils.c b/src/codegen/codegen_utils.c index fe580bf..3169eba 100644 --- a/src/codegen/codegen_utils.c +++ b/src/codegen/codegen_utils.c @@ -455,15 +455,15 @@ char *infer_type(ParserContext *ctx, ASTNode *node) if (node->type == NODE_EXPR_LITERAL) { - if (node->literal.type_kind == TOK_STRING) + if (node->literal.type_kind == LITERAL_STRING) { - return "string"; + return xstrdup("string"); } - if (node->literal.type_kind == TOK_CHAR) + if (node->literal.type_kind == LITERAL_CHAR) { - return "char"; + return xstrdup("char"); } - if (node->literal.type_kind == 1) + if (node->literal.type_kind == LITERAL_FLOAT) { return "double"; } @@ -519,8 +519,22 @@ char *extract_call_args(const char *args) // Parse original method name from mangled name. const char *parse_original_method_name(const char *mangled) { - const char *last = strrchr(mangled, '_'); - return last ? last + 1 : mangled; + const char *sep = strstr(mangled, "__"); + if (!sep) + { + return mangled; + } + + // Let's iterate to find the last `__`. + const char *last_double = NULL; + const char *p = mangled; + while ((p = strstr(p, "__"))) + { + last_double = p; + p += 2; + } + + return last_double ? last_double + 2 : mangled; } // Replace string type in arguments. |
