add codegen for foreach statement