Ejemplo n.º 1
0
void assembly(void) {	

    switch( get_assembler() ) {
        case OPT_NASM:	nasm(); break;
        case OPT_TASM:	tasm(); break;
        case OPT_TASMX:	tasmx(); break;
        case OPT_TASM32:tasm32(); break;
        case OPT_MASM:	masm(); break;
        case OPT_ML:	ml(); break;
        case OPT_WASM:	wasm(); break;
        case OPT_LASM:	lasm(); break;
        case OPT_LASM32:lasm32(); break;
        default:
            fprintf( stderr, "Unknown assembler, use NASN...\n");
            nasm();
            break;
    }
    if ( !get_option(OPT_KEEPGEN) )
        del_asm_tmpfiles();
}
Ejemplo n.º 2
0
void Builder::operator()(File* file) {
    // Generates the output files for the given source file.  Depending on the
    // options, this function will output the AST, IR, .jgo, or .c file.
    if (file->is_interface_file()) { return; }
    if (env_->errors()) { return; }

    // Generate native machine code, and then compile or assemble it.
    std::string const& source = file->path()->string();
    std::string const& jgo = file->jgo_file();
    if (!env_->make() || !File::is_up_to_date(source, jgo)) {
        File::mkdir(File::dir_name(file->jgo_file()));
        if (env_->verbose()) {
            Stream::stout() << "Compiling " << file->name() << "\n";
            Stream::stout()->flush();
        }
        if (env_->generator() == "Nasm64") {
            irgen(file);
            if (env_->dump_ir()) { return; }
            nasm64gen(file);
            if (!env_->assemble()) { return; }
            nasm(file->asm_file(), file->jgo_file());
        } else if (env_->generator() == "C") {
            cgen(file);
            if (!env_->assemble()) { return; }
            cc(file->jgc_file(), file->jgo_file());
        } else if (env_->generator() == "Intel64") {
            irgen(file);
            if (env_->dump_ir()) { return; }
            if (!env_->assemble()) { return; } 
            intel64gen(file);
        }
    }

    // Compile any native files.  Native files have the same name as the source
    // file, but with a .c extension.
    std::string const& native = file->native_file();
    if (File::is_reg(native)) {
        std::string const& o = file->o_file();
        if (!env_->make() || !File::is_up_to_date(native, o)) {
            cc(file->native_file(), file->o_file());
        }
    }
}