Bug 316615 - [otre][compiler] Optimize implementation of role-of-role
Summary: [otre][compiler] Optimize implementation of role-of-role
Status: NEW
Alias: None
Product: Objectteams
Classification: Tools
Component: OTJ (show other bugs)
Version: 1.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: trac
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-11 10:11 EDT by Stephan Herrmann CLA
Modified: 2010-06-29 10:06 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2010-06-11 10:11:48 EDT
(originally from http://trac.objectteams.org/ot/ticket/174)

When a role is bound to a dependent type (another role), currently two hacks ensure that the behavior is as desired:

 * An observer mechanism is generated into the base roles in order to propagate 
   team activation from one role to its implicit sub role (cannot share static
   role fields) (StaticSliceBaseMethodTransformation)
 * A lift method whose base type is a role first checks if the role's 
   enclosing instance is identical to the anchor given after playedBy 
   (Lifting.maybeCreateTeamMemberCheck()). 

    team class UpperTeam {
       final LowerTeam anchorForLowerRoles = ...;
       class UpperRole playedBy LowerRole<@anchoreForLowerRoles> {}
    }

Both hacks could perhaps be avoided, if the team registration code would be changed from using static fields

    class LowerRole {
      static Team[] _OT$activeTeams; 
      // etc.
    }

to using non-static fields in the enclosing team:

    class LowerTeam {
      Team[] _OT$activeTeamsForContainedRoles;
      // etc.
    }

Now the activation code in UpperTeam would have to be changed from
    LowerRole._OT$addTeam(this);
to
    this.anchorForLowerRoles._OT$addTeamForContainedRoles(this);

Thus dynamic binding following anchorForLowerRoles would transport the 
activation into the exact correct context.

Accordingly, initial wrappers would fetch active teams from their enclosing team.

----
today's addition:
It seems that LowerTeam can indeed hold two kinds of team registrations,
if the team itself is bound as the base class of another role.

However, all base-side dispatch code in a role class would always use the
new fields (no need to merge activations from different lists etc.).


Additionally more levels of nesting need more investigation.