lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Quintiq file version 2.0
#parent: #root
MethodOverride FindOrCreateSharedWith (
  LibOpt_ScopeThin scope,
  LibOpt_Group group
) as LibOpt_ScopeShared
{
  TextBody:
  [*
    result := null( LibOpt_ScopeShared );
    
    group_vector := this.GroupVectorAdd( scope, group );
    if( scope.Index() = 0 )
    {
      result := LibOpt_ScopeShared32::FindSet32( this.Set().BitOr( scope.Mask() ), this.Type(), group_vector );
    }
    else
    {
      vector := NumberVector::Construct( scope.Index() + 1 );
      vector.Set( 0, this.Set() );
      vector.Set( scope.Index(), scope.Mask() );
      result := LibOpt_ScopeSharedVector::FindSetVector( vector.AsBinaryValue(), this.Type(), group_vector );
    }
    
    if( isnull( result ) )
    {
      if( scope.Index() = 0 )
      {
        result := this.Owner().ScopeSharedOwned( relnew,
                                                 LibOpt_ScopeShared32,
                                                 Set := this.Set().BitOr( scope.Mask() ),
                                                 Type := this.Type(),
                                                 GroupVector := group_vector
                                                 );
    
        this.CopyScopesTo( scope, group, result );
      }
      else
      {
        result := LibOpt_ScopeSharedVector::From32( this, scope, group );
      }
    }
    
    return result;
  *]
}