Added addMethod to ClassBuilder.

Should be complete enough to move code from BackwardCompatibility.php