clean up decl creation

this cleans up decl creation a bit so that the "extern"
features can work
it moves rest_of_decl_compilation a bit later
it changes thigns so VAR_DECLs are given special treatment
while functions and types are not
it sets various things properly depending on whether the decl
in question is global