public bool TryGetMethod(string name, out SymbolBinding binding) { if (!_moduleCtx.TryGetMethod(name, out binding)) { return(_outerCtx.TryGetMethod(name, out binding)); } ShiftIndex(ref binding); return(true); }
public SymbolEntry(string name, T value, T size, SymbolBinding binding, SymbolType type, ELF <T> elf, ushort sectionIdx) { Name = name; Value = value; Size = size; Binding = binding; Type = type; this.elf = elf; this.sectionIdx = sectionIdx; }
public SymbolEntry(string name, T value, T size, SymbolVisibility visibility, SymbolBinding binding, SymbolType type, ELF <T> elf, ushort sectionIdx) { Name = name; Value = value; Size = size; Binding = binding; Type = type; Visibility = visibility; this.elf = elf; PointedSectionIndex = sectionIdx; }
public Elf32Sym(Elf32_Sym *st) { NameOffset = st->st_name; Value = st->st_value; Size = st->st_size; Info = st->st_info; Other = st->st_other; Shndx = st->st_shndx; Binding = (SymbolBinding)(Info >> 0x4); Type = (SymbolType)(Info & 0x0F); }
/// <summary> /// Initializes a new instance of the <see cref="Antmicro.Renode.Core.Symbol"/> class. /// </summary> /// <param name="start">Start.</param> /// <param name="end">End.</param> /// <param name="name">Name.</param> /// <param name="type">SymbolType.</param> /// <param name="binding">SymbolBinding.</param> /// <param name="mayBeThumb">Set to <c>true</c> if symbol is related to architecture that allows thumb symbols.</param> public Symbol(SymbolAddress start, SymbolAddress end, string name, SymbolType type = SymbolType.NotSpecified, SymbolBinding binding = SymbolBinding.Global, bool mayBeThumb = false) { if (end < start) { throw new ArgumentException(string.Format("Symbol cannot have start before the end. Input was: ({0},{1})", start, end)); } Type = type; Binding = binding; Name = DemangleSymbol(name); Start = start; End = end; thumbArchitecture = mayBeThumb; if (mayBeThumb) { UpdateIsThumbSymbol(); } }
private SymbolBinding GetSymbol(string symbol, Func<SymbolScope, int> extract) { for (int i = _scopeStack.Count - 1; i >= 0; i--) { var number = extract(_scopeStack[i]); if (number < 0) continue; var result = new SymbolBinding(); result.CodeIndex = number; result.ContextIndex = i; return result; } throw new SymbolNotFoundException(symbol); }
private SymbolBinding GetSymbol(string symbol, Func <SymbolScope, int> extract) { for (int i = _scopeStack.Count - 1; i >= 0; i--) { var number = extract(_scopeStack[i]); if (number < 0) { continue; } var result = new SymbolBinding(); result.CodeIndex = number; result.ContextIndex = i; return(result); } throw new SymbolNotFoundException(symbol); }
private bool TryGetSymbol(string symbol, Func <SymbolScope, int> extract, out SymbolBinding result) { for (int i = _scopeStack.Count - 1; i >= 0; i--) { var number = extract(_scopeStack[i]); if (number < 0) { continue; } result = new SymbolBinding(); result.CodeIndex = number; result.ContextIndex = i; return(true); } result = default(SymbolBinding); return(false); }
private void ShiftIndex(ref SymbolBinding symbolBinding) { symbolBinding.ContextIndex += OUTER_CTX_SIZE; }
/// <summary> /// Inserts a new symbol with defined parameters into the lookup structure. /// </summary> /// <param name="name">Name.</param> /// <param name="start">Start.</param> /// <param name="size">Size.</param> /// <param name="type">SymbolType.</param> /// <param name="binding">Symbol binding</param> /// <param name="isThumb">If set to <c>true</c>, symbol is marked as a thumb symbol.</param> public void InsertSymbol(string name, TAddress start, TAddress size, SymbolType type = SymbolType.NotSpecified, SymbolBinding binding = SymbolBinding.Global, bool isThumb = false) { var symbol = new Symbol(start, start + size, name, type, binding, isThumb); InsertSymbol(symbol); }
private int GetMethodRefNumber(ref SymbolBinding methodBinding) { var idx = _module.MethodRefs.IndexOf(methodBinding); if (idx < 0) { idx = _module.MethodRefs.Count; _module.MethodRefs.Add(methodBinding); } return idx; }
private void ShiftIndex(ref SymbolBinding symbolBinding) { symbolBinding.ContextIndex += OUTER_CTX_SIZE; }
public bool TryGetMethod(string name, out SymbolBinding result) { return(TryGetSymbol(name, x => ExtractMethodIndex(name, x), out result)); }
public static SymbolBinding Create(Battle context) { var ret = new SymbolBinding(); ret.Bind("BossHpPercentage", () => (int) context.Boss.HpPercentage); return ret; }
private void BuildModuleBody() { _isFunctionProcessed = false; PushStructureToken(Token.EndOfText); var entry = _module.Code.Count; _ctx.PushScope(new SymbolScope()); try { BuildCodeBatch(); } catch { _ctx.PopScope(); throw; } PopStructureToken(); var localCtx = _ctx.PopScope(); var topIdx = _ctx.TopIndex(); if (entry != _module.Code.Count) { var bodyMethod = new MethodInfo(); bodyMethod.Name = "$entry"; var descriptor = new MethodDescriptor(); descriptor.EntryPoint = entry; descriptor.Signature = bodyMethod; descriptor.VariableFrameSize = localCtx.VariableCount; var entryRefNumber = _module.MethodRefs.Count; var bodyBinding = new SymbolBinding() { ContextIndex = topIdx, CodeIndex = _module.Methods.Count }; _module.Methods.Add(descriptor); _module.MethodRefs.Add(bodyBinding); _module.EntryMethodIndex = entryRefNumber; } }
private int PushSimpleVariable(SymbolBinding binding) { if (binding.ContextIndex == _ctx.TopIndex()) { return AddCommand(OperationCode.PushLoc, binding.CodeIndex); } else { var idx = GetVariableRefNumber(ref binding); return AddCommand(OperationCode.PushVar, idx); } }
private int PushReference(SymbolBinding binding) { var idx = GetVariableRefNumber(ref binding); return AddCommand(OperationCode.PushRef, idx); }
private int GetVariableRefNumber(ref SymbolBinding binding) { var idx = _module.VariableRefs.IndexOf(binding); if (idx < 0) { idx = _module.VariableRefs.Count; _module.VariableRefs.Add(binding); } return idx; }