typecasting and new generated code (untested)