parrotcode: Untitled | |
Contents | Language Implementations | .Net |
This document discusses .NET managed pointers and how they can be supported on Parrot.
Instead, when a managed pointer is created it takes a pointer to the current context and increment its reference count. This count is be decremented in the destructor for the managed pointer PMC. The type and number of the register the pointer is referencing also needs to be stored. This mechanism should ensure that the safety of the VM by preventing register frames that are still referenced from vanishing. Admittedly, this is somewhat evil and is certainly playing with parts of the internals liable to change. However, it works.
struct dotnet_managed_ptr { int type; /* The type of managed pointer this is. */ union ref { PMC* pmc; /* For arrays, fields. */ Parrot_Context *ctx; /* For registers. */ } union tag { int index; /* For arrays. */ STRING *name; /* For field name. */ struct reg_info { /* For registers. */ int number; int reg_type; } } }
|