static void reify_one(ast_t** astp, ast_t* typeparam, ast_t* typearg) { ast_t* ast = *astp; ast_t* child = ast_child(ast); while(child != NULL) { reify_one(&child, typeparam, typearg); child = ast_sibling(child); } ast_t* type = ast_type(ast); if(type != NULL) reify_one(&type, typeparam, typearg); switch(ast_id(ast)) { case TK_TYPEPARAMREF: reify_typeparamref(astp, typeparam, typearg); break; case TK_ARROW: reify_arrow(astp); break; default: {} } }
static bool reify_one(ast_t** astp, ast_t* typeparam, ast_t* typearg) { ast_t* ast = *astp; ast_t* type = ast_type(ast); if(type != NULL) reify_one(&type, typeparam, typearg); if(ast_id(ast) == TK_TYPEPARAMREF) return reify_typeparamref(astp, typeparam, typearg); ast_t* child = ast_child(ast); bool flatten = false; while(child != NULL) { flatten |= reify_one(&child, typeparam, typearg); child = ast_sibling(child); } // Flatten type expressions after reifying them. if(flatten) { switch(ast_id(ast)) { case TK_ARROW: { AST_GET_CHILDREN(ast, left, right); ast = viewpoint_type(left, right); if(ast == NULL) return false; if(ast == right) ast = ast_dup(ast); ast_replace(astp, ast); return true; } default: {} } } return false; }