MCPcopy Create free account
hub / github.com/N64Recomp/N64Recomp / Context

Class Context

include/recompiler/context.h:211–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209 };
210
211 class Context {
212 private:
213 //// Reference symbols (used for populating relocations for patches)
214 // A list of the sections that contain the reference symbols.
215 std::vector<ReferenceSection> reference_sections;
216 // A list of the reference symbols.
217 std::vector<ReferenceSymbol> reference_symbols;
218 // Mapping of symbol name to reference symbol index.
219 std::unordered_map<std::string, SymbolReference> reference_symbols_by_name;
220 // Whether all reference sections should be treated as relocatable (used in live recompilation).
221 bool all_reference_sections_relocatable = false;
222 public:
223 std::vector<Section> sections;
224 std::vector<Function> functions;
225 // A list of the list of each function (by index in `functions`) in a given section
226 std::vector<std::vector<size_t>> section_functions;
227 // A mapping of vram address to every function with that address.
228 std::unordered_map<uint32_t, std::vector<size_t>> functions_by_vram;
229 // A mapping of bss section index to the corresponding non-bss section index.
230 std::unordered_map<uint16_t, uint16_t> bss_section_to_section;
231 // The target ROM being recompiled, TODO move this outside of the context to avoid making a copy for mod contexts.
232 // Used for reading relocations and for the output binary feature.
233 std::vector<uint8_t> rom;
234 // Whether reference symbols should be validated when emitting function calls during recompilation.
235 bool skip_validating_reference_symbols = true;
236 // Whether all function calls (excluding reference symbols) should go through lookup.
237 bool use_lookup_for_all_function_calls = false;
238
239 //// Only used by the CLI, TODO move this to a struct in the internal headers.
240 // A mapping of function name to index in the functions vector
241 std::unordered_map<std::string, size_t> functions_by_name;
242
243 //// Mod dependencies and their symbols
244
245 //// Imported values
246 // Dependency names.
247 std::vector<std::string> dependencies;
248 // Mapping of dependency name to dependency index.
249 std::unordered_map<std::string, size_t> dependencies_by_name;
250 // List of symbols imported from dependencies.
251 std::vector<ImportSymbol> import_symbols;
252 // List of events imported from dependencies.
253 std::vector<DependencyEvent> dependency_events;
254 // Mappings of dependency event name to the index in dependency_events, all indexed by dependency.
255 std::vector<std::unordered_map<std::string, size_t>> dependency_events_by_name;
256 // Mappings of dependency import name to index in import_symbols, all indexed by dependency.
257 std::vector<std::unordered_map<std::string, size_t>> dependency_imports_by_name;
258
259 //// Exported values
260 // List of function replacements, which contains the original function to replace and the function index to replace it with.
261 std::vector<FunctionReplacement> replacements;
262 // Indices of every exported function.
263 std::vector<size_t> exported_funcs;
264 // List of callbacks, which contains the function for the callback and the dependency event it attaches to.
265 std::vector<Callback> callbacks;
266 // List of symbols from events, which contains the names of events that this context provides.
267 std::vector<EventSymbol> event_symbols;
268 // List of hooks, which contains the original function to hook and the function index to call at the hook.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected