visitStaticCall()

in lib/generator.js [2317:2378]


  visitStaticCall(ast, level, env, argHasThrowFunc) {
    assert.equal(ast.left.type, 'static_call');
    if(ast.left.id.type === 'builtin_module') {
      this.visitBuiltinStaticCall(ast, level, env, argHasThrowFunc);
      return;
    }
    this.visitModuleName(ast.left.id);
    this.emit(`.${_format(_name(ast.left.propertyPath[0]))}(`);
    for (let i = 0; i < ast.args.length; i++) {
      const expr = ast.args[i];
      if(expr.yieldArg) {
        this.visitYieldArgs(expr.ast, level, env);
      } else if (expr.needCast) {
        this.emit('dara.ToMap(');
        if (argHasThrowFunc && argHasThrowFunc.get(i)) {
          this.emit(argHasThrowFunc.get(i));
        } else {
          this.visitExpr(expr, level, env);
        }
        this.emit(')');
      } else {
        if ((expr.expectedType.name === 'number' || expr.expectedType.name === 'integer') && expr.inferred.name === 'int32') {
          this.emit(`dara.ToInt(`);
          if (argHasThrowFunc && argHasThrowFunc.get(i)) {
            this.emit(argHasThrowFunc.get(i));
          } else {
            this.visitExpr(expr, level, env, { pointer: true });
          }
          this.emit(`)`);
        } else if (expr.type !== 'number' && (expr.inferred.name === 'number' || expr.inferred.name === 'integer') && expr.expectedType.name === 'int32') {
          this.emit(`dara.ToInt32(`);
          if (argHasThrowFunc && argHasThrowFunc.get(i)) {
            this.emit(argHasThrowFunc.get(i));
          } else {
            this.visitExpr(expr, level, env, { pointer: true });
          }
          this.emit(`)`);
        } else {
          let setFunc;
          if(expr && expr.type === 'call') {
            let dealFunc = this.getVarDealFunc(expr, { pointer: true });
            setFunc = dealFunc && dealFunc(_name(expr.inferred));
          }
          if(setFunc) {
            this.emit(`${setFunc}`);
          }
          if (argHasThrowFunc && argHasThrowFunc.get(i)) {
            this.emit(argHasThrowFunc.get(i));
          } else {
            this.visitExpr(expr, level, env, { pointer: true });
          }
          if(setFunc) {
            this.emit(')');
          }
        } 
      }
      if (i !== ast.args.length - 1) {
        this.emit(', ');
      }
    }
    this.emit(')');
  }