eachYieldFunc()

in lib/generator.js [4015:4048]


  eachYieldFunc(ast, level) {
    const env = {
      local: new Map(),
      returnType: {
        name: 'void'
      },
      hasThrow: false,
      yieldFunc: true,
      pointerParams: ast.pointerParams,
    };
    
    this.emit(`func ${ast.name}(`, level);
    for(let i = 0; i < ast.args.length; i++) {
      const arg = ast.args[i];
      if (arg.name === '_yieldErr chan error') {
        env.hasThrow = true;
      }
      this.emit(arg.name);
      if(arg.type) {
        this.emit(` `);
        if(!arg.variable) {
          this.visitPointerType(arg.type, level, env);
        } else {
          this.visitType(arg.type, level, env);
        }
      }
      if(i !== ast.args.length - 1){
        this.emit(', ');
      }
    }
    this.emit(') {\n');
    
    this.visitStmts(ast.functionBody.stmts, level + 1, env);
    this.emit(`}\n`, level);