void Value::deepDump(PrintStream& out) const { out.print(m_type, " ", *this, " = ", m_opcode); out.print("("); CommaPrinter comma; for (Value* child : children()) out.print(comma, pointerDump(child)); if (m_origin) out.print(comma, m_origin); { StringPrintStream stringOut; dumpMeta(stringOut); CString string = stringOut.toCString(); if (string.length()) out.print(comma, string); } { CString string = toCString(effects()); if (string.length()) out.print(comma, string); } out.print(")"); }
bool run() { ASSERT(m_graph.m_form == SSA); // Liveness is a backwards analysis; the roots are the blocks that // end in a terminal (Return/Throw/ThrowReferenceError). For now, we // use a fixpoint formulation since liveness is a rapid analysis with // convergence guaranteed after O(connectivity). // Start by assuming that everything is dead. for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) { BasicBlock* block = m_graph.block(blockIndex); if (!block) continue; block->ssa->liveAtHead.clear(); block->ssa->liveAtTail.clear(); } do { m_changed = false; for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) process(blockIndex); } while (m_changed); if (!m_graph.block(0)->ssa->liveAtHead.isEmpty()) { DFG_CRASH( m_graph, nullptr, toCString( "Bad liveness analysis result: live at root is not empty: ", nodeListDump(m_graph.block(0)->ssa->liveAtHead)).data()); } return true; }
OsFile& OsFile::operator <<(float value) { char buf[128]; toCString(value, buf, lengthOf(buf), 7); write(buf, stringLength(buf)); return *this; }
/* * Constructs a SegmentMeta object from a given sequence identifier * Returns TRUE if the sequence identifier could successfully be parsed * and FALSE otherwise. */ bool parseMetaInformation(SegmentMeta& segMeta, seqan::CharString const & idString) { std::stringstream s(std::string(toCString(idString))); std::string text; // (1) Parse the gene name if (!std::getline(s, text, '|')) return false; segMeta.geneName = text; // (2) Parse the segment type if (!std::getline(s, text, '|')) return false; segMeta.segType = text; // (3) Parse the segment id if (!std::getline(s, text, '|')) return false; segMeta.segId = text; // (4) Parse the allel if (!std::getline(s, text, '|')) return false; segMeta.allel = text; // (5) Parse the motif position if (!std::getline(s, text, '|')) return false; char *t = new char[text.size()+1]; std::strcpy(t, text.c_str()); segMeta.motifPos = static_cast<unsigned>(std::atoi(t)); delete[] t; return true; }
OsFile& OsFile::operator <<(u32 value) { char buf[20]; toCString(value, buf, lengthOf(buf)); write(buf, stringLength(buf)); return *this; }
void JsonSerializer::serializeArrayItem(int64_t value) { writeBlockComma(); char tmp[30]; toCString(value, tmp, 30); m_file.write(tmp, (int32_t)strlen(tmp)); m_is_first_in_block = false; }
void JsonSerializer::serializeArrayItem(float value) { writeBlockComma(); char tmp[20]; toCString(value, tmp, 20, 8); m_file.write(tmp, stringLength(tmp)); m_is_first_in_block = false; }
void JIT::privateCompileClosureCall(CallLinkInfo* callLinkInfo, CodeBlock* calleeCodeBlock, Structure* expectedStructure, ExecutableBase* expectedExecutable, MacroAssemblerCodePtr codePtr) { JumpList slowCases; slowCases.append(branch32(NotEqual, regT1, TrustedImm32(JSValue::CellTag))); slowCases.append(branchPtr(NotEqual, Address(regT0, JSCell::structureOffset()), TrustedImmPtr(expectedStructure))); slowCases.append(branchPtr(NotEqual, Address(regT0, JSFunction::offsetOfExecutable()), TrustedImmPtr(expectedExecutable))); loadPtr(Address(regT0, JSFunction::offsetOfScopeChain()), regT1); emitPutCellToCallFrameHeader(regT1, JSStack::ScopeChain); Call call = nearCall(); Jump done = jump(); slowCases.link(this); move(TrustedImmPtr(callLinkInfo->callReturnLocation.executableAddress()), regT2); restoreReturnAddressBeforeReturn(regT2); Jump slow = jump(); LinkBuffer patchBuffer(*m_vm, this, m_codeBlock); patchBuffer.link(call, FunctionPtr(codePtr.executableAddress())); patchBuffer.link(done, callLinkInfo->hotPathOther.labelAtOffset(0)); patchBuffer.link(slow, CodeLocationLabel(m_vm->getCTIStub(virtualCallThunkGenerator).code())); RefPtr<ClosureCallStubRoutine> stubRoutine = adoptRef(new ClosureCallStubRoutine( FINALIZE_CODE( patchBuffer, ("Baseline closure call stub for %s, return point %p, target %p (%s)", toCString(*m_codeBlock).data(), callLinkInfo->hotPathOther.labelAtOffset(0).executableAddress(), codePtr.executableAddress(), toCString(pointerDump(calleeCodeBlock)).data())), *m_vm, m_codeBlock->ownerExecutable(), expectedStructure, expectedExecutable, callLinkInfo->codeOrigin)); RepatchBuffer repatchBuffer(m_codeBlock); repatchBuffer.replaceWithJump( RepatchBuffer::startOfBranchPtrWithPatchOnRegister(callLinkInfo->hotPathBegin), CodeLocationLabel(stubRoutine->code().code())); repatchBuffer.relink(callLinkInfo->callReturnLocation, m_vm->getCTIStub(virtualCallThunkGenerator).code()); callLinkInfo->stub = stubRoutine.release(); }
/* * convert Tizen style string form a V8 String<br> * if failed then return null.<br> * * caller must free */ Tizen::Base::String* Util::toTizenStringN(const v8::Local<v8::String>& value) { if ( value->Length() == 0 ) { return new Tizen::Base::String(); } v8::String::Utf8Value v8utfstr( value->ToObject() ); const char *pValue = toCString( v8utfstr ); return new Tizen::Base::String( pValue ); }
// from: https://github.com/v8/v8-git-mirror/blob/master/samples/shell.cc // v3.15 from: https://chromium.googlesource.com/v8/v8.git/+/3.14.5.9/samples/shell.cc void reportException(v8::TryCatch* _tryCatch) { v8::HandleScope handle_scope; v8::String::Utf8Value exception(_tryCatch->Exception()); char const* exceptionString = toCString(exception); v8::Handle<v8::Message> message = _tryCatch->Message(); // V8 didn't provide any extra information about this error; just // print the exception. if (message.IsEmpty()) printf("%s\n", exceptionString); else { // Print (filename):(line number): (message). v8::String::Utf8Value filename(message->GetScriptResourceName()); char const* filenameString = toCString(filename); int linenum = message->GetLineNumber(); printf("%s:%i: %s\n", filenameString, linenum, exceptionString); // Print line of source code. v8::String::Utf8Value sourceline(message->GetSourceLine()); char const* sourcelineString = toCString(sourceline); printf("%s\n", sourcelineString); // Print wavy underline (GetUnderline is deprecated). int start = message->GetStartColumn(); for (int i = 0; i < start; i++) printf(" "); int end = message->GetEndColumn(); for (int i = start; i < end; i++) printf("^"); printf("\n"); v8::String::Utf8Value stackTrace(_tryCatch->StackTrace()); if (stackTrace.length() > 0) { char const* stackTraceString = toCString(stackTrace); printf("%s\n", stackTraceString); } } }
void JsonSerializer::serialize(const char* label, unsigned int value) { writeBlockComma(); char tmp[20]; writeString(label); toCString(value, tmp, 20); m_file.write(" : ", stringLength(" : ")); m_file.write(tmp, stringLength(tmp)); m_is_first_in_block = false; }
void JsonSerializer::serialize(const char* label, int value) { writeBlockComma(); char tmp[20]; writeString(label); toCString(value, tmp, 20); m_file.write(" : ", (int32_t)strlen(" : ")); m_file.write(tmp, (int32_t)strlen(tmp)); m_is_first_in_block = false; }
void Compilation::setJettisonReason(JettisonReason jettisonReason, const FireDetail* detail) { if (m_jettisonReason != NotJettisoned) return; // We only care about the original jettison reason. m_jettisonReason = jettisonReason; if (detail) m_additionalJettisonReason = toCString(*detail); else m_additionalJettisonReason = CString(); }
void VcfMaterializer::init() { if (!empty(vcfFileName)) { // Open VCF stream. if (!open(vcfFileIn, toCString(vcfFileName))) throw MasonIOException("Could not open VCF stream."); // Read header. readHeader(vcfHeader, vcfFileIn); // Read first VCF record. if (!atEnd(vcfFileIn)) readRecord(vcfRecord, vcfFileIn); // Get number of haplotypes in VCF file. SEQAN_ASSERT_NOT(empty(vcfRecord.genotypeInfos)); seqan::StringSet<seqan::CharString> xs; seqan::DirectionIterator<seqan::CharString const, seqan::Input>::Type inputIter = directionIterator(vcfRecord.genotypeInfos[0], seqan::Input()); numHaplotypes = 1; for (; !atEnd(inputIter); ++inputIter) numHaplotypes += (*inputIter == '|' || *inputIter == '/'); } else { numHaplotypes = 1; } // Open input FASTA file and FAI. if (!open(faiIndex, toCString(fastaFileName))) { if (!build(faiIndex, toCString(fastaFileName))) throw MasonIOException("Could not build FAI index."); seqan::CharString faiPath = fastaFileName; append(faiPath, ".fai"); if (!save(faiIndex, toCString(faiPath))) throw MasonIOException("Could not write FAI index."); } // Open methylation FASTA FAI file if given. if (!empty(methFastaFileName)) { if (!open(methFaiIndex, toCString(methFastaFileName))) { if (!build(methFaiIndex, toCString(methFastaFileName))) throw MasonIOException("Could not build methylation levels FAI index."); seqan::CharString faiPath = methFastaFileName; append(faiPath, ".fai"); if (!save(methFaiIndex, toCString(faiPath))) throw MasonIOException("Could not write methylation levels FAI index."); } } }
bool JITFinalizer::finalize() { m_jitCode->initializeCodeRef( FINALIZE_DFG_CODE(*m_linkBuffer, ("DFG JIT code for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock.get(), JITCode::DFGJIT)).data())), MacroAssemblerCodePtr()); m_plan.codeBlock->setJITCode(m_jitCode); finalizeCommon(); return true; }
bool JITFinalizer::finalizeFunction() { RELEASE_ASSERT(!m_withArityCheck.isEmptyValue()); m_jitCode->initializeCodeRef( FINALIZE_DFG_CODE(*m_linkBuffer, ("DFG JIT code for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock.get(), JITCode::DFGJIT)).data())), m_withArityCheck); m_plan.codeBlock->setJITCode(m_jitCode); finalizeCommon(); return true; }
PhaseScope::PhaseScope(Code& code, const char* name) : m_code(code) , m_name(name) { if (shouldDumpIRAtEachPhase()) { dataLog("Air after ", code.lastPhaseName(), ", before ", name, ":\n"); dataLog(code); } if (shouldSaveIRBeforePhase()) m_dumpBefore = toCString(code); }
std::string help(Namespace *ns) const { if (ns == NULL) { return ""; } std::stringstream sstr; if(ns!=getGlobal()->getGlobalNamespace()){ sstr <<"\tNamespace " << ns->name() << " consists of: \n"; } printSubBlockInfo(ns->subspaces(), "Namespaces", sstr); if(not ns->subspaces().empty()){ sstr <<"\t\t\tFor more information on a nested namespace, type help(<namespacename>)\n"; } printSubBlockInfo(ns->vocabularies(), "Vocabularies", sstr); printSubBlockInfo(ns->theories(), "Theories", sstr); printSubBlockInfo(ns->structures(), "Structures", sstr); printSubBlockInfo(ns->terms(), "Terms", sstr); printSubBlockInfo(ns->queries(), "Queries", sstr); // FIXME additional blocks are not detected automatically! // Printing procedures std::map<std::string, std::string> procedures; // Get text for each internal procedure in the given namespace for (auto i = getAllInferences().cbegin(); i < getAllInferences().cend(); ++i) { if ((*i)->getNamespace() == ns->name()) { std::vector<std::string> args; for (auto j = (*i)->getArgumentTypes().cbegin(); j < (*i)->getArgumentTypes().cend(); ++j) { args.push_back(toCString(*j)); } auto text = printProcedure((*i)->getName(), args, (*i)->getDescription()); procedures.insert({text, ""}); } } // Get text for each user defined procedure in the given namespace for (auto it = ns->procedures().cbegin(); it != ns->procedures().cend(); ++it) { auto text = printProcedure(it->first, it->second->args(), it->second->description()); procedures.insert({text, ""}); } if (procedures.empty()) { if (ns->isGlobal()) { sstr << "\t\tThere are no procedures in the global namespace\n"; } else { sstr << "\t\tThere are no procedures in namespace "; ns->putName(sstr); sstr << '\n'; } } else { printSubBlockInfo(procedures, "Procedures", sstr); } return sstr.str(); }
static bool testSetStatus(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result) { char* message = 0; if (argCount && NPVARIANT_IS_STRING(args[0])) { NPString statusString = NPVARIANT_TO_STRING(args[0]); message = toCString(statusString); } browser->status(obj->npp, message); free(message); return true; }
JSValue Bytecodes::toJS(ExecState* exec) const { VM& vm = exec->vm(); JSObject* result = constructEmptyObject(exec); result->putDirect(vm, vm.propertyNames->bytecodesID, jsNumber(m_id)); result->putDirect(vm, vm.propertyNames->inferredName, jsString(exec, String::fromUTF8(m_inferredName))); result->putDirect(vm, vm.propertyNames->sourceCode, jsString(exec, String::fromUTF8(m_sourceCode))); result->putDirect(vm, vm.propertyNames->hash, jsString(exec, String::fromUTF8(toCString(m_hash)))); result->putDirect(vm, vm.propertyNames->instructionCount, jsNumber(m_instructionCount)); addSequenceProperties(exec, result); return result; }
int main(int argc, char const ** argv) { // Parse the command line. seqan::ArgumentParser parser; MasonGenomeOptions options; seqan::ArgumentParser::ParseResult res = parseCommandLine(options, argc, argv); // If there was an error parsing or built-in argument parser functionality // was triggered then we exit the program. The return code is 1 if there // were errors and 0 if there were none. if (res != seqan::ArgumentParser::PARSE_OK) return res == seqan::ArgumentParser::PARSE_ERROR; std::cout << "MASON GENOME SIMULATOR\n" << "======================\n\n"; // Print the command line arguments back to the user. if (options.verbosity > 0) { std::cout << "__OPTIONS____________________________________________________________________\n" << '\n' << "VERBOSITY \t" << options.verbosity << '\n' << "\n" << "SEED \t" << options.seed << '\n' << "\n" << "OUTPUT FILE\t" << options.outputFilename << "\n" << "CONTIG LENS\t"; for (unsigned i = 0; i < length(options.contigLengths); ++i) { if (i > 0) std::cout << ", "; std::cout << options.contigLengths[i]; }; std::cout << "\n\n"; } // Perform genome simulation. std::cout << "__SIMULATING GENOME__________________________________________________________\n" << "\n"; MasonSimulateGenomeOptions simOptions; simOptions.contigLengths = options.contigLengths; simOptions.seed = options.seed; if (simulateGenome(toCString(options.outputFilename), simOptions) != 0) return 1; std::cerr << "\nDone.\n"; return 0; }
void getScriptDefaultPath(Entity e, char* path, char* full_path, int length, const char* ext) { char tmp[30]; toCString(e.index, tmp, 30); copyString(full_path, length, m_engine.getBasePath()); catCString(full_path, length, "e"); catCString(full_path, length, tmp); catCString(full_path, length, "."); catCString(full_path, length, ext); copyString(path, length, "e"); catCString(path, length, tmp); catCString(path, length, "."); catCString(path, length, ext); }
bool toCString(int64 value, char* output, int length) { char* c = output; if (length > 0) { if (value < 0) { value = -value; --length; *c = '-'; ++c; } return toCString((uint64)value, c, length); } return false; }
void check_cutted_frags(CharString frag, std::vector<table_entry*> &links, map<unsigned long long, string> &chains, unsigned int min_length){ if(length(frag) > min_length){ std::queue<int> l_link; std::queue<int> r_link; Pattern<CharString, ShiftOr > pattern(frag); for(unsigned int i=0; i<links.size(); ++i){ CharString text = links[i]->get_short_read()->get_RNA_seq_sequence(); Finder<CharString> finder(text); find(finder,pattern); if(beginPosition(finder) < min_length){ //std::cout << "L link " << i << ::std::endl; l_link.push(i); } if(endPosition(finder) > length(text) - min_length){ //std::cout << "R link" << ::std::endl; r_link.push(i); } } if(l_link.size() != 0 && r_link.size() != 0){ string head; assign(head,frag); for(unsigned int z=0; z<min_length*2 - length(frag);++z){ head.append("A"); } if(chains.find(fingerprint(head)) == chains.end()){ chains[fingerprint(head)] = toCString(frag); //std::cerr << "CUT: " << frag << " " << length(frag) << std::endl; }else{ //std::cerr << "Problem:" << std::endl; //std::cerr << chains[fingerprint(head)] << std::endl; //std::cerr << toCString(frag) << std::endl; } //::std::cout << toCString(frag) << ::std::endl; while(!l_link.empty()){ links[l_link.front()]->push_D_link(fingerprint(head)); l_link.pop(); } while(!r_link.empty()){ links[r_link.front()]->push_A_link(fingerprint(head)); r_link.pop(); } } } }
static CString regexpToSourceString(const RegExp* regExp) { char postfix[7] = { '/', 0, 0, 0, 0, 0, 0 }; int index = 1; if (regExp->global()) postfix[index++] = 'g'; if (regExp->ignoreCase()) postfix[index++] = 'i'; if (regExp->multiline()) postfix[index] = 'm'; if (regExp->dotAll()) postfix[index++] = 's'; if (regExp->unicode()) postfix[index++] = 'u'; if (regExp->sticky()) postfix[index++] = 'y'; return toCString("/", regExp->pattern().impl(), postfix); }
int getSVLen(seqan::CharString const & str) { seqan::DirectionIterator<seqan::CharString const, seqan::Input>::Type inputIter = directionIterator(str, seqan::Input()); // Parse out key/value pairs and interpret SVLEN. seqan::CharString key, val; enum { IN_KEY, IN_VALUE } state = IN_KEY; for (; !atEnd(inputIter); ++inputIter) { if (*inputIter == '=') { state = IN_VALUE; continue; } else if (*inputIter == ';') { if (key == "SVLEN") return seqan::lexicalCast<int>(val); clear(val); clear(key); state = IN_KEY; continue; } else if (state == IN_KEY) { appendValue(key, *inputIter); } else // (state == IN_VALUE) { appendValue(val, *inputIter); } } if (key == "SVLEN") return seqan::lexicalCast<int>(val); SEQAN_FAIL("Missing INFO SVLEN %s", toCString(str)); return 0; }
void Value::deepDump(PrintStream& out) const { out.print(m_type, " ", *this, " = ", m_opcode); out.print("("); CommaPrinter comma; dumpChildren(comma, out); if (m_origin) out.print(comma, m_origin); dumpMeta(comma, out); { CString string = toCString(effects()); if (string.length()) out.print(comma, string); } out.print(")"); }
void IlluminaSequencingSimulator::_initModel() { // Compute mismatch probabilities, piecewise linear function. resize(model->mismatchProbabilities, illuminaOptions.readLength); // Compute probability at raise point. double y_r = 2 * illuminaOptions.probabilityMismatch - illuminaOptions.positionRaise * illuminaOptions.probabilityMismatchBegin - illuminaOptions.probabilityMismatchEnd + illuminaOptions.probabilityMismatchEnd * illuminaOptions.positionRaise; if (illuminaOptions.verbosity >= 2) { std::cerr << "Illumina error curve:\n" << " (0, " << illuminaOptions.probabilityMismatchBegin << ") -- (" << illuminaOptions.positionRaise << ", " << y_r << ") -- (1, " << illuminaOptions.probabilityMismatchEnd << ")\n"; } // std::cout << "y_r = " << y_r << std::endl; // Compute mismatch probability at each base. if (!empty(illuminaOptions.probabilityMismatchFile)) { // Open file. std::fstream file; file.open(toCString(illuminaOptions.probabilityMismatchFile), std::ios_base::in); if (!file.is_open()) { std::cerr << "Failed to load mismatch probabilities from " << illuminaOptions.probabilityMismatchFile << std::endl; // return 1; } // Load probabilities. double x; file >> x; unsigned i; for (i = 0; i < illuminaOptions.readLength && !file.eof(); ++i) { model->mismatchProbabilities[i] = x; file >> x; } if (i != illuminaOptions.readLength) { std::cerr << "Not enough mismatch probabilites in " << illuminaOptions.probabilityMismatchFile << " (" << i << " < " << illuminaOptions.readLength << ")!" << std::endl; // return 1; } } else {
void StackTree::printCallstack(StackNode* node) { while (node) { HANDLE process = GetCurrentProcess(); uint8 symbol_mem[sizeof(SYMBOL_INFO) + 256 * sizeof(char)]; SYMBOL_INFO* symbol = reinterpret_cast<SYMBOL_INFO*>(symbol_mem); memset(symbol_mem, 0, sizeof(symbol_mem)); symbol->MaxNameLen = 255; symbol->SizeOfStruct = sizeof(SYMBOL_INFO); BOOL success = SymFromAddr(process, (DWORD64)(node->m_instruction), 0, symbol); if (success) { IMAGEHLP_LINE line; DWORD offset; if (SymGetLineFromAddr(process, (DWORD64)(node->m_instruction), &offset, &line)) { OutputDebugString("\t"); OutputDebugString(line.FileName); OutputDebugString("("); char tmp[20]; toCString((uint32)line.LineNumber, tmp, sizeof(tmp)); OutputDebugString(tmp); OutputDebugString("):"); } OutputDebugString("\t"); OutputDebugString(symbol->Name); OutputDebugString("\n"); } else { OutputDebugString("\tN/A\n"); } node = node->m_parent; } }
JSValue Bytecodes::toJS(ExecState* exec) const { JSObject* result = constructEmptyObject(exec); result->putDirect(exec->globalData(), exec->propertyNames().bytecodesID, jsNumber(m_id)); result->putDirect(exec->globalData(), exec->propertyNames().inferredName, jsString(exec, m_inferredName)); result->putDirect(exec->globalData(), exec->propertyNames().sourceCode, jsString(exec, m_sourceCode)); result->putDirect(exec->globalData(), exec->propertyNames().hash, jsString(exec, String::fromUTF8(toCString(m_hash)))); result->putDirect(exec->globalData(), exec->propertyNames().instructionCount, jsNumber(m_instructionCount)); addSequenceProperties(exec, result); return result; }