bool DSPServer::crossCompileFactory(MHD_Connection* connection, dsp_server_connection_info* info) { dsp_factory* factory; if ((factory = info->crossCompileFactory(this, info->fAnswer))) { fFactories.insert(factory); // Return machine_code to client, and keep the new compiled target, so that is it "cached" #ifdef LLVM_DSP_FACTORY string machine_code = writeDSPFactoryToMachine(dynamic_cast<llvm_dsp_factory*>(factory), info->fTarget); dsp_factory* new_factory = readDSPFactoryFromMachine(machine_code, info->fTarget); #else string machine_code = writeInterpreterDSPFactoryToMachine(dynamic_cast<interpreter_dsp_factory*>(factory)); dsp_factory* new_factory = readInterpreterDSPFactoryFromMachine(machine_code); #endif if (new_factory) { fFactories.insert(new_factory); if (fCreateDSPFactoryCb) { // Possibly call callback fCreateDSPFactoryCb(new_factory, fCreateDSPFactoryCb_arg); } } return sendPage(connection, machine_code, MHD_HTTP_OK, "text/html"); } else { return sendPage(connection, info->fAnswer, MHD_HTTP_BAD_REQUEST, "text/html"); } }
bool DSPServer::crossCompileFactory(MHD_Connection* connection, dsp_server_connection_info* info) { llvm_dsp_factory* factory; if ((factory = info->crossCompileFactory(this, info->fAnswer))) { fFactories.insert(factory); // Return machine_code to client string machine_code = writeDSPFactoryToMachine(factory, info->fTarget); //char* machine_code = writeCDSPFactoryToMachine(factory, info->fTarget.c_str()); // And keep the new compiled target, so that is it "cached" llvm_dsp_factory* new_factory = readDSPFactoryFromMachine(machine_code, info->fTarget); //llvm_dsp_factory* new_factory = readCDSPFactoryFromMachine(machine_code, info->fTarget.c_str()); //freeCDSP(machine_code); // TODO if (new_factory) { fFactories.insert(new_factory); if (fCreateDSPFactoryCb) { // Possibly call callback fCreateDSPFactoryCb(new_factory, fCreateDSPFactoryCb_arg); } } //return sendPage(connection, writeDSPFactoryToMachine(factory, ""), MHD_HTTP_OK, "text/html"); return sendPage(connection, machine_code, MHD_HTTP_OK, "text/html"); } else { return sendPage(connection, info->fAnswer, MHD_HTTP_BAD_REQUEST, "text/html"); } }