qapi-visit: Fix generated code when schema has forward refs