Code generation based on dynamic models