Generate d code