Add framework of codegen.
Fix bug for code generationg, waiting for further development.