@rma...@google.com Since you've made the most changes to `NativeType` in the last years. What do you think of the architectural options here?
Background: We need some display information to show to users for structs and their fields. And the VM service relies on the `NativeType` hierarchy calculations to figure out the field offsets and sizes. Which of the options listed in the comments below do you prefer? Or do you have another idea?
.map((f) => f.field?.name.text ?? f.getter!.name.text)Maybe add the fallback on `class CompoundField` instead. `String get name =>`
.toList(),Nit you can use `[for (final f` instead of `map` and `toList`.
static const NativeType* CompoundFromPragma(Let me think about the approach here architecturally:
Before this change, the NativeType _only_ has information needed for computing the calling convention. And this method only produces a NativeType.
With this change this method has two side effects, member names and user-readable dart types.
This feels kind of weird.
Some ideas on how to make the architecture better.
Option 1:
=> This ensures that we have a proper abstraction. The VM service only interacts with `NativeType` and it contains all the needed info also for debugging.
=> It also slightly slows down the compiler, because we're always parsing those names. (We're doing that already by embedding the names in the ffi struct fields pragma anyways. So it would be consistent.)
=> We might be able to use those names in the existing code to give more useful error messages.
Option 2: Scope the debugger-useful names only to the VM service.
Pros:
Cons:
Option 3:
Introduce a `DebuggableNativeStructType : public NativeStructType` that holds on to the names and return that from `CompoundFromPragma` if `bool debug_info=true` as a param.
Cons:
I think I'm leaning towards option 1.
WDYT @bkony and @rmacnak?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
@rma...@google.com Since you've made the most changes to `NativeType` in the last years. What do you think of the architectural options here?
Background: We need some display information to show to users for structs and their fields. And the VM service relies on the `NativeType` hierarchy calculations to figure out the field offsets and sizes. Which of the options listed in the comments below do you prefer? Or do you have another idea?
Maybe I'm not understanding the usage, but I would have expected changes to the output of getObject, not a new RPC, to be able to show the state of FFI objects.
(Compare "Records and the VM Service".)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |