added code gen of global functions