Code generation for functions.