mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
TTG: remove support for optional: true fields
After this commit, every non-key field is treated as if it was optional while every key field (plus every auto-generated `Kind` field) - as if it was required.
This commit is contained in:
@@ -40,7 +40,6 @@ definitions:
|
||||
type: uint64_t
|
||||
- name: UnusedStackArgumentBytes
|
||||
type: uint64_t
|
||||
optional: true
|
||||
|
||||
- name: MaximumGPRsPerAggregateArgument
|
||||
type: uint64_t
|
||||
@@ -55,37 +54,29 @@ definitions:
|
||||
sequence:
|
||||
type: std::vector
|
||||
elementType: model::Register::Values
|
||||
optional: true
|
||||
- name: GeneralPurposeReturnValueRegisters
|
||||
sequence:
|
||||
type: std::vector
|
||||
elementType: model::Register::Values
|
||||
optional: true
|
||||
- name: VectorArgumentRegisters
|
||||
sequence:
|
||||
type: std::vector
|
||||
elementType: model::Register::Values
|
||||
optional: true
|
||||
- name: VectorReturnValueRegisters
|
||||
sequence:
|
||||
type: std::vector
|
||||
elementType: model::Register::Values
|
||||
optional: true
|
||||
- name: CalleeSavedRegisters
|
||||
sequence:
|
||||
type: std::vector
|
||||
elementType: model::Register::Values
|
||||
optional: true
|
||||
|
||||
- name: ReturnValueLocationRegister
|
||||
type: model::Register::Values
|
||||
optional: true
|
||||
- name: ReturnValueLocationOnStack
|
||||
type: bool
|
||||
optional: true
|
||||
- name: ReturnValueLocationIsReturned
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: ScalarTypes
|
||||
sequence:
|
||||
@@ -113,7 +104,6 @@ definitions:
|
||||
doc: |
|
||||
When set to `0` (default), the alignment of this type matches its size
|
||||
type: uint64_t
|
||||
optional: true
|
||||
|
||||
key:
|
||||
- Size
|
||||
|
||||
@@ -22,12 +22,10 @@ definitions:
|
||||
- name: Name
|
||||
type: string
|
||||
doc: Optional name for debugging purposes
|
||||
optional: true
|
||||
- name: Blocks
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: BasicBlock
|
||||
optional: true
|
||||
|
||||
- name: BasicBlock
|
||||
doc: The basic block of a function
|
||||
@@ -46,7 +44,6 @@ definitions:
|
||||
type: MetaAddress
|
||||
- name: InlinedFrom
|
||||
type: MetaAddress
|
||||
optional: true
|
||||
doc: Address of the function this basic block has been inlined from
|
||||
- name: Successors
|
||||
doc: List of successor edges
|
||||
@@ -65,7 +62,6 @@ definitions:
|
||||
|
||||
fields:
|
||||
- name: Destination
|
||||
optional: true
|
||||
doc: |
|
||||
Target of the CFG edge
|
||||
|
||||
@@ -98,11 +94,9 @@ definitions:
|
||||
doc: |
|
||||
Name of the dynamic function being called, or empty if not a dynamic call
|
||||
type: string
|
||||
optional: true
|
||||
- name: IsTailCall
|
||||
doc: Is this a tail call?
|
||||
type: bool
|
||||
optional: true
|
||||
- name: Attributes
|
||||
doc: |
|
||||
Attributes for this function
|
||||
@@ -113,7 +107,6 @@ definitions:
|
||||
sequence:
|
||||
type: MutableSet
|
||||
elementType: model::FunctionAttribute::Values
|
||||
optional: true
|
||||
|
||||
- name: FunctionEdgeType
|
||||
doc: Type of edge on the CFG
|
||||
|
||||
@@ -70,8 +70,6 @@ fields:
|
||||
- name: <Field2_name>
|
||||
type: <Field2_type>
|
||||
doc: <Documentation entry about the second field>
|
||||
# marks a field as optional when deserializing YAML
|
||||
optional: true
|
||||
|
||||
key:
|
||||
# List the fields that uniquely identify an object inside a container here.
|
||||
|
||||
@@ -24,29 +24,24 @@ definitions:
|
||||
- name: Architecture
|
||||
doc: The architecture for this binary.
|
||||
type: Architecture
|
||||
optional: true
|
||||
|
||||
- name: EntryPoint
|
||||
doc: The program entry point, if any.
|
||||
type: MetaAddress
|
||||
optional: true
|
||||
|
||||
- name: DefaultABI
|
||||
doc: The default ABI to adopt for analysis purposes.
|
||||
type: ABI
|
||||
optional: true
|
||||
|
||||
- name: DefaultPrototype
|
||||
doc: |-
|
||||
The default function prototype to adopt for functions that do not provide
|
||||
it explicitly.
|
||||
type: Type
|
||||
optional: true
|
||||
|
||||
- name: Configuration
|
||||
doc: Project-level artifact configuration options
|
||||
type: Configuration
|
||||
optional: true
|
||||
|
||||
- name: Segments
|
||||
doc: |-
|
||||
@@ -55,7 +50,6 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: Segment
|
||||
optional: true
|
||||
|
||||
- name: ExtraCodeAddresses
|
||||
doc: |-
|
||||
@@ -68,7 +62,6 @@ definitions:
|
||||
handlers: no code ever directly jumps there and their address is not
|
||||
stored in jump tables. Their address can only be obtained by interpreting
|
||||
metadata in the ELF.
|
||||
optional: true
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: MetaAddress
|
||||
@@ -81,21 +74,18 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: string
|
||||
optional: true
|
||||
|
||||
- name: ImportedDynamicFunctions
|
||||
doc: List of functions imported from dynamic libraries (`.so`, `.dll`).
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: DynamicFunction
|
||||
optional: true
|
||||
|
||||
- name: Functions
|
||||
doc: List of the functions present in the binary.
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: Function
|
||||
optional: true
|
||||
|
||||
- name: TypeDefinitions
|
||||
doc: |-
|
||||
@@ -104,7 +94,6 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: TypeDefinition
|
||||
optional: true
|
||||
|
||||
#
|
||||
# Type definition system
|
||||
@@ -144,13 +133,11 @@ definitions:
|
||||
- name: Name
|
||||
doc: A user-chosen identifier for this type.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Comment
|
||||
doc: |-
|
||||
A comment attached to the *definition* of this type.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: CABIFunctionDefinition
|
||||
inherits: TypeDefinition
|
||||
@@ -176,14 +163,12 @@ definitions:
|
||||
- name: ReturnType
|
||||
doc: The function return type.
|
||||
type: Type
|
||||
optional: true
|
||||
|
||||
- name: ReturnValueComment
|
||||
doc: |-
|
||||
A comment that will be emitted as part of this function's definiktion
|
||||
in the `\returns ${COMMENT_TEXT}` shape.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Arguments
|
||||
doc: The list of formal arguments of the function type.
|
||||
@@ -212,14 +197,12 @@ definitions:
|
||||
- name: Name
|
||||
doc: The name of the argument.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Comment
|
||||
doc: |-
|
||||
A comment that will be emitted as part of this function's definition
|
||||
in the `\param ${NAME} ${COMMENT}` shape.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: EnumDefinition
|
||||
inherits: TypeDefinition
|
||||
@@ -266,14 +249,12 @@ definitions:
|
||||
doc: |-
|
||||
A user-chosen identifier for this `enum` entry.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Comment
|
||||
doc: |-
|
||||
A comment that will be emitted right before the *definition* of this
|
||||
`enum` entry.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: RawFunctionDefinition
|
||||
inherits: TypeDefinition
|
||||
@@ -303,7 +284,6 @@ definitions:
|
||||
The list of registers used to pass arguments.
|
||||
|
||||
The registers must belong to the `Architecture`.
|
||||
optional: true
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: NamedTypedRegister
|
||||
@@ -313,7 +293,6 @@ definitions:
|
||||
The list of registers used to return values.
|
||||
|
||||
The registers must belong to the `Architecture`.
|
||||
optional: true
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: NamedTypedRegister
|
||||
@@ -323,14 +302,12 @@ definitions:
|
||||
A comment that will be emitted as part of this function's definition
|
||||
in the `\returns ${COMMENT}` shape.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: PreservedRegisters
|
||||
doc: |-
|
||||
The list of registers preserved by functions using this function type.
|
||||
|
||||
The registers must belong to `Architecture`.
|
||||
optional: true
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: Register
|
||||
@@ -345,12 +322,10 @@ definitions:
|
||||
This is due to the fact that `ret` instruction increase the stack pointer
|
||||
by 8.
|
||||
type: uint64_t
|
||||
optional: true
|
||||
|
||||
- name: StackArgumentsType
|
||||
doc: The type of the `struct` representing all of the stack arguments.
|
||||
type: Type
|
||||
optional: true
|
||||
|
||||
- name: NamedTypedRegister
|
||||
type: struct
|
||||
@@ -375,12 +350,10 @@ definitions:
|
||||
- name: Name
|
||||
doc: The name for this argument or return value.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Comment
|
||||
doc: The comment for this argument or return value.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: TypedefDefinition
|
||||
inherits: TypeDefinition
|
||||
@@ -415,7 +388,6 @@ definitions:
|
||||
a segment's root type without traversing pointer, arrays or other
|
||||
qualifiers, the padding of the struct is treated at if it contains code.
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: Fields
|
||||
doc: The list of fields of this `struct`.
|
||||
@@ -442,12 +414,10 @@ definitions:
|
||||
- name: Name
|
||||
doc: The name of this field.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Comment
|
||||
doc: The comment that will be emitted before this field's *definition*.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Type
|
||||
doc: The type of the field.
|
||||
@@ -490,14 +460,12 @@ definitions:
|
||||
- name: Name
|
||||
doc: The name of this "field" (union alternative).
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Comment
|
||||
doc: |-
|
||||
The comment that will be emitted right before the *definition*
|
||||
of the given "field" (union alternative).
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Type
|
||||
doc: The name of this "field" (union alternative).
|
||||
@@ -524,7 +492,6 @@ definitions:
|
||||
- name: IsConst
|
||||
doc: Specifies whether the type this object denotes is `const` or not.
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: PrimitiveType
|
||||
inherits: Type
|
||||
@@ -560,7 +527,6 @@ definitions:
|
||||
|
||||
Note that `Void` *must* have size of 0.
|
||||
type: uint64_t
|
||||
optional: true
|
||||
|
||||
- name: PrimitiveKind
|
||||
type: enum
|
||||
@@ -694,20 +660,17 @@ definitions:
|
||||
- name: Name
|
||||
doc: The name of the segment.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Comment
|
||||
doc: |-
|
||||
The comment to emit right before the global variable that will be
|
||||
created for this segment.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: CanonicalRegisterValues
|
||||
doc: |-
|
||||
The list of registers that are assumed to have a canonical value set
|
||||
upon an entry into a function contained within this segment.
|
||||
optional: true
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: CanonicalRegisterValue
|
||||
@@ -716,7 +679,6 @@ definitions:
|
||||
doc: |-
|
||||
A list of locations where the address of this segment should be
|
||||
placed.
|
||||
optional: true
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: Relocation
|
||||
@@ -726,7 +688,6 @@ definitions:
|
||||
The struct type associated to this segment.
|
||||
Informally, each field of such a `struct` is a global variable.
|
||||
type: Type
|
||||
optional: true
|
||||
|
||||
- name: Function
|
||||
type: struct
|
||||
@@ -748,29 +709,24 @@ definitions:
|
||||
- name: Name
|
||||
doc: The user-provided name for this function.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Comment
|
||||
doc: The user-provided comment for this function.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: StackFrameType
|
||||
doc: The type of the stack frame.
|
||||
type: Type
|
||||
optional: true
|
||||
|
||||
- name: Prototype
|
||||
doc: The prototype of the function.
|
||||
type: Type
|
||||
optional: true
|
||||
|
||||
- name: Attributes
|
||||
doc: Attributes for *every* call site.
|
||||
sequence:
|
||||
type: MutableSet
|
||||
elementType: FunctionAttribute
|
||||
optional: true
|
||||
|
||||
- name: CallSitePrototypes
|
||||
doc: |-
|
||||
@@ -778,7 +734,6 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: CallSitePrototype
|
||||
optional: true
|
||||
|
||||
- name: ExportedNames
|
||||
doc: |-
|
||||
@@ -787,7 +742,6 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: string
|
||||
optional: true
|
||||
|
||||
- name: Comments
|
||||
doc: |-
|
||||
@@ -796,7 +750,6 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: StatementComment
|
||||
optional: true
|
||||
|
||||
- name: LocalVariables
|
||||
doc: |-
|
||||
@@ -804,7 +757,6 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: LocalIdentifier
|
||||
optional: true
|
||||
|
||||
- name: GotoLabels
|
||||
doc: |-
|
||||
@@ -812,7 +764,6 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: LocalIdentifier
|
||||
optional: true
|
||||
|
||||
- name: DynamicFunction
|
||||
type: struct
|
||||
@@ -834,19 +785,16 @@ definitions:
|
||||
- name: Comment
|
||||
doc: The user-provided comment for this dynamic function.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Prototype
|
||||
doc: The prototype of this dynamic function.
|
||||
type: Type
|
||||
optional: true
|
||||
|
||||
- name: Attributes
|
||||
doc: The attributes of this dynamic function.
|
||||
sequence:
|
||||
type: MutableSet
|
||||
elementType: FunctionAttribute
|
||||
optional: true
|
||||
|
||||
- name: Relocations
|
||||
doc: |-
|
||||
@@ -855,7 +803,6 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: Relocation
|
||||
optional: true
|
||||
|
||||
- name: LocalIdentifier
|
||||
type: struct
|
||||
@@ -975,14 +922,12 @@ definitions:
|
||||
- name: IsTailCall
|
||||
doc: Whether this call site is a tail call or not.
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: Attributes
|
||||
doc: Attributes for this call site.
|
||||
sequence:
|
||||
type: MutableSet
|
||||
elementType: FunctionAttribute
|
||||
optional: true
|
||||
|
||||
- name: FunctionAttribute
|
||||
type: enum
|
||||
@@ -1488,12 +1433,10 @@ definitions:
|
||||
- name: Disassembly
|
||||
doc: The options specific to the disassembly artifact.
|
||||
type: DisassemblyConfiguration
|
||||
optional: true
|
||||
|
||||
- name: Naming
|
||||
doc: The options specific to the naming conventions
|
||||
type: NamingConfiguration
|
||||
optional: true
|
||||
|
||||
# Configuration options that don't belong anywhere else find themselves
|
||||
# under this comment (in this struct).
|
||||
@@ -1507,7 +1450,6 @@ definitions:
|
||||
|
||||
Set to `-1` for unlimited line size.
|
||||
type: uint64_t
|
||||
optional: true
|
||||
|
||||
- name: NamingConfiguration
|
||||
type: struct
|
||||
@@ -1523,7 +1465,6 @@ definitions:
|
||||
|
||||
The default value is `segment_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedDynamicFunctionPrefix
|
||||
doc: |-
|
||||
@@ -1531,7 +1472,6 @@ definitions:
|
||||
|
||||
The default value is `dynamic_function_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedFunctionPrefix
|
||||
doc: |-
|
||||
@@ -1539,7 +1479,6 @@ definitions:
|
||||
|
||||
The default value is `function_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedTypeDefinitionPrefix
|
||||
doc: |-
|
||||
@@ -1550,7 +1489,6 @@ definitions:
|
||||
Note that the type kind (like `struct`, or `typedef`) is going to be
|
||||
inserted automatically after this prefix.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedEnumEntryPrefix
|
||||
doc: |-
|
||||
@@ -1558,7 +1496,6 @@ definitions:
|
||||
|
||||
The default value is `enum_entry_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedStructFieldPrefix
|
||||
doc: |-
|
||||
@@ -1566,7 +1503,6 @@ definitions:
|
||||
|
||||
The default value is `offset_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedUnionFieldPrefix
|
||||
doc: |-
|
||||
@@ -1574,7 +1510,6 @@ definitions:
|
||||
|
||||
The default value is `member_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedFunctionArgumentPrefix
|
||||
doc: |-
|
||||
@@ -1582,7 +1517,6 @@ definitions:
|
||||
|
||||
The default value is `argument_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedFunctionRegisterPrefix
|
||||
doc: |-
|
||||
@@ -1590,7 +1524,6 @@ definitions:
|
||||
|
||||
The default value is `register_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedLocalVariablePrefix
|
||||
doc: |-
|
||||
@@ -1598,7 +1531,6 @@ definitions:
|
||||
|
||||
The default value is `var_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedBreakFromLoopVariablePrefix
|
||||
doc: |-
|
||||
@@ -1606,7 +1538,6 @@ definitions:
|
||||
|
||||
The default value is `break_from_loop_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: UnnamedGotoLabelPrefix
|
||||
doc: |-
|
||||
@@ -1614,7 +1545,6 @@ definitions:
|
||||
|
||||
The default value is `label_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: OpaqueCSVValuePrefix
|
||||
doc: |-
|
||||
@@ -1622,7 +1552,6 @@ definitions:
|
||||
|
||||
The default value is `undef_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: MaximumEnumValuePrefix
|
||||
doc: |-
|
||||
@@ -1630,7 +1559,6 @@ definitions:
|
||||
|
||||
The default value is `enum_max_value_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: StackFrameVariableName
|
||||
doc: |-
|
||||
@@ -1638,7 +1566,6 @@ definitions:
|
||||
|
||||
The default value is `stack`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: RawStackArgumentName
|
||||
doc: |-
|
||||
@@ -1646,7 +1573,6 @@ definitions:
|
||||
|
||||
The default value is `stack_arguments`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: LoopStateVariableName
|
||||
doc: |-
|
||||
@@ -1654,7 +1580,6 @@ definitions:
|
||||
|
||||
The default value is `loop_state_var`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: StructPaddingPrefix
|
||||
doc: |-
|
||||
@@ -1662,7 +1587,6 @@ definitions:
|
||||
|
||||
The default value is `padding_at_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: ArtificialReturnValuePrefix
|
||||
doc: |-
|
||||
@@ -1670,14 +1594,12 @@ definitions:
|
||||
|
||||
The default value is `artificial_struct_returned_by_`.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: ReserveNamesStartingWithUnderscore
|
||||
doc: |-
|
||||
When this is set to `true`, all the names starting with underscores will
|
||||
have a \ref ReservedNamePrefix prefix attached.
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: DisassemblyConfiguration
|
||||
type: struct
|
||||
@@ -1699,7 +1621,6 @@ definitions:
|
||||
This part
|
||||
```
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: DisableEmissionOfRawBytes
|
||||
doc: |-
|
||||
@@ -1714,7 +1635,6 @@ definitions:
|
||||
This part
|
||||
```
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: UseX86ATTSyntax
|
||||
doc: |-
|
||||
@@ -1738,7 +1658,6 @@ definitions:
|
||||
|
||||
Note that this option has no effect on non-x86 binaries.
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: AddressStyle
|
||||
doc: |-
|
||||
@@ -1748,7 +1667,6 @@ definitions:
|
||||
|
||||
The default value is `Smart`.
|
||||
type: DisassemblyConfigurationAddressStyle
|
||||
optional: true
|
||||
|
||||
- name: ImmediateStyle
|
||||
doc: |-
|
||||
@@ -1758,7 +1676,6 @@ definitions:
|
||||
|
||||
The default value is `CHexadecimal`.
|
||||
type: DisassemblyConfigurationImmediateStyle
|
||||
optional: true
|
||||
|
||||
- name: PrintFullMetaAddress
|
||||
doc: |-
|
||||
@@ -1776,7 +1693,6 @@ definitions:
|
||||
```
|
||||
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: BasicBlockPrefix
|
||||
doc: |-
|
||||
@@ -1792,7 +1708,6 @@ definitions:
|
||||
80491a7: e9 ec fe ff ff jmp bb_0x8049098
|
||||
```
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: DisassemblyConfigurationImmediateStyle
|
||||
type: enum
|
||||
|
||||
@@ -49,11 +49,9 @@ definitions:
|
||||
- name: Component
|
||||
doc: Step's component
|
||||
type: string
|
||||
optional: true
|
||||
- name: Parent
|
||||
doc: The Step's parent (if present)
|
||||
type: string
|
||||
optional: true
|
||||
- name: Analyses
|
||||
doc: List of Analyses that the Step provides
|
||||
sequence:
|
||||
@@ -62,7 +60,6 @@ definitions:
|
||||
- name: Artifacts
|
||||
doc: The artifacts that this step provides
|
||||
type: Artifacts
|
||||
optional: true
|
||||
key:
|
||||
- Name
|
||||
|
||||
@@ -79,11 +76,9 @@ definitions:
|
||||
- name: Parent
|
||||
doc: The Rank's parent (if present)
|
||||
type: string
|
||||
optional: true
|
||||
- name: TupleTreePath
|
||||
doc: The model path corresponding to this rank.
|
||||
type: string
|
||||
optional: true
|
||||
key:
|
||||
- Name
|
||||
- name: Kind
|
||||
@@ -99,7 +94,6 @@ definitions:
|
||||
- name: Parent
|
||||
doc: The Kind's parent (if present)
|
||||
type: string
|
||||
optional: true
|
||||
- name: DefinedLocations
|
||||
doc: List of locations that the Kind provides
|
||||
sequence:
|
||||
@@ -133,15 +127,12 @@ definitions:
|
||||
- name: Kind
|
||||
doc: Artifacts's kind
|
||||
type: string
|
||||
optional: true
|
||||
- name: Container
|
||||
doc: Artifacts's container
|
||||
type: string
|
||||
optional: true
|
||||
- name: SingleTargetFilename
|
||||
doc: The Artifacts's filename to use for a single element
|
||||
type: string
|
||||
optional: true
|
||||
- name: Analysis
|
||||
doc: Data structure representing an analysis
|
||||
type: struct
|
||||
|
||||
@@ -21,6 +21,5 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: string
|
||||
optional: true
|
||||
key:
|
||||
- Location
|
||||
|
||||
@@ -38,7 +38,6 @@ definitions:
|
||||
|
||||
- name: InlinedFrom
|
||||
type: MetaAddress
|
||||
optional: true
|
||||
doc: Address of the function this basic block has been inlined from
|
||||
|
||||
- name: Label
|
||||
@@ -71,7 +70,6 @@ definitions:
|
||||
\note: This is always equal to `false` on architectures that do not
|
||||
support delay slots.
|
||||
type: bool
|
||||
optional: true
|
||||
|
||||
- name: FunctionEdgeBase
|
||||
doc: An edge on the CFG
|
||||
@@ -84,7 +82,6 @@ definitions:
|
||||
|
||||
fields:
|
||||
- name: Destination
|
||||
optional: true
|
||||
doc: |
|
||||
Target of the CFG edge
|
||||
|
||||
@@ -116,11 +113,9 @@ definitions:
|
||||
doc: |
|
||||
Name of the dynamic function being called, or empty if not a dynamic call
|
||||
type: string
|
||||
optional: true
|
||||
- name: IsTailCall
|
||||
doc: Is this a tail call?
|
||||
type: bool
|
||||
optional: true
|
||||
- name: Attributes
|
||||
doc: |
|
||||
Attributes for this function
|
||||
@@ -131,7 +126,6 @@ definitions:
|
||||
sequence:
|
||||
type: MutableSet
|
||||
elementType: model::FunctionAttribute::Values
|
||||
optional: true
|
||||
|
||||
- name: FunctionEdgeType
|
||||
doc: Type of edge on the CFG
|
||||
@@ -187,21 +181,18 @@ definitions:
|
||||
|
||||
- name: OpcodeIdentifier
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Comment
|
||||
doc: >
|
||||
Contains any extra information deduced based on the disassembly of this
|
||||
instruction that could be relevant for the user.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: Error
|
||||
doc: >
|
||||
Contains any extra extra warning/error style information deduced based on
|
||||
the disassembly of this instruction that could be relevant for the user.
|
||||
type: string
|
||||
optional: true
|
||||
|
||||
- name: TaggedLine
|
||||
type: struct
|
||||
@@ -237,7 +228,6 @@ definitions:
|
||||
sequence:
|
||||
type: SortedVector
|
||||
elementType: TagAttribute
|
||||
optional: true
|
||||
|
||||
- name: TagAttribute
|
||||
type: struct
|
||||
|
||||
@@ -107,7 +107,10 @@ class JSONSchemaGenerator:
|
||||
+ "` field."
|
||||
)
|
||||
|
||||
jsonschema["required"] = [f.name for f in definition.all_required_fields]
|
||||
if definition._key:
|
||||
jsonschema["required"] = definition._key
|
||||
else:
|
||||
jsonschema["required"] = []
|
||||
jsonschema["properties"] = properties
|
||||
|
||||
return jsonschema
|
||||
|
||||
@@ -177,7 +177,7 @@ class PythonGenerator:
|
||||
f'{{"type": {hint_type}, '
|
||||
+ (f'"possible_values": {possible_values},' if possible_values is not None else "")
|
||||
+ f'"ctor": "{ctor}", '
|
||||
+ f'"optional": {self.to_bool(field.optional)}, '
|
||||
+ f'"is_key": {self.to_bool(field.is_key)}, '
|
||||
+ f'"is_array": {self.to_bool(is_sequence)}, '
|
||||
+ f'"is_abstract": {self.to_bool(is_abstract)},'
|
||||
+ f'"external": {self.to_bool(external)}}}'
|
||||
|
||||
@@ -146,7 +146,7 @@ class TypeScriptGenerator:
|
||||
def gen_assignment(self, field: StructField) -> str:
|
||||
if self._is_simple_type(field):
|
||||
result = f"this.{field.name} = rawObject.{field.name}"
|
||||
opt = f"|| {self.get_default_value(field)}" if field.optional else ""
|
||||
opt = "" if field.is_key else f"|| {self.get_default_value(field)}"
|
||||
return f"{result}{opt};"
|
||||
if isinstance(field.resolved_type, ReferenceDefinition):
|
||||
pointee_type = field.resolved_type.pointee.name
|
||||
@@ -283,14 +283,13 @@ class TypeScriptGenerator:
|
||||
f"{{type: {hint_type}, "
|
||||
+ (f"possibleValues: {possible_values}," if possible_values is not None else "")
|
||||
+ f"ctor: '{ctor}', "
|
||||
+ f"optional: {'true' if field.optional else 'false'}, "
|
||||
+ f"isArray: {'true' if is_sequence else 'false'}, "
|
||||
+ f"isAbstract: {'true' if is_abstract else 'false'}}}"
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def is_optional(field: StructField):
|
||||
return field.optional or isinstance(field.resolved_type, ReferenceDefinition)
|
||||
return not field.is_key or isinstance(field.resolved_type, ReferenceDefinition)
|
||||
|
||||
@staticmethod
|
||||
def is_upcastable(field: StructField):
|
||||
|
||||
@@ -36,7 +36,6 @@ class Schema:
|
||||
"name": "Version",
|
||||
"type": "uint64_t",
|
||||
"doc": "The input's version, must match revng's schema version",
|
||||
"optional": True,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ def is_enum(resolved_type):
|
||||
|
||||
|
||||
class StructField(ABC):
|
||||
def __init__(self, *, name, doc=None, optional=False, const=False, is_guid=False):
|
||||
def __init__(self, *, name, doc=None, const=False, is_guid=False):
|
||||
self.name = name
|
||||
self.doc = doc
|
||||
self.optional = optional
|
||||
self.is_key = False
|
||||
self.upcastable = False
|
||||
self.const = const
|
||||
self.is_guid = is_guid
|
||||
@@ -63,11 +63,10 @@ class SimpleStructField(StructField):
|
||||
name,
|
||||
type, # noqa: A002
|
||||
doc=None,
|
||||
optional=False,
|
||||
const=False,
|
||||
is_guid=False,
|
||||
):
|
||||
super().__init__(name=name, doc=doc, optional=optional, const=const, is_guid=is_guid)
|
||||
super().__init__(name=name, doc=doc, const=const, is_guid=is_guid)
|
||||
self.type = type
|
||||
|
||||
def resolve_references(self, schema):
|
||||
@@ -88,10 +87,9 @@ class SequenceStructField(StructField):
|
||||
sequence_type,
|
||||
element_type,
|
||||
doc=None,
|
||||
optional=False,
|
||||
const=False,
|
||||
):
|
||||
super().__init__(name=name, doc=doc, optional=optional, const=const)
|
||||
super().__init__(name=name, doc=doc, const=const)
|
||||
self.sequence_type = sequence_type
|
||||
self.element_type = element_type
|
||||
self.resolved_element_type = None
|
||||
@@ -108,8 +106,8 @@ class SequenceStructField(StructField):
|
||||
|
||||
|
||||
class ReferenceStructField(StructField):
|
||||
def __init__(self, *, name, pointee_type, doc=None, optional=False, const=False):
|
||||
super().__init__(name=name, doc=doc, optional=optional, const=const)
|
||||
def __init__(self, *, name, pointee_type, doc=None, const=False):
|
||||
super().__init__(name=name, doc=doc, const=const)
|
||||
self.pointee_type = pointee_type
|
||||
|
||||
def resolve_references(self, schema):
|
||||
@@ -144,8 +142,6 @@ class StructDefinition(Definition):
|
||||
# These fields will be populated by resolve_references()
|
||||
self.inherits = None
|
||||
self._key_kind_index = None
|
||||
# Type containing the key fields (might be self or a base class)
|
||||
self.key_definition = None
|
||||
# None, "simple" or "composite"
|
||||
self.keytype = None
|
||||
self.key_fields: List[SimpleStructField] = []
|
||||
@@ -158,9 +154,18 @@ class StructDefinition(Definition):
|
||||
return
|
||||
|
||||
if self._inherits:
|
||||
self.inherits = schema.get_definition_for(self._inherits)
|
||||
self.dependencies.add(self._inherits)
|
||||
|
||||
self.inherits = schema.get_definition_for(self._inherits)
|
||||
self.inherits.resolve_references(schema)
|
||||
|
||||
# TODO: support indirect inheritance
|
||||
assert not self._key
|
||||
self._key = self.inherits._key
|
||||
self._key_kind_index = self.inherits._key_kind_index
|
||||
self.keytype = self.inherits.keytype
|
||||
self.key_fields = self.inherits.key_fields
|
||||
|
||||
for field in self.fields:
|
||||
field.resolve_references(schema)
|
||||
|
||||
@@ -178,36 +183,30 @@ class StructDefinition(Definition):
|
||||
else:
|
||||
raise ValueError()
|
||||
|
||||
if self._key:
|
||||
self.key_definition = self
|
||||
if self._key and not self._inherits:
|
||||
for field in self.fields:
|
||||
if field.name in self._key:
|
||||
assert isinstance(field, SimpleStructField)
|
||||
|
||||
elif self.inherits and self.inherits._key:
|
||||
# TODO: support indirect inheritance
|
||||
self.key_definition = self.inherits
|
||||
field.is_key = True
|
||||
# TODO: mark `field` as `const`
|
||||
|
||||
# TODO: mark key fields as const
|
||||
if self.key_definition:
|
||||
for key_field_index, key_field_name in enumerate(self.key_definition._key):
|
||||
key_field = next(f for f in self.key_definition.fields if f.name == key_field_name)
|
||||
assert isinstance(key_field, SimpleStructField)
|
||||
self.key_fields.append(key_field)
|
||||
self.key_fields.append(field)
|
||||
|
||||
if key_field.name == "Kind":
|
||||
assert self._key_kind_index is None, "Multiple kind fields in the key"
|
||||
self._key_kind_index = key_field_index
|
||||
kind_fields = [i for i, k in enumerate(self._key) if k == "Kind"]
|
||||
assert len(kind_fields) <= 1, f"Multiple kind fields in {self.name}"
|
||||
self._key_kind_index = kind_fields[0] if kind_fields else None
|
||||
|
||||
if len(self.key_definition.key_fields) == 0:
|
||||
if len(self.key_fields) == 0:
|
||||
self.keytype = None
|
||||
elif len(self.key_definition.key_fields) == 1:
|
||||
elif len(self.key_fields) == 1:
|
||||
self.keytype = "simple"
|
||||
else:
|
||||
self.keytype = "composite"
|
||||
|
||||
self._refs_resolved = True
|
||||
|
||||
key_fields_names = {f.name for f in self.key_fields}
|
||||
all_field_names = {f.name for f in self.all_fields}
|
||||
self.emit_full_constructor = key_fields_names != all_field_names
|
||||
self.emit_full_constructor = len(set(self.all_optional_fields)) != 0
|
||||
|
||||
if (self.inherits or self.abstract) and self.keytype:
|
||||
assert self._key_kind_index is not None, "A polymorphic type without kind in the key"
|
||||
@@ -224,34 +223,40 @@ class StructDefinition(Definition):
|
||||
}
|
||||
return StructDefinition(**args)
|
||||
|
||||
def is_required(self, field):
|
||||
if field.is_key:
|
||||
return True
|
||||
|
||||
return (self.inherits or self.abstract) and field.name == "Kind"
|
||||
|
||||
@property
|
||||
def optional_fields(self):
|
||||
for field in self.fields:
|
||||
if field.optional:
|
||||
if not self.is_required(field):
|
||||
yield field
|
||||
|
||||
@property
|
||||
def required_fields(self):
|
||||
for field in self.fields:
|
||||
if not field.optional:
|
||||
if self.is_required(field):
|
||||
yield field
|
||||
|
||||
@property
|
||||
def all_optional_fields(self):
|
||||
for field in self.all_fields:
|
||||
if field.optional:
|
||||
if not self.is_required(field):
|
||||
yield field
|
||||
|
||||
@property
|
||||
def all_required_fields(self):
|
||||
for field in self.all_fields:
|
||||
if not field.optional:
|
||||
if self.is_required(field):
|
||||
yield field
|
||||
|
||||
@property
|
||||
def all_fields(self):
|
||||
if not self._refs_resolved:
|
||||
raise RuntimeError("all_fields not available before resolving references")
|
||||
raise RuntimeError("`all_fields` is only available after resolving references")
|
||||
if self.inherits:
|
||||
yield from self.inherits.fields
|
||||
yield from self.fields
|
||||
|
||||
@@ -19,7 +19,7 @@ The notice below applies to the generated files.
|
||||
|
||||
#include "/*= user_include_path =*//*= struct.name =*/.h"
|
||||
|
||||
/** if upcastable and struct.key_definition._key **/
|
||||
/** if upcastable and struct._key **/
|
||||
|
||||
using /*= struct.name =*/Key = /*= struct | user_fullname =*/::Key;
|
||||
using U/*= struct.name =*/ = /*= base_namespace =*/::Upcastable/*= struct.name =*/;
|
||||
|
||||
-2
@@ -35,8 +35,6 @@ TypeDefinitions:
|
||||
Segments:
|
||||
- StartAddress: "0x400000:Generic64"
|
||||
VirtualSize: 4096
|
||||
StartOffset: 0
|
||||
FileSize: 4096
|
||||
IsReadable: true
|
||||
IsWriteable: false
|
||||
IsExecutable: true
|
||||
|
||||
@@ -108,9 +108,6 @@ definitions:
|
||||
type: string
|
||||
doc:
|
||||
type: string
|
||||
optional:
|
||||
type: boolean
|
||||
default: false
|
||||
is_guid:
|
||||
type: boolean
|
||||
default: false
|
||||
@@ -138,9 +135,6 @@ definitions:
|
||||
required:
|
||||
- type
|
||||
- elementType
|
||||
optional:
|
||||
type: boolean
|
||||
default: false
|
||||
const:
|
||||
type: boolean
|
||||
default: false
|
||||
@@ -158,9 +152,6 @@ definitions:
|
||||
type: string
|
||||
referenceTo:
|
||||
type: string
|
||||
optional:
|
||||
type: boolean
|
||||
default: false
|
||||
const:
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
@@ -9,7 +9,6 @@ definitions:
|
||||
- name: RequiredField
|
||||
type: uint64_t
|
||||
- name: OptionalField
|
||||
optional: true
|
||||
type: uint64_t
|
||||
- name: EnumField
|
||||
type: TestEnum
|
||||
|
||||
@@ -303,7 +303,6 @@ export function _makeDiff<T>(
|
||||
type: rootType,
|
||||
ctor: "class",
|
||||
isArray: false,
|
||||
optional: false,
|
||||
isAbstract: false,
|
||||
};
|
||||
return new DiffSet(
|
||||
@@ -584,7 +583,6 @@ type NativeParsable = (rawObject: any) => any;
|
||||
export type TupleTreeType = Constructor | Parsable;
|
||||
|
||||
interface CommonTypeInfo {
|
||||
optional: boolean;
|
||||
isArray: boolean;
|
||||
isAbstract: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user