V4 IR: change IR printing to use a visitor.

This allows for overriding methods to customize the printing of nodes.
It also removes some duplicate code.

Change-Id: Ieb9eec2fa7d4e211932d7772586a1d62b119a90a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
V4: replace debug macro by compile time constant.

By having all code "enabled" all the time, it will be checked by the
compiler and visible for refactoring. The compiler will optimize it away
when debugging is turned off.

Also fixes the code where previous refactoring changes were not applied.

Change-Id: I634ac85570125b533adce93ca347c4be3d60aa83
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>