예제 #1
0
/*
 * DoAutoSave - try to do autosave of current file
 */
void DoAutoSave( void )
{
    char        path[FILENAME_MAX];
    char        path2[FILENAME_MAX];
    char        tmp[FILENAME_MAX];
    bool        quiet;
    FILE        *f;
    vi_rc       rc;
    status_type lastst;

    if( EditVars.AutoSaveInterval == 0 ) {
        return;
    }
    if( clock() < NextAutoSave ) {
        return;
    }
    if( CurrentFile == NULL ) {
        return;
    }
    if( CurrentFile->is_stdio || CurrentFile->viewonly ||
                !CurrentFile->need_autosave ) {
        SetNextAutoSaveTime();
        return;
    }

    MakeTmpPath( path, "" );
    if( !CurrentFile->been_autosaved ) {
        getTmpName( path, CurrentFile->as_name );
    }
    strcat( path, CurrentFile->as_name );

    quiet = EditFlags.Quiet;
    EditFlags.Quiet = TRUE;
    lastst = UpdateCurrentStatus( CSTATUS_AUTOSAVE );
    rc = SaveFile( path, -1, -1, TRUE );
    EditFlags.Quiet = quiet;
    UpdateCurrentStatus( lastst );
    if( rc != ERR_NO_ERR ) {
        SetNextAutoSaveTime();
        return;
    }

    /*
     * update history file
     */
    CurrentFile->need_autosave = FALSE;
    if( !CurrentFile->been_autosaved ) {
        GetCurrentFilePath( path2 );
        CurrentFile->been_autosaved = TRUE;
        MakeTmpPath( tmp, checkFileName );
        f = fopen( tmp, "a" );
        if( f != NULL ) {
            MyFprintf( f, "%s %s\n", path, path2 );
            fclose( f );
        }
    }

    SetNextAutoSaveTime();

} /* DoAutoSave */
예제 #2
0
void output_openOutFile()
//
//  Input:   none
//  Output:  none
//  Purpose: opens a project's binary output file.
//
{
    // --- close output file if already opened
    if (Fout.file != NULL) fclose(Fout.file); 

    // --- else if file name supplied then set file mode to SAVE
    else if (strlen(Fout.name) != 0) Fout.mode = SAVE_FILE;

    // --- otherwise set file mode to SCRATCH & generate a name
    else
    {
        Fout.mode = SCRATCH_FILE;
        getTmpName(Fout.name);
    }

    // --- try to open the file
    if ( (Fout.file = fopen(Fout.name, "w+b")) == NULL)
    {
        writecon(FMT14);
        ErrorCode = ERR_OUT_FILE;
    }
}
예제 #3
0
llvm::Value* UnaryExprAST::codegen() {
  debug_info_helper->emitLocation(getLoc());
  llvm::Value* right_value = right_->codegen();
  CHECK(right_value != nullptr);
  std::string op_str = op_.desc;
  if (op_str == "-") {
    return cur_builder->CreateFNeg(right_value, getTmpName());
  }
  llvm::Function* function = cur_module->getFunction("unary" + op_str);
  if (function != nullptr) {
    CHECK_EQ(1u, function->arg_size());
    std::vector<llvm::Value*> values(1, right_value);
    return cur_builder->CreateCall(function, values, getTmpName());
  }
  LOG(FATAL) << "Unexpected unary operator " << op_str;
  return nullptr;
}
예제 #4
0
llvm::Value* VariableExprAST::codegen() {
  debug_info_helper->emitLocation(getLoc());
  llvm::Value* variable = getVariable(name_);
  if (variable == nullptr) {
    LOG(FATAL) << "Using unassigned variable: " << name_ << ", loc " << getLoc().toString();
  }
  llvm::LoadInst* load_inst = cur_builder->CreateLoad(variable, getTmpName());
  return load_inst;
}
예제 #5
0
llvm::Value* CallExprAST::codegen() {
  debug_info_helper->emitLocation(getLoc());
  llvm::Function* function = cur_module->getFunction(callee_);
  CHECK(function != nullptr);
  CHECK_EQ(function->arg_size(), args_.size());
  std::vector<llvm::Value*> values;
  for (auto& arg : args_) {
    llvm::Value* value = arg->codegen();
    values.push_back(value);
  }
  return cur_builder->CreateCall(function, values, getTmpName());
}
예제 #6
0
파일: rdii.cpp 프로젝트: Geosyntec/SUSTAIN
int openNewRdiiFile()
//
//  Input:   none
//  Output:  returns TRUE if successful, FALSE if not
//  Purpose: opens a new RDII interface file.
//
{
    int j;                             // node index

    // --- create a temporary file name if scratch file being used
    if ( Frdii.mode == SCRATCH_FILE ) getTmpName(Frdii.name);

    // --- open the RDII file as a formatted text file
    Frdii.file = fopen(Frdii.name, "wt");
    if ( Frdii.file == NULL )
    {
        return FALSE;
    }

    // --- initialize the contents of the file with header line,
    //     flow units, RDII time step (sec), number of RDII nodes,
    //     and name of each node 
    fprintf(Frdii.file, "SWMM5 Interface File");
    fprintf(Frdii.file, "\n%s", Title[0]);
    fprintf(Frdii.file, "\n%d - reporting time step in sec", RdiiStep);
    fprintf(Frdii.file, "\n1 - number of constituents as listed below:");
    fprintf(Frdii.file, "\nFLOW %s", FlowUnitWords[FlowUnits]);
    fprintf(Frdii.file, "\n%d - number of nodes as listed below:",
        NumRdiiNodes);
    for (j=0; j<Nobjects[NODE]; j++)
    {
        if ( Node[j].rdiiInflow )
        {
            fprintf(Frdii.file, "\n%s", Node[j].ID);
        }
    }

    // --- write column headings
    fprintf(Frdii.file,"\nNode             Year Mon Day Hr  Min Sec FLOW");
    return TRUE;
}
예제 #7
0
llvm::Value* BinaryExprAST::codegen() {
  debug_info_helper->emitLocation(getLoc());
  llvm::Value* left_value = left_->codegen();
  CHECK(left_value != nullptr);
  llvm::Value* right_value = right_->codegen();
  CHECK(right_value != nullptr);
  llvm::Value* result = nullptr;
  std::string op_str = op_.desc;
  llvm::Function* function = cur_module->getFunction("binary" + op_str);
  if (function != nullptr) {
    CHECK_EQ(2u, function->arg_size());
    std::vector<llvm::Value*> values;
    values.push_back(left_value);
    values.push_back(right_value);
    return cur_builder->CreateCall(function, values, getTmpName());
  }
  if (op_str == "<") {
    result = cur_builder->CreateFCmpOLT(left_value, right_value, getTmpName());
  } else if (op_str == "<=") {
    result = cur_builder->CreateFCmpOLE(left_value, right_value, getTmpName());
  } else if (op_str == "==") {
    result = cur_builder->CreateFCmpOEQ(left_value, right_value, getTmpName());
  } else if (op_str == "!=") {
    result = cur_builder->CreateFCmpONE(left_value, right_value, getTmpName());
  } else if (op_str == ">") {
    result = cur_builder->CreateFCmpOGT(left_value, right_value, getTmpName());
  } else if (op_str == ">=") {
    result = cur_builder->CreateFCmpOGT(left_value, right_value, getTmpName());
  } else if (op_str == "+") {
    result = cur_builder->CreateFAdd(left_value, right_value, getTmpName());
  } else if (op_str == "-") {
    result = cur_builder->CreateFSub(left_value, right_value, getTmpName());
  } else if (op_str == "*") {
    result = cur_builder->CreateFMul(left_value, right_value, getTmpName());
  } else if (op_str == "/") {
    result = cur_builder->CreateFDiv(left_value, right_value, getTmpName());
  } else {
    LOG(FATAL) << "Unexpected binary operator " << op_str;
  }
  result = cur_builder->CreateUIToFP(result, llvm::Type::getDoubleTy(*context));
  return result;
}
예제 #8
0
파일: rain.cpp 프로젝트: Geosyntec/SUSTAIN
void  rain_open(void)
//
//  Input:   none
//  Output:  none
//  Purpose: opens binary rain interface file and RDII processor.
//
{
    int i;
    int count;

    // --- see how many gages get their data from a file
    count = 0;
    for (i = 0; i < Nobjects[GAGE]; i++)
    {
        if ( Gage[i].dataSource == RAIN_FILE ) count++;
    }
    Frain.file = NULL;
    if ( count == 0 )
    {
        Frain.mode = NO_FILE;
    }

    // --- see what kind of rain interface file to open
    else switch ( Frain.mode )
    {
      case SCRATCH_FILE:
        getTmpName(Frain.name);
        if ( (Frain.file = fopen(Frain.name, "w+b")) == NULL)
        {
            report_writeErrorMsg(ERR_RAIN_FILE_SCRATCH, "");
            return;
        }
        break;

      case USE_FILE:
        if ( (Frain.file = fopen(Frain.name, "r+b")) == NULL)
        {
            report_writeErrorMsg(ERR_RAIN_FILE_OPEN, Frain.name);
            return;
        }
        break;

      case SAVE_FILE:
        if ( (Frain.file = fopen(Frain.name, "w+b")) == NULL)
        {
            report_writeErrorMsg(ERR_RAIN_FILE_OPEN, Frain.name);
            return;
        }
        break;
    }

    // --- create new rain file if required
    if ( Frain.mode == SCRATCH_FILE || Frain.mode == SAVE_FILE )
    {
        createRainFile(count);
    }

    // --- initialize rain file
    if ( Frain.mode != NO_FILE ) initRainFile();

    // --- open RDII processor (creates/opens a RDII interface file)
    rdii_openRdii();
}