88using System ;
99using System . Collections . Concurrent ;
1010using System . Collections . Generic ;
11- using System . Text ;
1211using System . Threading ;
1312
1413namespace FastChatProtocolInterface . SimpleFormulaScript
@@ -59,77 +58,6 @@ public static IEnumerable<SifoscObject> EnumerateAllObjects()
5958 public virtual SifoscObject ? Modulo ( SifoscObject ? other ) => null ;
6059 }
6160
62- public sealed record SifoscArray : SifoscObject
63- {
64- public override string Code
65- {
66- get
67- {
68- var sb = new StringBuilder ( ) ;
69- var span = this . Values . Span ;
70-
71- sb . Append ( '[' ) ;
72- for ( int i = 0 ; i < span . Length ; ++ i ) {
73- var obj = span [ i ] ;
74- if ( obj is null ) {
75- continue ;
76- }
77- if ( i != 0 ) {
78- sb . Append ( ',' ) ;
79- }
80- sb . Append ( obj . Code ) ;
81- }
82- sb . Append ( ']' ) ;
83-
84- return sb . ToString ( ) ;
85- }
86- }
87-
88- public ReadOnlyMemory < SifoscObject ? > Values { get ; init ; }
89-
90- protected override bool PrintMembers ( StringBuilder builder )
91- {
92- // 参考:https://qiita.com/muniel/items/fd843abc55a5626e5c45
93-
94- bool appendComma = base . PrintMembers ( builder ) ;
95-
96- var s = this . Values . Span ;
97- for ( int i = 0 ; i < s . Length ; ++ i ) {
98- if ( appendComma ) {
99- builder . Append ( ", " ) ;
100- }
101- var obj = s [ i ] ;
102- if ( obj is SifoscViewForAllObjects view ) {
103- view . PrintMembersSimply ( builder ) ;
104- } else {
105- builder . Append ( obj ) ;
106- }
107- appendComma = true ;
108- }
109- return appendComma ;
110- }
111-
112- public override SifoscObject ? Add ( SifoscObject ? other )
113- {
114- if ( other is SifoscArray otherArray ) {
115- int otherLen = otherArray . Values . Length ;
116- if ( otherLen == 0 ) {
117- return this ;
118- }
119-
120- int thisLen = this . Values . Length ;
121- var newArray = new SifoscObject ? [ thisLen + otherLen ] ;
122-
123- this . Values . CopyTo ( newArray ) ;
124- otherArray . Values . CopyTo ( newArray . AsMemory ( ) [ thisLen ..] ) ;
125-
126- return this with { Values = newArray } ;
127- }
128-
129- return null ;
130- }
131- }
132-
13361 public sealed record SifoscNull : SifoscObject
13462 {
13563 private static readonly SifoscNull _inst = new ( ) ;
@@ -140,48 +68,6 @@ public sealed record SifoscNull : SifoscObject
14068 private SifoscNull ( ) { }
14169 }
14270
143- public sealed record SifoscViewForAllObjects : SifoscObject
144- {
145- private static readonly SifoscViewForAllObjects _inst = new ( ) ;
146-
147- public static SifoscViewForAllObjects Instance => _inst ;
148- public override string Code => "allobj" ;
149-
150- private SifoscViewForAllObjects ( ) { }
151-
152- protected override bool PrintMembers ( StringBuilder builder )
153- {
154- bool appendComma = base . PrintMembers ( builder ) ;
155-
156- foreach ( var item in EnumerateAllObjects ( ) ) {
157- if ( appendComma ) {
158- builder . Append ( ", " ) ;
159- }
160- if ( item is SifoscViewForAllObjects ) {
161- this . PrintMembersSimply ( builder ) ;
162- } else {
163- builder . Append ( item ) ;
164- }
165- appendComma = true ;
166- }
167-
168- return appendComma ;
169- }
170-
171- public void PrintMembersSimply ( StringBuilder builder )
172- {
173- builder
174- . Append ( nameof ( SifoscViewForAllObjects ) )
175- . Append ( " { " ) ;
176-
177- if ( base . PrintMembers ( builder ) ) {
178- builder . Append ( ' ' ) ;
179- }
180-
181- builder . Append ( '}' ) ;
182- }
183- }
184-
18571 public sealed record SifoscBoolean : SifoscObject
18672 {
18773 private static readonly SifoscBoolean _true = new ( ) ;
@@ -194,61 +80,4 @@ public sealed record SifoscBoolean : SifoscObject
19480
19581 private SifoscBoolean ( ) { }
19682 }
197-
198- public sealed record SifoscInteger : SifoscObject
199- {
200- public long Value { get ; init ; }
201- public override string Code => this . Value . ToString ( ) ;
202-
203- public override SifoscObject ? Plus ( )
204- => this ;
205-
206- public override SifoscObject ? Minus ( )
207- => this with { Value = - this . Value } ;
208-
209- public override SifoscObject ? Add ( SifoscObject ? other )
210- {
211- if ( other is SifoscInteger otherInt ) {
212- return this with { Value = this . Value + otherInt . Value } ;
213- }
214-
215- return null ;
216- }
217-
218- public override SifoscObject ? Subtract ( SifoscObject ? other )
219- {
220- if ( other is SifoscInteger otherInt ) {
221- return this with { Value = this . Value - otherInt . Value } ;
222- }
223-
224- return null ;
225- }
226-
227- public override SifoscObject ? Multiply ( SifoscObject ? other )
228- {
229- if ( other is SifoscInteger otherInt ) {
230- return this with { Value = this . Value * otherInt . Value } ;
231- }
232-
233- return null ;
234- }
235-
236- public override SifoscObject ? Divide ( SifoscObject ? other )
237- {
238- if ( other is SifoscInteger otherInt ) {
239- return this with { Value = this . Value / otherInt . Value } ;
240- }
241-
242- return null ;
243- }
244-
245- public override SifoscObject ? Modulo ( SifoscObject ? other )
246- {
247- if ( other is SifoscInteger otherInt ) {
248- return this with { Value = this . Value % otherInt . Value } ;
249- }
250-
251- return null ;
252- }
253- }
25483}
0 commit comments