TBool ELFFile::GetExceptionIndexInfo(TUint32 &aOffset) { const TText * aBase = (TText *)".ARM.exidx$$Base"; const TText * aLimit = (TText *)".ARM.exidx$$Limit"; Elf32_Sym * exidxBase = FindSymbol(aBase); Elf32_Sym * exidxLimit = FindSymbol(aLimit); if (exidxBase && exidxLimit && (exidxLimit->st_value - exidxBase->st_value)) { const TText * aExceptionDescriptor = (TText *)"Symbian$$CPP$$Exception$$Descriptor"; Elf32_Sym * aED = FindSymbol(aExceptionDescriptor); if (aED) { // Set bottom bit so 0 in header slot means an old binary. // The decriptor is always aligned on a 4 byte boundary. aOffset = (aED->st_value - iLinkedBase) | 0x00000001; return ETrue; } else { Print(EPeError,"Executable has exception table but no exception descriptor\n"); exit(666); } } return EFalse; }
void Load_FunctionProc () { CFragConnectionID connectionID; Ptr mainAddress; Str255 errorString; OSErr anErr; if (nil == tCallUniversalProcProcPtr) /* if it's not defined yet */ { /* Resolve the symbol against InterfaceLib. */ anErr = GetSharedLibrary("\pInterfaceLib",kPowerPCCFragArch, kFindCFrag, &connectionID, &mainAddress, errorString); if (noErr == anErr) { CFragSymbolClass symbolClass; anErr = FindSymbol(connectionID, "\pCallUniversalProc", (Ptr *) &tCallUniversalProcProcPtr,&symbolClass); if (noErr != anErr) tCallUniversalProcProcPtr = nil; anErr = FindSymbol(connectionID,"\pNewRoutineDescriptor", (Ptr *) &tNewRoutineDescriptorProcPtr,&symbolClass); if (noErr != anErr) tNewRoutineDescriptorProcPtr = nil; anErr = FindSymbol(connectionID,"\pDisposeRoutineDescriptor", (Ptr *)&tDisposeRoutineDescriptorProcPtr,&symbolClass); if (noErr != anErr) tDisposeRoutineDescriptorProcPtr = nil; } }
void HandleTranslationUnit(ASTContext &Context) override { const SourceManager &SourceMgr = Context.getSourceManager(); for (unsigned Offset : SymbolOffsets) { if (!FindSymbol(Context, SourceMgr, Offset, "")) return; } for (const std::string &QualifiedName : QualifiedNames) { if (!FindSymbol(Context, SourceMgr, 0, QualifiedName)) return; } }
//--------------------------------------------------------------------------- // FindSymbol // // This function looks for a symbol in the symbol tree, and returns a pointer // to the node if found. // // RETURNS: Pointer if found, NULL if not found //--------------------------------------------------------------------------- SYMNODE * NEAR FindSymbol (SYMNODE *pTree, LPSTR szSym) { register INT i; if (pTree) { i = _fstricmp (pTree->szSym, szSym); if (!i) return (pTree); if (i < 0) return (FindSymbol (pTree->left, szSym)); return (FindSymbol (pTree->right, szSym)); } return (NULL); }
/******************************************************************************* NAME : PPDefmessageHandlerCommand DESCRIPTION : Displays the pretty-print form (if any) for a handler INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : None NOTES : H/L Syntax: (ppdefmessage-handler <class> <message> [<type>]) *******************************************************************************/ globle void PPDefmessageHandlerCommand() { DATA_OBJECT temp; SYMBOL_HN *csym,*msym; char *tname; DEFCLASS *cls = NULL; int mtype; HANDLER *hnd; if (ArgTypeCheck("ppdefmessage-handler",1,SYMBOL,&temp) == FALSE) return; csym = FindSymbol(DOToString(temp)); if (ArgTypeCheck("ppdefmessage-handler",2,SYMBOL,&temp) == FALSE) return; msym = FindSymbol(DOToString(temp)); if (RtnArgCount() == 3) { if (ArgTypeCheck("ppdefmessage-handler",3,SYMBOL,&temp) == FALSE) return; tname = DOToString(temp); } else tname = hndquals[MPRIMARY]; mtype = HandlerType("ppdefmessage-handler",tname); if (mtype == MERROR) { SetEvaluationError(TRUE); return; } if (csym != NULL) cls = LookupDefclassByMdlOrScope(ValueToString(csym)); if (((cls == NULL) || (msym == NULL)) ? TRUE : ((hnd = FindHandlerByAddress(cls,msym,(unsigned) mtype)) == NULL)) { PrintErrorID("MSGCOM",2,FALSE); PrintRouter(WERROR,"Unable to find message-handler "); PrintRouter(WERROR,ValueToString(msym)); PrintRouter(WERROR," "); PrintRouter(WERROR,tname); PrintRouter(WERROR," for class "); PrintRouter(WERROR,ValueToString(csym)); PrintRouter(WERROR," in function ppdefmessage-handler.\n"); SetEvaluationError(TRUE); return; } if (hnd->ppForm != NULL) PrintInChunks(WDISPLAY,hnd->ppForm); }
static char *NewSymbol(char *string) { SymbolPtr symbol; // Look for string in the list of symbols. symbol = FindSymbol(string, 0); // Add the new symbol. if (symbol == 0) { symbol = AllocateBootXMemory(sizeof(Symbol) + strlen(string)); if (symbol == 0) return 0; // Set the symbol's data. symbol->refCount = 0; strcpy(symbol->string, string); // Add the symbol to the list. symbol->next = gSymbolsHead; gSymbolsHead = symbol; } // Update the refCount and return the string. symbol->refCount++; return symbol->string; }
//----------------------------------------------------------------------------- void *DynamicLibrary::getProcAddress( const char *function ) { OSErr err = noErr; void *fnAddress = NULL; #if defined(TORQUE_OS_MAC_CARB) if (platState.osX) { CFStringRef str = CFStringCreateWithCString(NULL, function, kCFStringEncodingMacRoman); fnAddress = CFBundleGetFunctionPointerForName( (CFBundleRef)hInst, str ); if (fnAddress == NULL) err = cfragNoSymbolErr; CFRelease(str); } else #endif { err = FindSymbol((CFragConnectionID)hInst, str2p(function), (char**)&fnAddress, NULL); } if (!fnAddress) { if (mErrorReport) Con::errorf("DynamicLibrary: function '%s' not found!", function); mError = true; } return fnAddress; }
/********************************************************* NAME : SlotInfoSlot DESCRIPTION : Runtime support routine for slot-sources, slot-facets, et. al. which looks up a slot INPUTS : 1) Data object buffer 2) Class pointer 3) Name-string of slot to find 4) The name of the calling function RETURNS : Nothing useful SIDE EFFECTS : Support function called and data object buffer initialized NOTES : None *********************************************************/ static SLOT_DESC *SlotInfoSlot( DATA_OBJECT *result, DEFCLASS *cls, char *sname, char *fnxname) { SYMBOL_HN *ssym; int i; if ((ssym = FindSymbol(sname)) == NULL) { SetEvaluationError(TRUE); SetMultifieldErrorValue(result); return(NULL); } i = FindInstanceTemplateSlot(cls,ssym); if (i == -1) { SlotExistError(sname,fnxname); SetEvaluationError(TRUE); SetMultifieldErrorValue(result); return(NULL); } result->type = MULTIFIELD; result->begin = 0; return(cls->instanceTemplate[i]); }
bool IsWtk( instruction * curr_ins ) //================================= { operand * op = &curr_ins->op[ curr_ins->mem_ref_op ]; char * sym = FindSymbol( InsAddr + op->offset ); bool retn = false; if( /* Pass == 2 && so that didAnyWtk can be set */ ( Options & FORM_DO_WTK ) ) { if( strstr( sym, WTLBASEStr ) != NULL ) { fixup * fix = FindFixup( InsAddr + op->offset, Segment ); if( fix != NULL ) { WtkAddr = fix->imp_address + ( fix->seg_address << 4 ); retn = true; } } else if( WtlsegPresent && ( curr_ins->pref & PREF_FS ) && curr_ins->seg_used == FS_REG && sym == NULL ) { WtkAddr = op->disp; retn = true; } } if( retn ) { didAnyWtk = true; } if( Pass == 2 ) { return( retn ); } else { return( false ); } }
CHAR8* NewSymbol(CHAR8* string) { SymbolPtr lastGuy = 0; SymbolPtr symbol; // Look for string in the list of symbols. symbol = FindSymbol(string, 0); // Add the new symbol. if (symbol == NULL) { symbol = (SymbolPtr)AllocateZeroPool(sizeof(Symbol) + 1 + AsciiStrLen(string)); if (symbol == NULL) return NULL; // Set the symbol's data. symbol->refCount = 0; AsciiStrCpy(symbol->string, string); // Add the symbol to the list. symbol->next = gSymbolsHead; gSymbolsHead = symbol; } // Update the refCount and return the string. symbol->refCount++; if (lastGuy && lastGuy->next != 0) return NULL; return symbol->string; }
int CInterpreter::GetTag( CBlock *block ) { char typeName[MAX_STRING_SIZE]; int typeID; //Mark as a tag block->Write( ID_TAG, (float) ID_TAG ); if (!Match( TK_OPEN_PARENTHESIS )) return Error("syntax error : '(' not found"); //Get the tag name if ( GetString( block ) == false ) return false; //Get the lookup ID GetType( (char *) typeName ); typeID = FindSymbol( (char *) typeName, m_typeKeywords); //Tags only contain origin and angles lookups if ( (typeID != TYPE_ORIGIN) && (typeID != TYPE_ANGLES) ) { return Error("syntax error : 'tag' : %s is not a valid look up identifier", typeName ); } block->Write( TK_FLOAT, (float) typeID ); if (!Match( TK_CLOSED_PARENTHESIS )) return Error("tag : too many parameters"); return true; }
//--------------------------------------------------------------------------- // RemoveSymbol // // This function looks for a defined symbol, and if found, turns it's flag // off so that it isn't really defined. // // RETURNS: Nothing //--------------------------------------------------------------------------- VOID NEAR RemoveSymbol (SYMNODE *pRoot, LPSTR szSym) { SYMNODE *pTree; if (pTree = FindSymbol (pRoot, szSym)) pTree->fDef = FALSE; }
static char * NewSymbol( char * string ) { static SymbolPtr lastGuy = 0; SymbolPtr symbol; // Look for string in the list of symbols. symbol = FindSymbol(string, 0); // Add the new symbol. if (symbol == 0) { symbol = (SymbolPtr)malloc(sizeof(Symbol) + 1 + strlen(string)); if (symbol == 0) //return 0; stop("NULL symbol!"); // Set the symbol's data. symbol->refCount = 0; strcpy(symbol->string, string); // Add the symbol to the list. symbol->next = gSymbolsHead; gSymbolsHead = symbol; } // Update the refCount and return the string. symbol->refCount++; if (lastGuy && lastGuy->next != 0) stop("last guy not last!"); return symbol->string; }
/* AddGlobal - add a symbol to a global symbol table */ static Symbol *AddGlobal(ParseContext *c, SymbolTable *table, const char *name, StorageClass storageClass, Type *type, VMUVALUE offset) { size_t size = sizeof(Symbol) + strlen(name); Symbol *sym; /* check for a duplicate symbol name */ if ((sym = FindSymbol(table, name)) != NULL) ParseError(c, "duplicate symbol '%s'", name); /* allocate the symbol structure */ sym = (Symbol *)GlobalAlloc(c, size); strcpy(sym->name, name); sym->storageClass = storageClass; sym->section = NULL; sym->type = type; sym->v.variable.offset = offset; sym->v.variable.fixups = 0; sym->next = NULL; /* add it to the symbol table */ *table->pTail = sym; table->pTail = &sym->next; ++table->count; /* return the symbol */ return sym; }
int ProcessExpress(char *instring) /*对原表达式进行预处理*/ { int len,pos; inlength=-1; parencount=0; tokencount=LASTOPERAND; len=strlen(instring); instring[len]='\0'; for (pos=0;pos<len;) { if (instring[pos]==' ') /*忽略空格字符*/ pos++; else if (isalpha(instring[pos])) /*处理字母*/ pos=FindWord(instring,pos); else if (isdigit(instring[pos]) || instring[pos]=='.') /*处理数字*/ pos=FindNumber(instring,pos); else /*处理符号*/ pos=FindSymbol(instring,pos); if (pos==-1) return 0; } if (parencount!=0) printf("左右括号不匹配\n"); PutToken(0); /*在infix中添加ENDEXPR*/ return 1; }
/* AddLocal - add a symbol to the symbol table */ Symbol *AddLocal(ParseContext *c, const char *name, Type *type, VMUVALUE offset) { SymbolTable *table = &c->function->u.functionDefinition.locals; size_t size = sizeof(Symbol) + strlen(name); Symbol *sym; /* check for a duplicate symbol name */ if ((sym = FindSymbol(table, name)) != NULL) ParseError(c, "duplicate symbol '%s'", name); /* allocate the symbol structure */ sym = (Symbol *)xbLocalAlloc(c->sys, size); strcpy(sym->name, name); sym->storageClass = SC_LOCAL; sym->section = NULL; sym->type = type; sym->v.variable.offset = offset; sym->next = NULL; /* add it to the symbol table */ *table->pTail = sym; table->pTail = &sym->next; ++table->count; /* return the symbol */ return sym; }
void *wxDynamicLibrary::DoGetSymbol(const wxString &name, bool *success) const { wxCHECK_MSG( IsLoaded(), NULL, _T("Can't load symbol from unloaded library") ); void *symbol = 0; wxUnusedVar(symbol); #if defined(__WXMAC__) && !defined(__DARWIN__) Ptr symAddress; CFragSymbolClass symClass; Str255 symName; #if TARGET_CARBON c2pstrcpy( (StringPtr) symName, name.fn_str() ); #else strcpy( (char *)symName, name.fn_str() ); c2pstr( (char *)symName ); #endif if( FindSymbol( m_handle, symName, &symAddress, &symClass ) == noErr ) symbol = (void *)symAddress; #elif defined(__WXPM__) || defined(__EMX__) DosQueryProcAddr( m_handle, 1L, (PSZ)name.c_str(), (PFN*)symbol ); #else symbol = RawGetSymbol(m_handle, name); #endif if ( success ) *success = symbol != NULL; return symbol; }
static void FreeSymbol(char *string) { SymbolPtr symbol, prev; prev = 0; // Look for string in the list of symbols. symbol = FindSymbol(string, &prev); if (symbol == 0) { return; } // Update the refCount. symbol->refCount--; if (symbol->refCount != 0) { return; } // Remove the symbol from the list. if (prev != 0) { prev->next = symbol->next; } else { gSymbolsHead = symbol->next; } // Free the symbol's memory. free(symbol); }
globle int UndefineFunction( char *functionName) { SYMBOL_HN *findValue; struct FunctionDefinition *fPtr, *lastPtr = NULL; findValue = (SYMBOL_HN *) FindSymbol(functionName); for (fPtr = ListOfFunctions; fPtr != NULL; fPtr = fPtr->next) { if (fPtr->callFunctionName == findValue) { DecrementSymbolCount(fPtr->callFunctionName); RemoveHashFunction(fPtr); if (lastPtr == NULL) { ListOfFunctions = fPtr->next; } else { lastPtr->next = fPtr->next; } rtn_struct(FunctionDefinition,fPtr); return(TRUE); } lastPtr = fPtr; } return(FALSE); }
LinkExpression *LinkExpression::Eval(int section, int base, ObjInt offset) { if (left) left = left->Eval(section, base, offset); if (right) right = right->Eval(section, base, offset); LinkExpression *rv = this; switch(op) { case ePC: delete rv; rv = new LinkExpression(section, base, offset); break; case eSymbol: { LinkExpressionSymbol *exp = FindSymbol(symbolName); if (!exp) { LinkManager::LinkError("Variable "+symbolName+" is undefined"); } else { delete rv; rv = new LinkExpression(*(exp->GetValue())); } break; } } return rv; }
/*************************************************** NAME : Send DESCRIPTION : C Interface for sending messages to instances INPUTS : 1) The data object of the instance 2) The message name-string 3) The message arguments string (Constants only) 4) Caller's buffer for result RETURNS : Nothing useful SIDE EFFECTS : Executes message and stores result caller's buffer NOTES : None ***************************************************/ globle void Send( DATA_OBJECT *idata, char *msg, char *args, DATA_OBJECT *result) { int error; EXPRESSION *iexp; SYMBOL_HN *msym; SetEvaluationError(FALSE); result->type = SYMBOL; result->value = FalseSymbol; msym = FindSymbol(msg); if (msym == NULL) { PrintNoHandlerError(msg); SetEvaluationError(TRUE); return; } iexp = GenConstant(idata->type,idata->value); iexp->nextArg = ParseConstantArguments(args,&error); if (error == TRUE) { ReturnExpression(iexp); SetEvaluationError(TRUE); return; } PerformMessage(result,iexp,msym); ReturnExpression(iexp); if ((CurrentEvaluationDepth == 0) && (! EvaluatingTopLevelCommand) && (CurrentExpression == NULL)) { PeriodicCleanup(TRUE,FALSE); } }
void ReportID(char *id) { Symbol *sym; char str[100]; if (sym=FindSymbol(0,id)) FormatSymbol(str,sym); else strcpy(str,"--- Null Symbol ---"); message(str); }
VMFunction *PClass::FindFunction(FName clsname, FName funcname) { auto cls = PClass::FindClass(clsname); if (!cls) return nullptr; auto func = dyn_cast<PFunction>(cls->FindSymbol(funcname, true)); if (!func) return nullptr; return func->Variants[0].Implementation; }
//--------------------------------------------------------------------------- // IsDefined // // This function determines if the given symbol is defined in the symbol tree // // RETURNS: TRUE if symbol defined, FALSE if not //--------------------------------------------------------------------------- BOOL NEAR IsDefined (SYMNODE *pRoot, LPSTR szSym) { SYMNODE *pTree; if (pTree = FindSymbol (pRoot, szSym)) return (pTree->fDef); return (FALSE); }
void PClass::FindFunction(VMFunction **pptr, FName clsname, FName funcname) { auto cls = PClass::FindClass(clsname); if (!cls) return; auto func = dyn_cast<PFunction>(cls->FindSymbol(funcname, true)); if (!func) return; *pptr = func->Variants[0].Implementation; FunctionPtrList.Push(pptr); }
CPointer* CBinaryFile::FindAddress(object oIdentifier) { #ifdef _WIN32 if(CheckClassname(oIdentifier, "bytes")) return FindSignature(oIdentifier); #endif return FindSymbol(extract<char*>(oIdentifier)); }
bool JniInvocation::Init(const char* library) { #ifdef __ANDROID__ char buffer[PROPERTY_VALUE_MAX]; #else char* buffer = NULL; #endif library = GetLibrary(library, buffer); handle_ = dlopen(library, RTLD_NOW); if (handle_ == NULL) { if (strcmp(library, kLibraryFallback) == 0) { // Nothing else to try. ALOGE("Failed to dlopen %s: %s", library, dlerror()); return false; } // Note that this is enough to get something like the zygote // running, we can't property_set here to fix this for the future // because we are root and not the system user. See // RuntimeInit.commonInit for where we fix up the property to // avoid future fallbacks. http://b/11463182 ALOGW("Falling back from %s to %s after dlopen error: %s", library, kLibraryFallback, dlerror()); library = kLibraryFallback; handle_ = dlopen(library, RTLD_NOW); if (handle_ == NULL) { ALOGE("Failed to dlopen %s: %s", library, dlerror()); return false; } } if (!FindSymbol(reinterpret_cast<void**>(&JNI_GetDefaultJavaVMInitArgs_), "JNI_GetDefaultJavaVMInitArgs")) { return false; } if (!FindSymbol(reinterpret_cast<void**>(&JNI_CreateJavaVM_), "JNI_CreateJavaVM")) { return false; } if (!FindSymbol(reinterpret_cast<void**>(&JNI_GetCreatedJavaVMs_), "JNI_GetCreatedJavaVMs")) { return false; } return true; }
SReference SExpressionHashPackage::Intern(const char *name) { SReference ret = FindSymbol(name); if(ret.GetPtr() == EmptySlotMark.GetPtr()) { // Now we create a new symbol ret = CreateNewSymbolObject(name); AddItem(name, ret); } return ret; }
bool PassParser::Parse(Lexer* lexer, const boost::filesystem::path& dir) { m_rootDir = dir; Token token = lexer->CurToken(); if(token.type != Token::token_id) { Error(token.line, "unexpected token: '" + token.str + "'"); return false; } m_name = token.str; if(FindSymbol(m_name, true) != nullptr) { Error(token.line, "object '" + m_name + "' already defined."); return false; } token = lexer->NextToken(); if(token.str != "{") { Error(token.line, "unexpected token: '" + token.str + "'"); return false; } token = lexer->NextToken(); while(true) { if(ParseFunctionCall(lexer) == false) { return false; } if(lexer->CurToken().str == "}") { break; } } token = lexer->NextToken(); if(token.str == ";") { lexer->SkipToken(token); } return true; }
OSErr SetData(unsigned long value) { OSErr error; SymClass symClass; long myCount; short myIndex; Str255 myName; Ptr myAddr; error = FindSymbol(connID, transportGlobalsName, (char**)&hSer, &symClass); // Find the global if (error == noErr) { // Found it; make it nil *hSer = value; } return error; }