| 1733 | } |
| 1734 | |
| 1735 | static void cs_process_function_like(CSLSPContext *ctx, TSNode node) { |
| 1736 | const char *kind = ts_node_type(node); |
| 1737 | bool is_method = (strcmp(kind, "method_declaration") == 0 || |
| 1738 | strcmp(kind, "local_function_statement") == 0); |
| 1739 | bool is_ctor = strcmp(kind, "constructor_declaration") == 0; |
| 1740 | bool is_dtor = strcmp(kind, "destructor_declaration") == 0; |
| 1741 | bool is_property = strcmp(kind, "property_declaration") == 0; |
| 1742 | bool is_indexer = strcmp(kind, "indexer_declaration") == 0; |
| 1743 | bool is_op = strcmp(kind, "operator_declaration") == 0 || |
| 1744 | strcmp(kind, "conversion_operator_declaration") == 0; |
| 1745 | |
| 1746 | CBMScope *saved_scope = ctx->current_scope; |
| 1747 | const char *saved_func = ctx->enclosing_func_qn; |
| 1748 | const char **saved_tp = ctx->type_param_names; |
| 1749 | const CBMType **saved_tp_args = ctx->type_param_args; |
| 1750 | int saved_tp_count = ctx->type_param_count; |
| 1751 | |
| 1752 | ctx->current_scope = cbm_scope_push(ctx->arena, ctx->current_scope); |
| 1753 | |
| 1754 | /* Determine func short name + QN. */ |
| 1755 | const char *short_name = NULL; |
| 1756 | if (is_method) { |
| 1757 | TSNode nm = ts_node_child_by_field_name(node, "name", 4); |
| 1758 | if (!ts_node_is_null(nm)) short_name = cs_node_text(ctx, nm); |
| 1759 | } else if (is_ctor) { |
| 1760 | short_name = ".ctor"; |
| 1761 | } else if (is_dtor) { |
| 1762 | short_name = ".dtor"; |
| 1763 | } else if (is_property) { |
| 1764 | TSNode nm = ts_node_child_by_field_name(node, "name", 4); |
| 1765 | if (!ts_node_is_null(nm)) short_name = cs_node_text(ctx, nm); |
| 1766 | } else if (is_indexer) { |
| 1767 | short_name = "this[]"; |
| 1768 | } else if (is_op) { |
| 1769 | TSNode op = ts_node_child_by_field_name(node, "operator", 8); |
| 1770 | if (!ts_node_is_null(op)) short_name = cs_node_text(ctx, op); |
| 1771 | } |
| 1772 | |
| 1773 | if (short_name) { |
| 1774 | if (ctx->enclosing_class_qn) { |
| 1775 | ctx->enclosing_func_qn = |
| 1776 | cbm_arena_sprintf(ctx->arena, "%s.%s", ctx->enclosing_class_qn, short_name); |
| 1777 | } else if (ctx->module_qn) { |
| 1778 | ctx->enclosing_func_qn = |
| 1779 | cbm_arena_sprintf(ctx->arena, "%s.%s", ctx->module_qn, short_name); |
| 1780 | } else { |
| 1781 | ctx->enclosing_func_qn = cbm_arena_strdup(ctx->arena, short_name); |
| 1782 | } |
| 1783 | } |
| 1784 | |
| 1785 | /* Collect generic type parameters. */ |
| 1786 | if (is_method) { |
| 1787 | const char **tp_names = NULL; |
| 1788 | int tp_count = 0; |
| 1789 | cs_collect_type_params(ctx, node, &tp_names, &tp_count); |
| 1790 | if (tp_count > 0) { |
| 1791 | const CBMType **args = |
| 1792 | (const CBMType **)cbm_arena_alloc(ctx->arena, |
no test coverage detected