@@ -13,30 +13,26 @@ namespace Active.Core{
1313public class Drive : AbstractDecorator {
1414
1515 static int uid ; internal static int id => uid = ID ( uid ) ;
16- //
17- static status hold ;
1816
1917 #if ! AL_OPTIMIZE
20- internal static LogData logData ;
18+
2119 protected object target ;
2220 #endif
2321
2422 public Gate ? this [ status @in , bool crit ] { get {
25- hold = @in ;
23+ StatusRef . hold = @in ;
2624 return @in . running ? Eval ( crit ) : Bypass ( ) ;
2725 } }
2826
29- public Gate ? this [ bool @in , bool crit ] { get {
30- hold = @in ? status . cont ( ) : status . fail ( ) ;
31- return @in ? Eval ( crit ) : Bypass ( ) ;
32- } }
27+ public Gate ? this [ bool @in , bool crit ]
28+ => this [ @in ? status . cont ( ) : status . fail ( ) , crit ] ;
3329
3430 protected Gate Eval ( bool crit , ValidString reason = null )
3531 => new Gate ( this , crit , new LogData ( this , "." , reason ) ) ;
3632
3733 protected Gate ? Bypass ( ValidString reason = null ) {
3834 #if ! AL_OPTIMIZE
39- logData = new LogData ( this , target , reason ) ;
35+ SetLogData ( target , reason ) ;
4036 #endif
4137 return null ;
4238 }
@@ -62,51 +58,13 @@ public StatusRef this[status s]{ get{
6258 #if ! AL_OPTIMIZE
6359 owner . target = s . targetScope ;
6460 #endif
65- return new StatusRef ( crit ? s : hold , logData ) ;
61+ return new StatusRef ( crit ? s : StatusRef . hold , logData ) ;
6662 } }
6763
6864 }
6965
7066 // ===============================================================
7167
72- public readonly struct StatusRef {
73-
74- readonly status x ;
75- readonly LogData logData ;
76-
77- internal StatusRef ( status value , LogData logData )
78- { x = value ; this . logData = logData ; }
79-
80- #if AL_OPTIMIZE
81- public static implicit operator status ( StatusRef ? self )
82- => ToStatus ( self ) ;
83- #else
84- public static implicit operator status ( StatusRef ? self )
85- => status . log ? ToStatusWithLog ( self ) : ToStatus ( self ) ;
86- #endif
87-
88- static status ToStatus ( StatusRef ? self )
89- => self ? . x ?? Self . hold ;
90-
91- #if ! AL_OPTIMIZE
92- static status ToStatusWithLog ( StatusRef ? self ) {
93- if ( self . HasValue ) {
94- var ι = self . Value ;
95- return ι . x . ViaDecorator (
96- ι . logData . scope ,
97- log && ι . logData . Reason ( ) ) ;
98- } else {
99- if ( Self . logData . scope == null ) throw
100- new InvOp ( "Log data is null" ) ;
101- return hold . ViaDecorator (
102- Self . logData . scope ,
103- log && Self . logData . Reason ( ) ) ;
104- }
105- }
106- #endif
107-
108- } // StatusRef
109-
11068}
11169
11270#if ! AL_BEST_PERF
0 commit comments