Interface PcodeUseropLibraryFactory
- All Superinterfaces:
ExtensionPoint
- All Known Implementing Classes:
TrigPcodeUseropLibraryFactory
The factory must have a public default constructor.
-
Nested Class Summary
Nested ClassesChangeModifier and TypeInterfaceDescriptionstatic @interfaceA required annotation for identifying the library in pspec files -
Field Summary
FieldsChangeModifier and TypeFieldDescriptionstatic final StringThe property key for useropLib ids in pspec files -
Method Summary
ChangeModifier and TypeMethodDescription<T> PcodeUseropLibrary<T> create(SleighLanguage language, PcodeArithmetic<T> arithmetic) Create the userop librarystatic <T> PcodeUseropLibrary<T> createUseropLibraryForLanguage(SleighLanguage language, PcodeArithmetic<T> arithmetic) Create the userop library for the given languagestatic <T> PcodeUseropLibrary<T> createUseropLibraryFromId(String id, SleighLanguage language, PcodeArithmetic<T> arithmetic) Create the userop library as identified for the given language and arithmeticdefault StringgetId()Get the id of this factory
-
Field Details
-
KEY_USEROP_LIBS
The property key for useropLib ids in pspec files- See Also:
-
-
Method Details
-
createUseropLibraryFromId
static <T> PcodeUseropLibrary<T> createUseropLibraryFromId(String id, SleighLanguage language, PcodeArithmetic<T> arithmetic) Create the userop library as identified for the given language and arithmeticWhile not strictly enforced by the framework, some care should be taken to ensure the library is prepared to handle the given language, since it may only expect those whose pspec files identify it. The library (or its factory) may throw an exception, or otherwise exhibit undefined behavior, if it cannot find the resources, e.g., a specific named register, that it expects.
The given arithmetic must also be compatible with both the library and the language. In particular, the language and arithmetic must agree in endianness. (The default emulator should already ensure this is the case.) The library must also understand the type of the arithmetic, i.e., the type of values in the emulator. If either is not the case the emulator may exhibit undefined behavior. (The default emulator does not guarantee type compatibility.) Ideally, such incompatibilities are checked and reported by the userop library as early as possible, e.g., in the library's constructor.
If the given id cannot be found, an empty library (
PcodeUseropLibrary.nil()) is returned and a warning logged. If multiple factories have the given id (this is considered a bug), then a warning is logged and a factory is selected non-deterministically.- Type Parameters:
T- the type of values in the emulator's state- Parameters:
id- the id of the userop librarylanguage- the languagearithmetic- the arithmetic- Returns:
- the userop library
-
createUseropLibraryForLanguage
static <T> PcodeUseropLibrary<T> createUseropLibraryForLanguage(SleighLanguage language, PcodeArithmetic<T> arithmetic) Create the userop library for the given languageThis composes all of the libraries named in the language's pspec file in the "useropLibs" property. That property is a comma-separated list of the ids to compose.
See the caveats in
createUseropLibraryFromId(String, SleighLanguage, PcodeArithmetic)regarding agreement between language and arithmetic.- Type Parameters:
T- the type of values in the emulator's state- Parameters:
language- the languagearithmetic- the arithmetic- Returns:
- the userop library
- Implementation Notes:
- currently, duplicate userops (by name) are not permitted. This may change in future versions. Thus, we compose libraries in the order listed, in case of that change, as it would matter.
-
getId
Get the id of this factoryThis gets the id from the
PcodeUseropLibraryFactory.UseropLibraryannotation. You should not override this function without a good reason.- Returns:
- the id
-
create
Create the userop library- Type Parameters:
T- the type of values in the emulator- Parameters:
language- the language of the emulatorarithmetic- the arithmetic of the emulator- Returns:
- the userop library
-