void linkModules(llvm::Module* dst, const Module_vector& MV) { if (MV.empty()) return; llvm::Linker linker("ldc", dst); std::string err; for (Module_vector::const_iterator i=MV.begin(); i!=MV.end(); ++i) { if (!linker.LinkInModule(*i, &err)) { error("%s", err.c_str()); fatal(); } } }
llvm::Module* Compiler::compile(const std::string& program_) { std::string header(OPENCL_STDHEADER); std::string prf = header + program_; llvm::MemoryBuffer* bufptr = llvm::MemoryBuffer::getMemBuffer(prf); clang::FrontendOptions& frontend = clang_->getFrontendOpts(); frontend.Inputs.push_back( std::make_pair(clang::IK_OpenCL, "_tmp.cl")); clang::PreprocessorOptions& preprocessor = clang_->getPreprocessorOpts(); preprocessor.addRemappedFile("_tmp.cl", bufptr); clang::CodeGenAction* action = new clang::EmitLLVMOnlyAction(); if (clang_->ExecuteAction(*action)) { llvm::Module* result = action->takeModule(); // now, link in the stdlib. llvm::Linker linker("program", result); bool native; llvm::sys::Path mypath; mypath.set("stdlib.bc"); //Linker returns false on success. if (!linker.LinkInFile(mypath, native)) { result = linker.releaseModule(); } else { //Error in linking. std::cerr << "Error linking module." << std::endl; } return result; } return 0; }
int main() { int length=3; bool hi; ifstream arr[7], input; ofstream out("output"); arr[0].open("jen.txt"); arr[1].open("mary.txt"); arr[2].open("nappier.txt"); arr[3].open("you"); arr[4].open("us"); arr[5].open("what'sup"); hi=linker( arr, out, length); out.close(); arr[0].close(); arr[1].close(); arr[2].close(); arr[3].close(); arr[4].close(); arr[5].close(); }
void common_compile ( intrusive_ptr<matchable_ex<BidiIter> const> const ®ex , regex_impl<BidiIter> &impl , Traits const &traits ) { typedef typename iterator_value<BidiIter>::type char_type; // "link" the regex xpression_linker<char_type> linker(traits); regex->link(linker); // "peek" into the compiled regex to see if there are optimization opportunities hash_peek_bitset<char_type> bset; xpression_peeker<char_type> peeker(bset, traits); regex->peek(peeker); // optimization: get the peek chars OR the boyer-moore search string impl.finder_ = optimize_regex<BidiIter>(peeker, traits, is_random<BidiIter>()); impl.xpr_ = regex; }
bool link() { std::map< std::string, ref<VLXStructure> > link_map; // map all the IDs to the appropriate VLXStructures VLXVisitorLinkMapper link_mapper(&link_map); for(size_t i=0; i<mModules.size(); ++i) mModules[i]->acceptVisitor(&link_mapper); if (link_mapper.error()) return false; // link all the IDs to the associated VLXStructure VLXVisitorLinker linker(&link_map); for(size_t i=0; i<mModules.size(); ++i) mModules[i]->acceptVisitor(&linker); if (linker.error()) return false; return true; }
void drill_view::init() { // Load dependencies compiler = require<drill::compiler>(); linker = require<drill::linker>(); transform = require<drill::transform>(); material = require<drill::material>(); // Load model wf_reader.load_from_file(model_path); object = wf_reader.to_object(); c_object = compiler().compile(object); // Load texture png_reader.load_from_file(texture_path); texture = png_reader.to_texture(); c_texture = material().compile_texture(texture); // Init shaders c_program = linker().begin() .include(transform()) .include(material()) .create(); }
void RecordList::link(int mote, int reboot) { search_for_matching_records(mote, reboot); sdc::RecordLinker linker(sdc::time_to_filename().c_str()); const sdc::RecordInfo recinfo = scout->find_recordinfo(sdc::RecordID(mote, reboot)); uint boot_utc = 0; // TODO Why isn't it time_t if (recinfo.date_recorded().size()>0) { QDateTime booted = stdDate2QDate(recinfo.date_recorded().c_str()); boot_utc = booted.toUTC().toTime_t(); } linker.set_reference_boot_time(boot_utc); std::string length = recinfo.length(); linker.write_participant(mote, reboot, length, boot_utc, 0, 0); for (int i=0; i<matching_records->size(); ++i) { const RecordLine& r = matching_records->at(i); std::string len = r.length().toStdString(); boot_utc = 0; if (!r.recorded().isNull()) { boot_utc = r.recorded().toUTC().toTime_t(); } TimeSyncData sync = matching_timesync_data->at(i); linker.write_participant(r.mote_id(), r.record_id(), len, boot_utc, sync.get_skew_1(), sync.get_offset()); } linker.write_record_header(); linker.write_record(mote, reboot, 0, 0); for (int i=0; i<matching_records->size(); ++i) { const RecordLine& r = matching_records->at(i); TimeSyncData sync = matching_timesync_data->at(i); linker.write_record(r.mote_id(), r.record_id(), sync.get_skew_1(), sync.get_offset()); } }
/* ******************************* */ int main(int argc, char *argv[]) { /* ******************************* */ // standard counter int32 i; // check if the parameter exist otherwise print help and exit if(argc < 2) { printf("no class file name given\n"); return -1; } // check if the given filename exist char * filename = argv[1]; if(!fopen(filename,"r")) { printf("no class file found\n"); return -1; } // bootstrap class loader bootstrap_cache_load(); // should be threaded // NCC = native class count STACK * ncl_list; ncl_list = (STACK *) mmalloc(sizeof(STACK)); stack_init(ncl_list, sizeof(CLASS)); for(i = 0; i < NCC; i++) { CLASS * clc = load_class(ncs[i].name); STACK_ELEM * stack_elem; stack_elem = (STACK_ELEM *) mmalloc(sizeof(STACK_ELEM)); stack_elem->data = clc; stack_push(ncl_list,stack_elem); } // user defined class loader CLASS * cl = load_class(argv[1]); // link class file /** * Verification: ensures the correctness of the imported type * Preparation: allocates memory for class variables and initializing the memory to default values * Resolution: transforms symbolic references from the type into direct references. */ linker(cl); /* cache the result of parsing and linking */ //cache(); // starting the main interprer process MACHINE * vm; vm = (MACHINE *) mmalloc(sizeof(MACHINE)); virtual_machine_init(vm); stack_init(vm->native_ms, sizeof(CLASS)); virtual_machine_exec(vm,cl); /* memory cleanup */ virtual_machine_destroy(vm); stack_destroy(ncl_list); class_destroy(cl); /* always return zero at the end */ return 0; }