code gen for function.