HashedDB::HashedDB ( string dbFileName ) { nbZero = new int[signatureLength]; int totalSignatureLength=0; ifstream is; is.open(dbFileName.c_str(), std::ifstream::binary); if (!is.is_open()) { cerr << "Warning: Error opening file " << dbFileName << endl; } is.seekg(0,ios_base::beg); is.read((char*)&totalSignatureLength, sizeof(totalSignatureLength)); is.read((char*)&nSignatures, sizeof(nSignatures)); cerr << "Sig Length : " << totalSignatureLength << endl; cerr << "Nb signatures : " << nSignatures << endl; signatureLength = totalSignatureLength; for (int sigIndex = 0; sigIndex < nSignatures; sigIndex++) { LSHSignature * newLshSig = new LSHSignature(signatureLength); append(*newLshSig); // Read from disk is.read((char*)signatures[sigIndex].getData(), totalSignatureLength/8); } LSHSignature target1 = getSignature ( 0 ); LSHSignature target2 = getSignature ( 2 ); LSHSignature target3 = getSignature ( 3 ); cerr << "Test loadHAshed db : "; target1.print(1,20); target2.print(2,20); target3.print(3,20); is.close(); }
void CFactorGraph::createGroups (void) { VarSignMap varGroups; FacSignMap facGroups; unsigned nIters = 0; bool groupsHaveChanged = true; const VarNodes& varNodes = groundFg_->varNodes(); const FacNodes& facNodes = groundFg_->facNodes(); while (groupsHaveChanged || nIters == 1) { nIters ++; unsigned prevFactorGroupsSize = facGroups.size(); facGroups.clear(); // set a new color to the factors with the same signature for (unsigned i = 0; i < facNodes.size(); i++) { const Signature& signature = getSignature (facNodes[i]); FacSignMap::iterator it = facGroups.find (signature); if (it == facGroups.end()) { it = facGroups.insert (make_pair (signature, FacNodes())).first; } it->second.push_back (facNodes[i]); } for (FacSignMap::iterator it = facGroups.begin(); it != facGroups.end(); it++) { Color newColor = getFreeColor(); FacNodes& groupMembers = it->second; for (unsigned i = 0; i < groupMembers.size(); i++) { setColor (groupMembers[i], newColor); } } // set a new color to the variables with the same signature unsigned prevVarGroupsSize = varGroups.size(); varGroups.clear(); for (unsigned i = 0; i < varNodes.size(); i++) { const Signature& signature = getSignature (varNodes[i]); VarSignMap::iterator it = varGroups.find (signature); if (it == varGroups.end()) { it = varGroups.insert (make_pair (signature, VarNodes())).first; } it->second.push_back (varNodes[i]); } for (VarSignMap::iterator it = varGroups.begin(); it != varGroups.end(); it++) { Color newColor = getFreeColor(); VarNodes& groupMembers = it->second; for (unsigned i = 0; i < groupMembers.size(); i++) { setColor (groupMembers[i], newColor); } } groupsHaveChanged = prevVarGroupsSize != varGroups.size() || prevFactorGroupsSize != facGroups.size(); } printGroups (varGroups, facGroups); createClusters (varGroups, facGroups); }
void JitInstanceMemberFunction::compileThisAdjustementThunk( size_t a_uiThisOffset ) const { o_assert(m_ThisAdjustmentThunks.find(a_uiThisOffset) == m_ThisAdjustmentThunks.end()); size_t argCount = getSignature()->getParameterCount()+1; // parameters+this jit_value_t* args = o_allocate_n(argCount, jit_value_t); // The fixing function has the same signature as the indirected one jit_function_t func = jit_function_create((jit_context_t)m_jit_context.context, jit_function_get_signature((jit_function_t)m_jit_function.function)); jit_value_t new_this = jit_insn_add(func, jit_value_get_param(func, 0), jit_value_create_nint_constant(func, jit_type_nint, -((int)a_uiThisOffset))); args[0] = new_this; size_t i = 1; for(;i<argCount;++i) { args[i] = jit_value_get_param(func, i); } string name = "[thunk]:"+m_pSubroutine->getQualifiedDecoratedName()+":adjustor{"+boost::lexical_cast<string>(a_uiThisOffset)+"}"; jit_insn_call(func , name.c_str() , (jit_function_t)m_jit_function.function , jit_function_get_signature((jit_function_t)m_jit_function.function) , args , argCount , 0); int result = jit_function_compile(func); o_assert(result != 0); o_deallocate_n(args, argCount, jit_value_t); m_ThisAdjustmentThunks[a_uiThisOffset] = func; }
const char *BaseObject::getConstructorSignature(int args, ...) { va_list ap; va_start(ap, args); const char *sig=getSignature(JNI::Void, args, ap); va_end(ap); return sig; }
str MACROprocessor(Client cntxt, MalBlkPtr mb, Symbol t) { InstrPtr q; int i, cnt = 0, last = -1; str msg = MAL_SUCCEED; (void) cntxt; if (t == NULL) return msg; msg = MACROvalidate(t->def); if (msg) return msg; for (i = 0; i < mb->stop; i++) { q = getInstrPtr(mb, i); if (getFunctionId(q) && idcmp(getFunctionId(q), t->name) == 0 && getSignature(t)->token == FUNCTIONsymbol) { if (i == last) throw(MAL, "optimizer.MACROoptimizer", MACRO_DUPLICATE); last = i; i = inlineMALblock(mb, i, t->def); cnt++; if (cnt > MAXEXPANSION) throw(MAL, "optimizer.MACROoptimizer", MACRO_TOO_DEEP); } } return msg; }
int do_check_signature(JNIEnv* env, jobject thiz){ int equal = -1; jobject signature = getSignature(env, thiz); if(signature == NULL){ return equal; } //PublicKey key jobject publicKey = getPublicKey(env, signature); if(publicKey == NULL){ return equal; } //BigInteger modulus = ((RSAPublicKey)key).getModulus().hashCode(); jobject modulus = JNU_CallMethodByName(env, publicKey, "getModulus", "()Ljava/math/BigInteger;").l; //String strModulus = modulus.toString(10) jstring strKey = (jstring)JNU_CallMethodByName(env, modulus, "toString", "(I)Ljava/lang/String;", 10).l; #ifndef TEST_HASH_CODE const char *nativeKeyString = (*env)->GetStringUTFChars(env, strKey, 0); LOGI("this app publicKey of signature is %s", nativeKeyString); equal = 0 == strncmp(nativeKeyString, global_app_signature_public_key, 1000); (*env)->ReleaseStringUTFChars(env, strKey, nativeKeyString); #else int hash_code = (int)JNU_CallMethodByName(env, modulus, "hashCode", "()I").i; LOGI("this app hash_code of signature is %d", hash_code); equal = hash_code == global_app_signature_hash_code; #endif //合法返回1 return equal == 1; }
str RUNsqlbind(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p) { int i; str msg = MAL_SUCCEED; Symbol sqlbind = findSymbol(cntxt ->nspace, getName("sql"), getName("bind")); MALfcn f = NULL; if (sqlbind ) f = getSignature(sqlbind)->fcn; if ( f ) for (i = 0; i < mb->stop; i++) { p = getInstrPtr(mb, i); if (p->fcn == f) { if ((msg = reenterMAL(cntxt, mb, i, i + 1, stk))) break; /* fetch the BAT properties and turn off this instruction */ p->token = NOOPsymbol; } } #ifdef DEBUG_MAL_SCHEDULER fprintf(stderr, "scheduler.sqlbind results\n"); fprintFunction(stderr, mb, stk, LIST_MAL_ALL); #endif return msg; }
void JitInstanceMemberFunction::compileVTableIndirectionFunction() { m_jit_virtual_indirection_function = jit_function_create((jit_context_t)m_jit_context.context, toJitSignature(m_eAbi, getSignature())); o_assert(m_jit_virtual_indirection_function.function); jit_context_build_start((jit_context_t)m_jit_context.context); size_t argCount = getSignature()->getParameterCount()+1; // parameters+this jit_value_t* args = o_allocate_n(argCount, jit_value_t); // The indirection has the same signature as the indirected one jit_value_t this_pointer = jit_value_get_param((jit_function_t)m_jit_virtual_indirection_function.function, 0); jit_value_t vtable_index = jit_value_create_nint_constant((jit_function_t)m_jit_virtual_indirection_function.function, jit_type_nuint, getInstanceMemberFunction()->getVirtualTableIndex()); jit_value_t vtable_array = jit_insn_load_relative ((jit_function_t)m_jit_virtual_indirection_function.function, this_pointer, 0, jit_type_void_ptr); jit_value_t vtable_pointer = jit_insn_load_elem((jit_function_t)m_jit_virtual_indirection_function.function, vtable_array, vtable_index, jit_type_void_ptr); size_t i = 0; for(;i<argCount;++i) { args[i] = jit_value_get_param((jit_function_t)m_jit_virtual_indirection_function.function, i); } jit_insn_call_indirect_vtable ((jit_function_t)m_jit_virtual_indirection_function.function, vtable_pointer, jit_function_get_signature((jit_function_t)m_jit_function.function), args, argCount, 0); int result = jit_function_compile((jit_function_t)m_jit_virtual_indirection_function.function); o_assert(result != 0); jit_context_build_end((jit_context_t)m_jit_context.context); o_deallocate_n(args, argCount, jit_value_t); }
void SimpleMatcher::run(const ca::MatchFinder::MatchResult &result) { // Get matched AST node std::string functionStr = utils::getStringByType<clang::FunctionDecl>(); const clang::FunctionDecl *fd = result.Nodes.getNodeAs<clang::FunctionDecl>(functionStr); // Check if object is valid and get function signature std::string signature = getSignature(fd); if (signature.empty()) { return; } const clang::SourceManager &sm = result.Context->getSourceManager(); const clang::SourceLocation loc = fd->getLocStart(); FunctionId fid; fid.path = sm.getFilename(fd->getLocation()); fid.name = fd->getQualifiedNameAsString(); fid.signature = signature; fid.line = sm.getSpellingLineNumber(loc); fid.column = sm.getSpellingColumnNumber(loc); // Log match utils::logMatch(fid.path, fid.line, fid.column, functionStr); // Count lines of code in function body unsigned bodyStart = sm.getSpellingLineNumber(fd->getBody()->getLocStart()); unsigned bodyEnd = sm.getSpellingLineNumber(fd->getBody()->getLocEnd()); stats[fid].loc = bodyEnd - bodyStart + 1; // Increase cyclomatic number ++stats[fid].cyclomaticN; }
bool Serializer::checkSignature (const void *data) { //Compare data to signature UUID *dataID = (UUID*) data; UUID *sigID = (UUID*) getSignature(); return (*dataID == *sigID); }
/* * Removal of elements from the symbol table should be * done with care. For, it should be assured that * there are no references to the definition at the * moment of removal. This situation can not easily * checked at runtime, without tremendous overhead. */ void deleteSymbol(Module scope, Symbol prg){ InstrPtr sig; int t; sig = getSignature(prg); #ifdef _DEBUG_MODULE_ fprintf(stderr,"#delete symbol %s.%s from %s\n", getModuleId(sig), getFunctionId(sig), prg->name); #endif if (getModuleId(sig) && getModuleId(sig)!= scope->name ){ /* move the definition to the proper place */ /* default scope is the last resort */ Module c= findModule(scope, getModuleId(sig)); if(c ) scope = c; } t = getSymbolIndex(getFunctionId(sig)); if (scope->space[t] == prg) { scope->space[t] = scope->space[t]->peer; freeSymbol(prg); } else { Symbol nxt = scope->space[t]; while (nxt->peer != NULL) { if (nxt->peer == prg) { nxt->peer = prg->peer; nxt->skip = prg->peer; freeSymbol(prg); return; } nxt = nxt->peer; } } }
void pgResetFn_boardConfig(boardConfig_t *boardConfig) { if (boardInformationIsSet()) { strncpy(boardConfig->manufacturerId, getManufacturerId(), MAX_MANUFACTURER_ID_LENGTH); strncpy(boardConfig->boardName, getBoardName(), MAX_BOARD_NAME_LENGTH); boardConfig->boardInformationSet = true; } else { #if !defined(GENERIC_TARGET) strncpy(boardConfig->boardName, targetName, MAX_BOARD_NAME_LENGTH); #if defined(TARGET_MANUFACTURER_IDENTIFIER) strncpy(boardConfig->manufacturerId, TARGET_MANUFACTURER_IDENTIFIER, MAX_MANUFACTURER_ID_LENGTH); #endif boardConfig->boardInformationSet = true; #else boardConfig->boardInformationSet = false; #endif // GENERIC_TARGET } #if defined(USE_SIGNATURE) if (signatureIsSet()) { memcpy(boardConfig->signature, getSignature(), SIGNATURE_LENGTH); boardConfig->signatureSet = true; } else { boardConfig->signatureSet = false; } #endif }
bool JPMethodOverload::isSameOverload(JPMethodOverload& o) { if (isStatic() != o.isStatic()) { return false; } if (m_Arguments.size() != o.m_Arguments.size()) { return false; } TRACE_IN("JPMethodOverload::isSameOverload"); TRACE2("My sig", getSignature()); TRACE2("It's sig", o.getSignature()); int start = 0; if (! isStatic()) { start = 1; } for (unsigned int i = start; i < m_Arguments.size() && i < o.m_Arguments.size(); i++) { JPTypeName& mine = m_Arguments[i]; JPTypeName& his = o.m_Arguments[i]; const string& mineSimple = mine.getSimpleName(); const string& hisSimple = his.getSimpleName(); if (mineSimple != hisSimple) { return false; } } return true; TRACE_OUT; }
QString Operator::getCodeDefinition(unsigned def_type, bool reduced_form) { unsigned i; QString atribs_tipos[]={ParsersAttributes::LEFT_TYPE, ParsersAttributes::RIGHT_TYPE}, atribs_ops[]={ ParsersAttributes::COMMUTATOR_OP, ParsersAttributes::NEGATOR_OP }, atribs_funcoes[]={ParsersAttributes::OPERATOR_FUNC, ParsersAttributes::JOIN_FUNC, ParsersAttributes::RESTRICTION_FUNC}; for(i=Operator::LEFT_ARG; i <= Operator::RIGHT_ARG; i++) { if(def_type==SchemaParser::SQL_DEFINITION) { if(argument_types[i]!="any") attributes[atribs_tipos[i]]=(*argument_types[i]); } else { attributes[atribs_tipos[i]]=argument_types[i]. getCodeDefinition(SchemaParser::XML_DEFINITION,atribs_tipos[i]); } } for(i=Operator::OPER_COMMUTATOR; i <= Operator::OPER_NEGATOR; i++) { if(operators[i]) { if(def_type==SchemaParser::SQL_DEFINITION) attributes[atribs_ops[i]]=operators[i]->getName(true); else { operators[i]->attributes[ParsersAttributes::REF_TYPE]=atribs_ops[i]; attributes[atribs_ops[i]]=operators[i]->getCodeDefinition(def_type, true); } } } for(i=Operator::FUNC_OPERATOR; i <= Operator::FUNC_RESTRICT; i++) { if(functions[i]) { if(def_type==SchemaParser::SQL_DEFINITION) attributes[atribs_funcoes[i]]=functions[i]->getName(true); else { functions[i]->setAttribute(ParsersAttributes::REF_TYPE, atribs_funcoes[i]); attributes[atribs_funcoes[i]]=functions[i]->getCodeDefinition(def_type, true); } } } attributes[ParsersAttributes::HASHES]=(hashes ? "1" : ""); attributes[ParsersAttributes::MERGES]=(merges ? "1" : ""); attributes[ParsersAttributes::SIGNATURE]=getSignature(); return(BaseObject::getCodeDefinition(def_type, reduced_form)); }
/*++ * @method: oAuth::getOAuthHeader * * @description: this method builds OAuth header that should be used in HTTP requests to twitter * * @input: eType - HTTP request type * rawUrl - raw url of the HTTP request * rawData - HTTP data (post fields) * includeOAuthVerifierPin - flag to indicate whether or not oauth_verifier needs to included * in OAuth header * * @output: oAuthHttpHeader - OAuth header * *--*/ bool oAuth::getOAuthHeader( const eOAuthHttpRequestType eType, const std::string& rawUrl, const std::string& rawData, std::string& oAuthHttpHeader, const bool includeOAuthVerifierPin ) { oAuthKeyValuePairs rawKeyValuePairs; std::string rawParams; // MDM Made this a member so it could be read if needed. // std::string oauthSignature; m_oAuthSignature = ""; std::string paramsSeperator; std::string pureUrl( rawUrl ); /* Clear header string initially */ oAuthHttpHeader = ""; rawKeyValuePairs.clear(); /* If URL itself contains ?key=value, then extract and put them in map */ size_t nPos = rawUrl.find_first_of( "?" ); if( std::string::npos != nPos ) { /* Get only URL */ pureUrl = rawUrl.substr( 0, nPos ); /* Get only key=value data part */ std::string dataPart = rawUrl.substr( nPos + 1 ); /* Split the data in URL as key=value pairs */ buildOAuthRawDataKeyValPairs( dataPart, true, rawKeyValuePairs ); } /* Split the raw data if it's present, as key=value pairs. Data should already be urlencoded once */ buildOAuthRawDataKeyValPairs( rawData, false, rawKeyValuePairs ); /* Build key-value pairs needed for OAuth request token, without signature */ buildOAuthTokenKeyValuePairs( includeOAuthVerifierPin, rawKeyValuePairs, true ); /* Get url encoded base64 signature using request type, url and parameters */ getSignature( eType, pureUrl, rawKeyValuePairs ); /* Clear map so that the parameters themselves are not sent along with the OAuth values */ rawKeyValuePairs.clear(); /* Now, again build key-value pairs with signature this time */ buildOAuthTokenKeyValuePairs( includeOAuthVerifierPin, rawKeyValuePairs, false ); /* Get OAuth header in string format */ paramsSeperator = ","; getStringFromOAuthKeyValuePairs( rawKeyValuePairs, rawParams, paramsSeperator ); /* Build authorization header */ oAuthHttpHeader.assign( oAuthLibDefaults::OAUTHLIB_AUTHHEADER_STRING ); oAuthHttpHeader.append( rawParams ); return !oAuthHttpHeader.empty(); }
bool Data::operator==(const Data& other) const { return getName() == other.getName() && getMetaInfo() == other.getMetaInfo() && getContent() == other.getContent() && getSignature() == other.getSignature(); }
inline bool operator== (const ::Datagram::DatagramKey::Reader& a, const ::Datagram::DatagramKey::Reader& b) { if (a.getKey().which() != b.getKey().which()) return false; if (a.getKey().isContestKey()) { auto ac = a.getKey().getContestKey().getCreator(); auto bc = b.getKey().getContestKey().getCreator(); if (ac.which() != bc.which()) return false; if (ac.isAnonymous()) return bc.isAnonymous(); return ac.getSignature().getId() == bc.getSignature().getId() && ac.getSignature().getSignature() == bc.getSignature().getSignature(); } auto ad = a.getKey().getDecisionKey().getBalanceId(); auto bd = b.getKey().getDecisionKey().getBalanceId(); return ad.getAccountInstance() == bd.getAccountInstance() && ad.getCoinInstance() == bd.getCoinInstance(); }
string JavaMethodInfo::getFQN(){ string methodName(getClass()->getName()); methodName+="#"; methodName+=getName(); methodName+=getSignature(); return methodName; }
ULXR_API_IMPL(Value) MethodCall::getParam(unsigned ind) const { if (ind < params.size() ) return params[ind]; throw ParameterException(InvalidMethodParameterError, ulxr_i18n(ULXR_PCHAR("Not enough actual parameters for call to method: ") +getSignature())); }
/*++ * @method: oAuth::getOAuthHeader * * @description: this method builds OAuth header that should be used in HTTP requests to twitter * * @input: eType - HTTP request type * rawUrl - raw url of the HTTP request * rawData - HTTP data * includeOAuthVerifierPin - flag to indicate whether or not oauth_verifier needs to included * in OAuth header * * @output: oAuthHttpHeader - OAuth header * *--*/ bool oAuth::getOAuthHeader( const eOAuthHttpRequestType eType, const std::string& rawUrl, const std::string& rawData, std::string& oAuthHttpHeader, const bool includeOAuthVerifierPin ) { oAuthKeyValuePairs rawKeyValuePairs; std::string rawParams( "" ); std::string oauthSignature( "" ); std::string paramsSeperator( "" ); std::string pureUrl( rawUrl ); /* Clear header string initially */ oAuthHttpHeader.assign( "" ); rawKeyValuePairs.clear(); /* If URL itself contains ?key=value, then extract and put them in map */ size_t nPos = rawUrl.find_first_of( "?" ); if( std::string::npos != nPos ) { /* Get only URL */ pureUrl = rawUrl.substr( 0, nPos ); /* Get only key=value data part */ std::string dataPart = rawUrl.substr( nPos + 1 ); size_t nPos2 = dataPart.find_first_of( "=" ); if( std::string::npos != nPos2 ) { std::string dataKey = dataPart.substr( 0, nPos2 ); std::string dataVal = dataPart.substr( nPos2 + 1 ); /* Put this key=value pair in map */ rawKeyValuePairs[dataKey] = urlencode( dataVal ); } } /* Build key-value pairs needed for OAuth request token, without signature */ buildOAuthTokenKeyValuePairs( includeOAuthVerifierPin, rawData, std::string( "" ), rawKeyValuePairs ); /* Get url encoded base64 signature using request type, url and parameters */ getSignature( eType, pureUrl, rawKeyValuePairs, oauthSignature ); /* Now, again build key-value pairs with signature this time */ buildOAuthTokenKeyValuePairs( includeOAuthVerifierPin, std::string( "" ), oauthSignature, rawKeyValuePairs ); /* Get OAuth header in string format */ paramsSeperator = ","; getStringFromOAuthKeyValuePairs( rawKeyValuePairs, rawParams, paramsSeperator ); /* Build authorization header */ oAuthHttpHeader.assign( oAuthLibDefaults::OAUTHLIB_AUTHHEADER_STRING.c_str() ); oAuthHttpHeader.append( rawParams.c_str() ); return ( oAuthHttpHeader.length() > 0 ) ? true : false; }
vector< int > & HashedDB::fastKNNSearch1 ( vector<int>& permutations, int beam ) { vector<int> sortBuffer ( nSignatures ); vector<int> *result = new vector<int> ( beam ); for ( int i = 0; i < nSignatures; i++ ) sortBuffer[i] = i; if (signatureLength > 0) cerr << "before sort " << *sortBuffer.begin() << " " ; getSignature(*(sortBuffer.begin()+1)).print(getSignature(*(sortBuffer.begin()+1)).bitCount(), 20 ); getSignature(60996).print(60996, 20); nth_element ( sortBuffer.begin(), sortBuffer.begin() + beam, sortBuffer.end(), (comparePermutedSignatures ( permutations, *this ) ) ); cerr << "after sort " << *sortBuffer.begin() << " " ; getSignature(*(sortBuffer.begin()+1)).print(getSignature(*(sortBuffer.begin()+1)).bitCount(), 20 ); copy ( sortBuffer.begin(), sortBuffer.begin() + beam, (*result).begin() ); return *result; }
Node<MethodNode>::Link TypeParser::method(Visibility vis, bool isStatic, bool isForeign) { Trace methTrace = current().trace; auto parsedAsFunc = function(isForeign); auto methNode = Node<MethodNode>::make(parsedAsFunc->getIdentifier(), parsedAsFunc->getSignature(), vis, isStatic); methNode->setTrace(methTrace); if (isForeign) { expectSemi(); } else { methNode->setCode(Node<BlockNode>::staticPtrCast(parsedAsFunc->removeChild(0))); } return methNode; }
QString Table::createInsertCommand(const QStringList &col_names, const QStringList &values) { QString fmt_cmd, insert_cmd = QString("INSERT INTO %1 (%2) VALUES (%3);\n%4"); QStringList val_list, col_list; int curr_col=0; for(QString col_name : col_names) col_list.push_back(BaseObject::formatName(col_name)); for(QString value : values) { //Empty values as considered as DEFAULT if(value.isEmpty()) { value=QString("DEFAULT"); } //Unescaped values will not be enclosed in quotes else if(value.startsWith(PgModelerNS::UNESC_VALUE_START) && value.endsWith(PgModelerNS::UNESC_VALUE_END)) { value.remove(0,1); value.remove(value.length()-1, 1); } //Quoting value else { value.replace(QString("\\") + PgModelerNS::UNESC_VALUE_START, PgModelerNS::UNESC_VALUE_START); value.replace(QString("\\") + PgModelerNS::UNESC_VALUE_END, PgModelerNS::UNESC_VALUE_END); value.replace(QString("\'"), QString("''")); value.replace(QChar(QChar::LineFeed), QString("\\n")); value=QString("E'") + value + QString("'"); } val_list.push_back(value); } if(!col_list.isEmpty() && !val_list.isEmpty()) { //If the set of values is greater than the set of columns it will be truncated if(val_list.size() > col_list.size()) val_list.erase(val_list.begin() + col_list.size(), val_list.end()); //If the set of columns is greater than the set of values than DEFAULT values will be provided else if(col_list.size() > val_list.size()) { for(curr_col = val_list.size(); curr_col < col_list.size(); curr_col++) val_list.append(QString("DEFAULT")); } fmt_cmd=insert_cmd.arg(getSignature()).arg(col_list.join(", ")) .arg(val_list.join(", ")).arg(ParsersAttributes::DDL_END_TOKEN); } return(fmt_cmd); }
JavaObjectMethod* JavaObjectMethod::createFromInternalMethod(JavaMethod* meth, int i) { JavaObjectMethod* ret = 0; JavaString* str = 0; JavaObject* pArr = 0; JavaObject* eArr = 0; JavaObject* retTy = 0; ArraySInt8* ann = 0; ArraySInt8* pmAnn = 0; ArraySInt8* defAnn = 0; llvm_gcroot(ret, 0); llvm_gcroot(str, 0); llvm_gcroot(pArr, 0); llvm_gcroot(eArr, 0); llvm_gcroot(retTy, 0); llvm_gcroot(ann, 0); llvm_gcroot(pmAnn, 0); llvm_gcroot(defAnn, 0); // TODO: check parameter types Jnjvm* vm = JavaThread::get()->getJVM(); JnjvmClassLoader * classLoader = meth->classDef->classLoader; UserClass* Meth = vm->upcalls->newMethod; ret = (JavaObjectMethod*)Meth->doNew(vm); str = vm->internalUTF8ToStr(meth->name); pArr = meth->getParameterTypes(classLoader); eArr = meth->getExceptionTypes(classLoader); retTy = meth->getReturnType(classLoader); JavaString ** sig = getSignature(meth); ann = getAnnotations(meth); pmAnn = getParamAnnotations(meth); defAnn = getAnnotationDefault(meth); JavaObject* const* Cl = meth->classDef->getClassDelegateePtr(vm); vm->upcalls->initMethod->invokeIntSpecial(vm, Meth, ret, Cl, /* declaring class */ &str, /* name */ &pArr, /* parameter types */ &retTy, /* return type */ &eArr, /* exceptions */ meth->access, /* modifiers */ i, /* slot */ sig, /* signature */ &ann, /* annotations */ &pmAnn, /* parameter annotations */ &defAnn); /* default annotations */ return ret; }
/* * After filling in a structure it is added to the multi-level symbol * table. We keep a skip list of similarly named function symbols. * This speeds up searching provided the modules adhere to the * structure and group the functions as well. */ void insertSymbol(Module scope, Symbol prg){ InstrPtr sig; int t; Module c; assert(scope); sig = getSignature(prg); #ifdef _DEBUG_MODULE_ fprintf(stderr,"#insertSymbol: %s.%s in %s ", getModuleId(sig), getFunctionId(sig), scope->name); #endif if(getModuleId(sig) && getModuleId(sig)!= scope->name){ /* move the definition to the proper place */ /* default scope is the last resort */ c= findModule(scope,getModuleId(sig)); if ( c ) scope = c; #ifdef _DEBUG_MODULE_ fprintf(stderr," found alternative module %s ", scope->name); #endif } t = getSymbolIndex(getFunctionId(sig)); if( scope->space == NULL) { scope->space = (Symbol *) GDKzalloc(MAXSCOPE * sizeof(Symbol)); if (scope->space == NULL) return; } assert(scope->space); if (scope->space[t] == prg){ /* already known, last inserted */ #ifdef _DEBUG_MODULE_ fprintf(stderr," unexpected double insert "); #endif } else { prg->peer= scope->space[t]; scope->space[t] = prg; if( prg->peer && idcmp(prg->name,prg->peer->name) == 0) prg->skip = prg->peer->skip; else prg->skip = prg->peer; } assert(prg != prg->peer); #ifdef _DEBUG_MODULE_ fprintf(stderr,"\n"); #endif }
void printSignature(stream *fd, Symbol s, int flg) { InstrPtr p; str txt; if ( s->def == 0 ){ mnstr_printf(fd, "missing definition of %s\n", s->name); return; } txt = GDKzalloc(MAXLISTING); /* some slack for large blocks */ if( txt){ p = getSignature(s); (void) fcnDefinition(s->def, p, txt, flg, txt, MAXLISTING); mnstr_printf(fd, "%s\n", txt); GDKfree(txt); } else mnstr_printf(fd, "printSignature: " MAL_MALLOC_FAIL); }
JavaObjectField* JavaObjectField::createFromInternalField(JavaField* field, int i) { JavaObjectField* ret = 0; JavaString* name = 0; ArraySInt8* ann = 0; llvm_gcroot(ret, 0); llvm_gcroot(name, 0); llvm_gcroot(ann, 0); // TODO: check parameter types Jnjvm* vm = JavaThread::get()->getJVM(); UserClass* Field = vm->upcalls->newField; ret = (JavaObjectField*)Field->doNew(vm); name = vm->internalUTF8ToStr(field->name); //type->Class JnjvmClassLoader* loader = field->classDef->classLoader; UserCommonClass * fieldCl = field->getSignature()->assocClass(loader); assert(fieldCl); JavaObject* const* type = fieldCl->getClassDelegateePtr(vm); JavaObject* const* Cl = field->classDef->getClassDelegateePtr(vm); JavaString** sig = getSignature(field); ann = getAnnotations(field); /* java.reflect.Field( * Class declaringClass, * String name, * Class type, * int modifiers, * int slot, * String signature, * byte[] annotations) */ vm->upcalls->initField->invokeIntSpecial(vm, Field, ret, Cl, &name, type, field->access, i, sig, &ann); return ret; }
QString RtmApi::getUrl(QString method, QString base) { if (method != "") { addParam("method", "rtm."+method); }; addParam("api_key", d->api_key); addParam("api_sig", getSignature()); QString s = "?"; QStringList ss; QMap<QString, QString>::const_iterator i = d->args.constBegin(); while (i != d->args.constEnd()) { ss << i.key() + "=" + i.value(); ++i; } s += ss.join("&"); return base+s; }
int OPTorcamImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p) { MalBlkPtr target= mb; Module s; Symbol t; str mod,fcn; int j; str msg; (void) cntxt; (void) stk; if( p->argc == 3){ mod= getArgDefault(mb,p,1); fcn= getArgDefault(mb,p,2); } else { mod= getArgDefault(mb,p,1); fcn= getArgDefault(mb,p,2); t= findSymbol(cntxt->nspace, putName(mod, strlen(mod)), fcn); if( t == 0) return 0; target= t->def; mod= getArgDefault(mb,p,3); fcn= getArgDefault(mb,p,4); } s = findModule(cntxt->nspace, putName(mod, strlen(mod))); if (s == 0) return 0; if (s->subscope) { j = getSubScope(fcn); for (t = s->subscope[j]; t != NULL; t = t->peer) if (t->def->errors == 0) { if (getSignature(t)->token == FUNCTIONsymbol) { msg =ORCAMprocessor(cntxt, target, t); if( msg) GDKfree(msg); } } } return 1; }
void Matcher<T>::run(const ca::MatchFinder::MatchResult &result) { std::string functionStr = utils::getStringByType<clang::FunctionDecl>(); std::string nodeStr = utils::getStringByType<T>(); // Get matched AST node const clang::FunctionDecl *fd = result.Nodes.getNodeAs<clang::FunctionDecl>(functionStr); const T *node = result.Nodes.getNodeAs<T>(nodeStr); // Check if node is valid if (!node || !utils::isValidStmt<T>(node)) { return; } // Check if object is valid and get function signature std::string signature = getSignature(fd); if (signature.empty()) { return; } const clang::SourceManager &sm = result.Context->getSourceManager(); const clang::SourceLocation loc = node->getLocStart(); // Fill map key FunctionId fid; fid.path = sm.getFilename(fd->getLocation()); fid.name = fd->getQualifiedNameAsString(); fid.signature = signature; fid.line = sm.getSpellingLineNumber(loc); fid.column = sm.getSpellingColumnNumber(loc); // Log match utils::logMatch(fid.path, fid.line, fid.column, nodeStr); // Increase cyclomatic number ++stats[fid].cyclomaticN; }