static const char* nominal_name(ast_t* ast) { AST_GET_CHILDREN(ast, package, name, typeargs); ast_t* def = (ast_t*)ast_data(ast); ast_t* pkg = ast_nearest(def, TK_PACKAGE); const char* s = package_symbol(pkg); return build_name(s, ast_name(name), typeargs, false); }
static void type_append(printbuf_t* buf, ast_t* type, bool first) { switch(ast_id(type)) { case TK_UNIONTYPE: { // u3_Arg1_Arg2_Arg3 printbuf(buf, "u%d", ast_childcount(type)); types_append(buf, type); return; } case TK_ISECTTYPE: { // i3_Arg1_Arg2_Arg3 printbuf(buf, "i%d", ast_childcount(type)); types_append(buf, type); return; } case TK_TUPLETYPE: { // t3_Arg1_Arg2_Arg3 printbuf(buf, "t%d", ast_childcount(type)); types_append(buf, type); return; } case TK_NOMINAL: { // pkg_Type[_Arg1_Arg2]_cap AST_GET_CHILDREN(type, package, name, typeargs, cap, eph); ast_t* def = (ast_t*)ast_data(type); ast_t* pkg = ast_nearest(def, TK_PACKAGE); const char* pkg_name = package_symbol(pkg); if(pkg_name != NULL) printbuf(buf, "%s_", pkg_name); printbuf(buf, "%s", ast_name(name)); types_append(buf, typeargs); if(!first) printbuf(buf, "_%s", ast_get_print(cap)); return; } default: {} } assert(0); }