Few good options
The day a mob attacks me is the day I kill an entire mob.
Sure, take your hi-cap plastic and start spraying. You may even come out alive. Then again, you may not. Or you take careful aim and drop the first attacker or two, escaping while the rest scatter. Then what? Better get yourself to the closest police station instantly (do not pass go, do not collect $200) and turn your self in. You will be alive.
However, you will then be in the position of having shot an "innocent man" or two, while the other 18 will be lining up to swear statements that is what you did, without provocation, while they were just standing around minding their own business. A couple dozen eye witnesses vs. you isn't going to go well for you in court.
For those who say stay in the car and "floor it", there is a drawback as well. As mentioned, you are now a hit and run driver, possibly facing vehicular homocide charges. Tempting as it will be to "bust through" the mob, flooring it is a clear panic reaction, and can wind up injuring or killing an actual innocent person. Run down someone on the rear edge of the mob (who had made no threatening actions against you), and you are likely to be found guilty.
And then there is the risk that as you take off at speed, you can lose control of the car, crashing into something, immobilizing your vehicle, and exposing you to the now fully enraged mob's anger. Few good options here.
One better choice might be not to "floor it", but to move off at a steady slow speed (assuming you cannot retreat). Your car will get damaged, maybe alot, but moving through the mob at 5mph and not stopping for any reason seems to make sense to me. Rather than slamming into the mob, just push them out of the way. Very few people will let themselves be run over (especially at slow speed) when they can get out of the way. They may climb on the car, they may break all the windows, and try to pull you out, but this is hard if you do not stop. And once you are clear of the press of bodies, you can speed up to escape the area. Then head to the police.
It isn't an easy thing, and I think of all the movies where a mob surrounds a car, and then rocks it, eventually tipping it over. The all have one thing in common, the driver stops and sits there. It will take a strong act of will to continue to move forward, and not "floor it" to get away, but I think it offers the best chance of both escaping, and proving you are victim.
Turning around and driving away (even if you have to damage your car or other cars to do so) is the preferred option, and will likely be possible, if you become aware of your actual situation soon enough.
The best choice, of course, is the Myagi defense. Careful employment of this ancient oriental wisdom (from the karate kid movie) will avoid many, many problems. "Mr Myagi say, Best defense? NO BE THERE!"