Commit Graph

29 Commits

Author SHA1 Message Date
Pietro Fezzardi e052dee40f Drop isCandidateForInline 2024-06-07 17:59:06 +02:00
Pietro Fezzardi a44679f847 ModelToPTMLTypeHelpers.cpp: fix unaligned Doxygen 2024-06-07 17:55:52 +02:00
Pietro Fezzardi e1a59e527a TypeNames: fix missing trailing \n in PTML comment
The missing \n was causing following type declaration to be wrongly
commented out.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi 2ee2577152 TypeInlineHelper: drop unused getTypeGraph method 2024-05-29 15:34:26 +02:00
Pietro Fezzardi 746cf5b55d TypeInlineHelper: rename collectStackTypes method
to collectTypesInlinableInStacks and document it.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi df9d7215b5 TypeInlineHelper: remove unnecessary members
`TypeToNumOfRefs` was used only in one method, so it can be computed
directly there on the fly.

`calculateNumOfOccurrences` doesn't need to be a method (it can be a
free function), it doesn't need to run at construction time, and it
doesn't need to return a map. So it's been moved in the `.cpp` file,
renamed to `getCrossReferencedTypes` and changed to return a set. It is
now only called when needed.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi 31db946bd3 TypeInlineHelper: refactor collectStackTypes
Now collectStackTypes is implemented as a wrapper on top of
findTypesToInlineInStacks.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi 196a15685f Rename TypeInlineHelper::findStackTypesPerFunction
to TypeInlineHelper::findTypesToInlineInStacks, which is more
descriptive of what the method actually does.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi f1fedf4e4e Drop unused TypeInlineHelper::getTypeToNumOfRefs 2024-05-29 15:34:26 +02:00
Pietro Fezzardi d9fddc4933 Early exit from isReachableFromRootType
Before this commit, TypeInlineHelper would always visit all the types to
compute reachability.
Now it bails out early, as soon as it detects reachability.
2024-05-29 15:34:26 +02:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Giacomo Vercesi 4d83c5e879 Allow renaming RawFunctionType return fields
Add the needed attributes to allow the fields of the return of a
RawFunctionType to be renamed.
2023-12-11 12:03:48 +01:00
Giacomo Vercesi 194bcecc41 Drop getReturnField
Drop the `getReturnField` helper, the cases in which it was used are now
covered by the `NamedTypeRegister::name` method.
2023-12-11 10:21:40 +01:00
Giacomo Vercesi fd24487666 C code: fix location for RawFunction return struct
Fix the needed attributes to allow navigation from the use of an
artificial return struct for raw functions to their definition in
`types-and-globals.h`.
2023-12-11 10:21:40 +01:00
Giacomo Vercesi ce446576a4 Fix typos 2023-11-02 16:49:49 +01:00
Pietro Fezzardi 740ef6f1d3 ModelToPTMLTypeHelpers: avoid redundant whitespace
Before this commit, the `printDefinition` helper functions for
`StructType` and `UnionType` were printing a duplicated whitespace when
generating the inline type definition as part of the declaration of a
field of a struct or union.

This commit skips the redundant whitespace when relevant.
2023-10-18 15:19:53 +02:00
Pietro Fezzardi a97287cef3 ModelToPTMLTypeHelpers: refactor APIs
This commit reorders the argument passed to various `printDeclaration`
and `printDefinition` helper functions, to make them more uniform across
each other, and to accept the same arguments in the same order.
2023-10-18 15:19:53 +02:00
Alessandro Di Federico f3d6bbb047 s/ThePTMLCBuilder/B/g 2023-08-23 16:40:54 +02:00
Alessandro Di Federico 4e1fed5fa0 ModelToHeader: omit _enum_max_value_* when editing 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 489dddd0e7 TupleTreeReference::isValid is for assertions only 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 330d2b6cc7 Model: rework how we name things
This commit:

* Introduces `_` as a prefix for all non-user entities we emit in
  decompiled code.
  Also, some names have been changed to be more concise.
  Specifically, the following entities have changed:
  `_ENUM_UNDERLYING`, `_ABI`, `_REG`, `_padding_at_`,
  `_artificial_struct_`, `_artificial_wrapper_`, `_stack`,
  `_break_from_loop_`, `_var_`, `_stack_arguments`,
  `_artificial_struct_returned_`, `_enum_max_value_`.
* Introduce _PACKED for `__attribute__((packed))`.
* `EnumEntry` name: drop the `EnumType` name prefix.
2023-08-23 16:37:39 +02:00
Alessandro Di Federico a207ef7c44 Minor changes 2023-08-23 16:12:51 +02:00
Djordje Todorovic 262e579128 ModelToHeader: annotation for enum underlying type 2023-07-25 12:03:57 +02:00
Djordje Todorovic 5c0167f792 Add ImportModelFromC Analysis
This analysis will be used for the following features:

1) Edit Type in the Model
2) Edit Function Prototype in the Model
3) Add Type to the Model

It takes C code as an input, parses it and produces a Model
type that represents the C type.
2023-07-24 11:51:47 +02:00
Ivan Krysak 11f07c6708 TypeNames: emit comments when outputting types 2023-07-21 04:58:50 +00:00
Ivan Krysak e0b956b1c2 Model: rework edit path helpers from the ground up 2023-07-21 04:58:50 +00:00
Djordje Todorovic 286eb4d734 c-backend: Introduce PTMLCBuilder
This will be used to generate plain C.
2023-06-09 15:40:23 +02:00
Giacomo Vercesi a4ad571e61 rcc: Fix typos
Fix the typos detected by `codespell`
2023-05-11 10:04:32 +02:00
Djordje Todorovic ca7bc2e442 c-backend: Generate Inline Types in PTML
In ModelToHeader generate Inline Types in PTML by handling
Structs, Unions and Enums.

In addition, during the ModelToHeader we avoid producing
Structs that describe stacks, and in the DecompileFunction we
produce the definition of it inline if it is safe (referenced
only once).
2023-05-03 13:13:28 +02:00