SEM::Value GetStaticMethod(Context& context, SEM::Value rawValue, const String& methodName, const Debug::SourceLocation& location) { auto value = derefOrBindValue(context, std::move(rawValue)); assert(value.type()->isRef() && value.type()->isBuiltInReference()); assert(value.type()->refTarget()->isStaticRef()); const auto targetType = value.type()->refTarget()->staticRefTarget()->resolveAliases(); if (!targetType->isObjectOrTemplateVar()) { throw ErrorException(makeString("Cannot get static method '%s' for non-object type '%s' at position %s.", methodName.c_str(), targetType->toString().c_str(), location.toString().c_str())); } const auto methodSet = getTypeMethodSet(context, targetType); const auto canonicalMethodName = CanonicalizeMethodName(methodName); const auto methodIterator = methodSet->find(canonicalMethodName); if (methodIterator == methodSet->end()) { throw ErrorException(makeString("Cannot find static method '%s' for type '%s' at position %s.", methodName.c_str(), targetType->toString().c_str(), location.toString().c_str())); } const auto& methodElement = methodIterator->second; if (!methodElement.isStatic()) { throw ErrorException(makeString("Cannot call non-static method '%s' for type '%s' at position %s.", methodName.c_str(), targetType->toString().c_str(), location.toString().c_str())); } if (targetType->isObject()) { // Get the actual function so we can refer to it. const auto& function = targetType->getObjectType()->functions().at(canonicalMethodName); const auto functionTypeTemplateMap = targetType->generateTemplateVarMap(); const auto functionType = simplifyFunctionType(context, function->type().substitute(functionTypeTemplateMap)); const auto functionRefType = createFunctionPointerType(context, functionType); auto functionRef = addDebugInfo(SEM::Value::FunctionRef(targetType, function.get(), {}, functionRefType), location); if (targetType->isInterface()) { const auto interfaceMethodType = createStaticInterfaceMethodType(context, functionType); return addDebugInfo(SEM::Value::StaticInterfaceMethodObject(std::move(functionRef), std::move(value), interfaceMethodType), location); } else { return functionRef; } } else { const bool isTemplated = true; const auto functionType = createFunctionPointerType(context, methodElement.createFunctionType(isTemplated)); return addDebugInfo(SEM::Value::TemplateFunctionRef(targetType, methodName, functionType), location); } }
int profileFunction(struct mangled_method *mm, char *code, int codelen) { int retval = false; if( xProfFlag && kaffe_memory_samples ) { /* * Add the function name to the symbol file and observe the * memory */ xProfilingOff(); if( observeMemory(kaffe_memory_samples, code, codelen) && addDebugInfo(profiler_debug_file, DIA_FunctionSymbol, mm, code, codelen, DIA_DONE) ) { retval = true; } xProfilingOn(); } else { retval = true; } return( retval ); }
struct debug_file *createDebugFile(const char *filename) { struct debug_file *retval = 0; assert(filename != NULL); /* Allocate space for the debug_file struct and filename */ if( (retval = (struct debug_file *) KMALLOC(sizeof(struct debug_file) + strlen(filename) + 1)) ) { retval->df_filename = (char *)(retval + 1); strcpy(retval->df_filename, filename); retval->df_current_type_id = STYPE_MAX; if( (retval->df_file = fopen(retval->df_filename, "w")) ) { addDebugInfo(retval, DIA_SourceFile, "$xdb$.java", 0, DIA_Comment, debug_header, DIA_DONE); fprintf(retval->df_file, "%s", types_header); } else { KFREE(retval); retval = 0; } } return( retval ); }
void VcfWriterRnaSV:: modifyTranslocInfo( const SVCandidate& sv, const bool isFirstOfPair, const SVCandidateAssemblyData& assemblyData, InfoTag_t& infotags) const { const SVScoreInfo& baseInfo(getBaseInfo()); infotags.push_back( str(boost::format("BND_DEPTH=%i") % (isFirstOfPair ? baseInfo.bp1MaxDepth : baseInfo.bp2MaxDepth) ) ); infotags.push_back( str(boost::format("MATE_BND_DEPTH=%i") % (isFirstOfPair ? baseInfo.bp2MaxDepth : baseInfo.bp1MaxDepth) ) ); { ///TODO better multisample handler here: const unsigned sampleIndex(0); const SVSampleAlleleInfo& refinfo(baseInfo.samples[sampleIndex].ref); infotags.push_back(str(boost::format("REF_COUNT=%i") % (isFirstOfPair ? refinfo.confidentSplitReadAndPairCountRefBp1 : refinfo.confidentSplitReadAndPairCountRefBp2))); infotags.push_back(str(boost::format("MATE_REF_COUNT=%i") % (isFirstOfPair ? refinfo.confidentSplitReadAndPairCountRefBp2 : refinfo.confidentSplitReadAndPairCountRefBp1))); } { // if (!assemblyData.isSpanning) return; const bool isFirst = (assemblyData.bporient.isBp1First == isFirstOfPair); if (isFirst) infotags.push_back("RNA_FIRST"); if (assemblyData.bporient.isTranscriptStrandKnown) infotags.push_back("RNA_STRANDED"); if (!isFirstOfPair) return; // only the first breakpoint gets the additional RNA info attached to its VCF entry infotags.push_back(str(boost::format("RNA_FwRvReads=%i,%i") % sv.forwardTranscriptStrandReadCount % sv.reverseTranscriptStrandReadCount)); infotags.push_back(str(boost::format("RNA_Reads=%i") % sv.bp2.lowresEvidence.getTotal())); const unsigned numContigs(assemblyData.contigs.size()); if (numContigs > 0) { if (numContigs != assemblyData.spanningAlignments.size()) infotags.push_back(str(boost::format("ERROR=%i,%i") % numContigs % assemblyData.spanningAlignments.size())); const unsigned int bestAlignmentIdx(assemblyData.bestAlignmentIndex); if (numContigs <= bestAlignmentIdx) infotags.push_back(str(boost::format("ERROR2=%i,%i") % numContigs % bestAlignmentIdx)); infotags.push_back(str(boost::format("RNA_CONTIG=%s") % assemblyData.contigs[bestAlignmentIdx].seq)); const auto& bestAlignment(assemblyData.spanningAlignments[bestAlignmentIdx]); infotags.push_back(str(boost::format("RNA_CONTIG_ALN=%i,%i") % apath_matched_length(bestAlignment.align1.apath) % apath_matched_length(bestAlignment.align2.apath))); } } #ifdef DEBUG_VCF addDebugInfo(isFirstOfPair, sv, assemblyData, infotags); #endif }
AST::Value CallValue(Context& context, AST::Value rawValue, HeapArray<AST::Value> args, const Debug::SourceLocation& location) { auto value = derefValue(std::move(rawValue)); if (getDerefType(value.type())->isTypename()) { return CallValue(context, GetStaticMethod(context, std::move(value), context.getCString("create"), location), std::move(args), location); } if (!value.type()->isCallable()) { // Try to use 'call' method. if (TypeCapabilities(context).hasCallMethod(getDerefType(value.type()))) { return CallValue(context, GetMethod(context, std::move(value), context.getCString("call"), location), std::move(args), location); } else { context.issueDiag(TypeNotCallableDiag(getDerefType(value.type())), location); return AST::Value::Constant(Constant::Integer(0), context.typeBuilder().getIntType()); } } const auto functionType = value.type()->asFunctionType(); const auto& typeList = functionType.parameterTypes(); if (functionType.attributes().isVarArg()) { if (args.size() < typeList.size()) { context.issueDiag(VarArgTooFewArgsDiag(value.toDiagString(), args.size(), typeList.size()), location); } } else { if (args.size() != typeList.size()) { context.issueDiag(CallIncorrectArgCountDiag(value.toDiagString(), args.size(), typeList.size()), location); } } if (!TypeCapabilities(context).isSized(functionType.returnType())) { // TODO: also check that the type is not abstract. context.issueDiag(CallReturnTypeIsUnsizedDiag(functionType.returnType()), location); } if (functionType.returnType()->hasConst()) { context.issueDiag(CallReturnTypeIsConstDiag(functionType.returnType()), location); } return addDebugInfo(AST::Value::Call(std::move(value), CastFunctionArguments(context, std::move(args), typeList, location), functionType.returnType()->stripConst()), location); }
int profileSymbol(struct mangled_method *mm, char *addr, int size) { int retval = false; if( xProfFlag ) { if( addDebugInfo(profiler_debug_file, DIA_FunctionSymbol, mm, addr, size, DIA_DONE) ) { retval = true; } } else { retval = true; } return( retval ); }
void ALua::printDebugError(lua_State* L,int sErr) { if(sErr == 0) { return; } const char* error; switch(sErr) { case LUA_ERRSYNTAX://编译时错误 /*const char *buf = "mylib.myfun()2222";类似这行语句可以引起编译时错误*/ //qDebug()<<"------syntax error during pre-compilation------"; addDebugInfo(QString("------syntax error during pre-compilation------")); break; case LUA_ERRMEM://内存错误 //qDebug()<<"------memory allocation error------"; addDebugInfo(QString("------memory allocation error------")); break; case LUA_ERRRUN://运行时错误 //qDebug()<<"------a runtime error------"; addDebugInfo(QString("------a runtime error------")); break; case LUA_YIELD://线程被挂起错误 //qDebug()<<"------Thread has Suspended------"; addDebugInfo(QString("------Thread has Suspended------")); break; case LUA_ERRERR://在进行错误处理时发生错误 //qDebug()<<"------error while running the error handler function-------"; addDebugInfo(QString("------error while running the error handler function-------")); break; default: break; } error = lua_tostring(L, -1);//打印错误结果 addDebugInfo(QString(error)); //qDebug()<<"--------End--------"; addDebugInfo(QString("--------End--------")); }
SEM::Value GetTemplatedMethodWithoutResolution(Context& context, SEM::Value value, const SEM::Type* const type, const String& methodName, SEM::ValueArray templateArguments, const Debug::SourceLocation& location) { assert(value.type()->isRef() && value.type()->isBuiltInReference()); if (!type->isObjectOrTemplateVar()) { throw ErrorException(makeString("Cannot get method '%s' for non-object type '%s' at position %s.", methodName.c_str(), type->toString().c_str(), location.toString().c_str())); } const auto methodSet = getTypeMethodSet(context, type); const auto& objectConstPredicate = methodSet->constPredicate(); const auto canonicalMethodName = CanonicalizeMethodName(methodName); const auto methodIterator = methodSet->find(canonicalMethodName); if (methodIterator == methodSet->end()) { throw ErrorException(makeString("Cannot find method '%s' for type '%s' at position %s.", methodName.c_str(), type->toString().c_str(), location.toString().c_str())); } const auto& methodElement = methodIterator->second; if (methodElement.isStatic()) { throw ErrorException(makeString("Cannot access static method '%s' for value of type '%s' at position %s.", methodName.c_str(), type->toString().c_str(), location.toString().c_str())); } auto templateVariableAssignments = type->generateTemplateVarMap(); const auto function = type->isObject() ? type->getObjectType()->functions().at(canonicalMethodName).get() : nullptr; if (function != nullptr) { const auto& templateVariables = function->templateVariables(); if (templateVariables.size() != templateArguments.size()) { // Try to apply some basic deduction... if (templateVariables.size() == 1 && templateArguments.size() == 0 && function->constPredicate().isVariable() && function->constPredicate().variableTemplateVar() == templateVariables[0] ) { const auto boolType = getBuiltInType(context, context.getCString("bool"), {}); templateArguments.push_back(SEM::Value::PredicateExpr(objectConstPredicate.copy(), boolType)); } else { throw ErrorException(makeString("Incorrect number of template " "arguments provided for method '%s'; %llu were required, " "but %llu were provided at position %s.", function->name().toString().c_str(), (unsigned long long) templateVariables.size(), (unsigned long long) templateArguments.size(), location.toString().c_str())); } } // Add function template variable => argument mapping. for (size_t i = 0; i < templateArguments.size(); i++) { const auto templateVariable = templateVariables.at(i); const auto& templateValue = templateArguments.at(i); if (templateValue.isTypeRef()) { const auto templateTypeValue = templateValue.typeRefType()->resolveAliases(); if (!templateTypeValue->isObjectOrTemplateVar() || templateTypeValue->isInterface()) { throw ErrorException(makeString("Invalid type '%s' passed " "as template parameter '%s' for method '%s' at position %s.", templateTypeValue->toString().c_str(), templateVariable->name().toString().c_str(), function->name().toString().c_str(), location.toString().c_str())); } templateVariableAssignments.insert(std::make_pair(templateVariable, SEM::Value::TypeRef(templateTypeValue, templateValue.type()))); } else { templateVariableAssignments.insert(std::make_pair(templateVariable, templateValue.copy())); } } } else { assert(templateArguments.empty()); } const auto methodConstPredicate = methodElement.constPredicate().substitute(templateVariableAssignments); if (!objectConstPredicate.implies(methodConstPredicate)) { throw ErrorException(makeString("Cannot refer to mutator method '%s' from const object of type '%s' at position %s.", methodName.c_str(), type->toString().c_str(), location.toString().c_str())); } // Now check the template arguments satisfy the requires predicate. const auto& requirePredicate = methodElement.requirePredicate(); // Conservatively assume require predicate is not satisified if result is undetermined. const bool satisfiesRequireDefault = false; if (!evaluatePredicateWithDefault(context, requirePredicate, templateVariableAssignments, satisfiesRequireDefault)) { throw ErrorException(makeString("Template arguments do not satisfy " "require predicate '%s' of method '%s' at position %s.", requirePredicate.substitute(templateVariableAssignments).toString().c_str(), methodName.c_str(), location.toString().c_str())); } if (function != nullptr) { const auto functionType = simplifyFunctionType(context, function->type().substitute(templateVariableAssignments)); const auto functionRefType = createFunctionPointerType(context, functionType); auto functionRef = addDebugInfo(SEM::Value::FunctionRef(type, function, std::move(templateArguments), functionRefType), location); if (type->isInterface()) { const auto interfaceMethodType = createInterfaceMethodType(context, functionType); return addDebugInfo(SEM::Value::InterfaceMethodObject(std::move(functionRef), std::move(value), interfaceMethodType), location); } else { const auto methodType = createMethodType(context, functionType); return addDebugInfo(SEM::Value::MethodObject(std::move(functionRef), std::move(value), methodType), location); } } else { const bool isTemplated = true; const auto functionType = methodElement.createFunctionType(isTemplated); const auto functionRefType = createFunctionPointerType(context, functionType); auto functionRef = addDebugInfo(SEM::Value::TemplateFunctionRef(type, methodName, functionRefType), location); const auto methodType = createMethodType(context, functionType); return addDebugInfo(SEM::Value::MethodObject(std::move(functionRef), std::move(value), methodType), location); } }