Difference between revisions of "Reattachment"
m (typo fixed) |
m (→Reattachment of generic derivations in classic: Cosmetics) |
||
Line 6: | Line 6: | ||
All features in a generic derivation with an expanded parameter that involve this generic parameter should be able to handle the case when they are called on a target where this generic parameter is reference, i.e. they should be able to take reference arguments and return reference result. | All features in a generic derivation with an expanded parameter that involve this generic parameter should be able to handle the case when they are called on a target where this generic parameter is reference, i.e. they should be able to take reference arguments and return reference result. | ||
== Reattachment of generic derivations in classic == | == Reattachment of generic derivations in classic == | ||
− | # | + | # '''Dynamic dispatch'''.The feature <e>{ROUT_TABLE}.is_polymorphic</e> has to be modified so that it allows for different generic derivations to share the same table, because now it becomes possible to reattach generic derivations with expanded parameters to the generic derivations with reference parameters. Though not all the reattachments are possible (e.g., no reattachment is possible between the types <e>ARRAY [INTEGER]</e> and <e>ARRAY [BOOLEAN]</e>), it's too complicated and/or resource consuming to create the tables for every generic derivation and types that conform to it. |
− | + | # '''Unification of feature signature'''. In addition to the "normal" version of the method generated for a particular feature, a new stub can be generated so that its arguments/result types match those of the generic derivation with reference generic parameters. In order to avoid additional pressure on garbage collector, the values passed to/from the generated methods can be embedded in an EIF_UNION structure that allows to pass objects of basic and reference types "as is", while objects of user-defined expanded type still need to be "boxed" and kept in the heap. | |
− | # Attributes that are declared of a formal generic type (or as of type, anchored to a feature of a formal generic type) have to be accessed as functions so that they can be safely | + | # '''Access to attributes'''. Attributes that are declared of a formal generic type (or as of type, anchored to a feature of a formal generic type) have to be accessed as functions so that they can be safely accessed from the generic derivations with reference parameters. This involves two changes in code generation: |
## Promotion of <e>ATTRIBUTE_B</e> to <e>FEATURE_B</e> if an attribute type is (directly or indirectly) a formal generic. | ## Promotion of <e>ATTRIBUTE_B</e> to <e>FEATURE_B</e> if an attribute type is (directly or indirectly) a formal generic. | ||
## Generation of an accessor for the attribute by setting the field <e>generated_in</e>. | ## Generation of an accessor for the attribute by setting the field <e>generated_in</e>. |
Revision as of 02:48, 27 March 2007
See also: Object_Layout, Dynamic_Binding
Introduction
Conformance of expanded types to (particular) reference types implies that objects of generically derived types with expanded parameters can be attached to generically derived types with reference parameters (e.g., ARRAY [INTEGER]
can be attached to ARRAY [ANY]
).
All features in a generic derivation with an expanded parameter that involve this generic parameter should be able to handle the case when they are called on a target where this generic parameter is reference, i.e. they should be able to take reference arguments and return reference result.
Reattachment of generic derivations in classic
- Dynamic dispatch.The feature
{ROUT_TABLE}.is_polymorphic
has to be modified so that it allows for different generic derivations to share the same table, because now it becomes possible to reattach generic derivations with expanded parameters to the generic derivations with reference parameters. Though not all the reattachments are possible (e.g., no reattachment is possible between the typesARRAY [INTEGER]
andARRAY [BOOLEAN]
), it's too complicated and/or resource consuming to create the tables for every generic derivation and types that conform to it. - Unification of feature signature. In addition to the "normal" version of the method generated for a particular feature, a new stub can be generated so that its arguments/result types match those of the generic derivation with reference generic parameters. In order to avoid additional pressure on garbage collector, the values passed to/from the generated methods can be embedded in an EIF_UNION structure that allows to pass objects of basic and reference types "as is", while objects of user-defined expanded type still need to be "boxed" and kept in the heap.
- Access to attributes. Attributes that are declared of a formal generic type (or as of type, anchored to a feature of a formal generic type) have to be accessed as functions so that they can be safely accessed from the generic derivations with reference parameters. This involves two changes in code generation:
- Promotion of
ATTRIBUTE_B
toFEATURE_B
if an attribute type is (directly or indirectly) a formal generic. - Generation of an accessor for the attribute by setting the field
generated_in
.
- Promotion of