Extract generateCanonicalCode function out.