I have no expeirence with this, but here goes.
I would suggest drawing a pattern of the gun's outlined shape, then pin and copy the pattern on to the top of the slab. If foam is hard enough, use a coping saw to cut out the outline of the gun, leaving you with a general gun shape. From there, pencil in the details of the weapon onto the foam and commence shaving, wittling, and sanding down the foam to get the accuracy you want. All that's left is to paint it black and customize it.
Mind you, I have absolutely NO experience when it comes to this, so this is just the basics of the basics. Please consult with other people here before commencing to see if there are easier and more accurate ways to do this.
A phrase every bad-ass should live by.