[M3devel] computing a typeid in backend for a pointer to a declared type??

Rodney M. Bates rodney_bates at lcwb.coop
Sun Apr 7 18:02:51 CEST 2013



On 04/07/2013 12:56 AM, Jay K wrote:
> In the C backend, I would like to share code for records and objects.
>
>
> As I understand, objects are always pointers.

Yes.

>
>
> In my framework, I map typeids to type information.
>
>
> For this to work, given an object, I need to declare both a record
> and a pointer to it. I need two typeids for that.
>
>
> I'm in the position where I need to compute a typeid.
> Is that feasible?
>
>
>
> I have two choices if I can't do that:
>
>
>   1) map from strings instead, where the strings tend to be
>      a string form of a typeid, but where I can make up other forms;
>      quite an inefficiency
>
>
>   1b) have two maps maybe
>
>
>
>   2) build a flag into my record data that indicates "record or object"

FWIW, I believe it is true that every way of using an object type in Modula-3
implicitly and uniquely identifies whether it works on the pointer or the
heap object.  For example, := and  = mean the pointer, while any use of . implies
dereferencing.  There is no whole-object assignment or whole-object comparison,
as there are for REF RECORD (which has two types).

Maybe this distinction is lost in the lowering that happens by the time M3C gets it,
or later.

>
>
> #1 is easy but I'm leary of the inefficiency.
> I'll probably try #2 instead then.
>
>
>
>   - Jay
>
>




More information about the M3devel mailing list