SI-7852 for GenBCode

Avoid null checks for "someLiteral".== and SomeModule.==. This has
been implemented in GenICode in #2954.

Introduces a trait to share code between GenICode and GenBCode. This
is just a start, more such refactorings will come quite certainly.