1 /* Generated by Nim Compiler v1.6.2 */
2 #define NIM_INTBITS 32
3 
4 #include "nimbase.h"
5 #include <string.h>
6 #undef LANGUAGE_C
7 #undef MIPSEB
8 #undef MIPSEL
9 #undef PPC
10 #undef R3000
11 #undef R4000
12 #undef i386
13 #undef linux
14 #undef mips
15 #undef near
16 #undef far
17 #undef powerpc
18 #undef unix
19 #define nimfr_(x, y)
20 #define nimln_(x, y)
21 typedef struct NimStringDesc NimStringDesc;
22 typedef struct TGenericSeq TGenericSeq;
23 typedef struct tyObject_StandardFormatSpecifier__NDU7AW5Eu6Q69c8cH6RDouQ tyObject_StandardFormatSpecifier__NDU7AW5Eu6Q69c8cH6RDouQ;
24 typedef struct tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw;
25 typedef struct tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA;
26 typedef struct Exception Exception;
27 typedef struct RootObj RootObj;
28 typedef struct TNimType TNimType;
29 typedef struct TNimNode TNimNode;
30 typedef struct tySequence__uB9b75OUPRENsBAu4AnoePA tySequence__uB9b75OUPRENsBAu4AnoePA;
31 typedef struct tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA;
32 typedef struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g;
33 typedef struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w;
34 typedef struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ;
35 typedef struct tyObject_GcStack__7fytPA5bBsob6See21YMRA tyObject_GcStack__7fytPA5bBsob6See21YMRA;
36 typedef struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg;
37 typedef struct tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ;
38 typedef struct tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg;
39 typedef struct tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw;
40 typedef struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA;
41 typedef struct tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw;
42 typedef struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw;
43 typedef struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg;
44 typedef struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyTuple__ujsjpB2O9cjj3uDHsXbnSzg;
45 typedef struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg;
46 typedef struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ;
47 typedef struct tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg;
48 typedef struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA;
49 struct TGenericSeq {
50 NI len;
51 NI reserved;
52 };
53 struct NimStringDesc {
54   TGenericSeq Sup;
55 NIM_CHAR data[SEQ_DECL_SIZE];
56 };
57 struct tyObject_StandardFormatSpecifier__NDU7AW5Eu6Q69c8cH6RDouQ {
58 NIM_CHAR fill;
59 NIM_CHAR align;
60 NIM_CHAR sign;
61 NIM_BOOL alternateForm;
62 NIM_BOOL padWithZero;
63 NI minimumWidth;
64 NI precision;
65 NIM_CHAR typ;
66 NI endPosition;
67 };
68 typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
69 typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
70 typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
71 typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
72 struct TNimType {
73 NI size;
74 NI align;
75 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
76 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
77 TNimType* base;
78 TNimNode* node;
79 void* finalizer;
80 tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
81 tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
82 };
83 struct RootObj {
84 TNimType* m_type;
85 };
86 struct Exception {
87   RootObj Sup;
88 Exception* parent;
89 NCSTRING name;
90 NimStringDesc* message;
91 tySequence__uB9b75OUPRENsBAu4AnoePA* trace;
92 Exception* up;
93 };
94 struct tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA {
95   Exception Sup;
96 };
97 struct tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw {
98   tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA Sup;
99 };
100 typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
101 struct TNimNode {
102 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
103 NI offset;
104 TNimType* typ;
105 NCSTRING name;
106 NI len;
107 TNimNode** sons;
108 };
109 struct tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA {
110 NI a;
111 NI b;
112 };
113 struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g {
114 NI refcount;
115 TNimType* typ;
116 };
117 struct tyObject_GcStack__7fytPA5bBsob6See21YMRA {
118 void* bottom;
119 };
120 struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w {
121 NI len;
122 NI cap;
123 tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g** d;
124 };
125 typedef tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ* tyArray__SPr7N6UKfuF549bNPiUvSRw[256];
126 typedef NU32 tyArray__BHbOSqU1t9b3Gt7K2c6fQig[24];
127 typedef tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* tyArray__N1u1nqOgmuJN9cSZrnMHgOQ[32];
128 typedef tyArray__N1u1nqOgmuJN9cSZrnMHgOQ tyArray__B6durA4ZCi1xjJvRtyYxMg[24];
129 typedef tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw* tyArray__lh2A89ahMmYg9bCmpVaplLbA[256];
130 struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA {
131 tyArray__lh2A89ahMmYg9bCmpVaplLbA data;
132 };
133 typedef tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* tyArray__0aOLqZchNi8nWtMTi8ND8w[2];
134 struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw {
135 tyArray__0aOLqZchNi8nWtMTi8ND8w link;
136 NI key;
137 NI upperBound;
138 NI level;
139 };
140 struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg {
141 tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* Field0;
142 NI Field1;
143 };
144 typedef tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyArray__LzOv2eCDGiceMKQstCLmhw[30];
145 struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg {
146 NI len;
147 tyArray__LzOv2eCDGiceMKQstCLmhw chunks;
148 tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg* next;
149 };
150 struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg {
151 NI minLargeObj;
152 NI maxLargeObj;
153 tyArray__SPr7N6UKfuF549bNPiUvSRw freeSmallChunks;
154 NU32 flBitmap;
155 tyArray__BHbOSqU1t9b3Gt7K2c6fQig slBitmap;
156 tyArray__B6durA4ZCi1xjJvRtyYxMg matrix;
157 tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw* llmem;
158 NI currMem;
159 NI maxMem;
160 NI freeMem;
161 NI occ;
162 NI lastSize;
163 tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA chunkStarts;
164 tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* root;
165 tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* deleted;
166 tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* last;
167 tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* freeAvlNodes;
168 NIM_BOOL locked;
169 NIM_BOOL blockChunkSizeIncrease;
170 NI nextChunkSize;
171 tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw bottomData;
172 tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg heapLinks;
173 };
174 struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg {
175 NI stackScans;
176 NI cycleCollections;
177 NI maxThreshold;
178 NI maxStackSize;
179 NI maxStackCells;
180 NI cycleTableSize;
181 NI64 maxPause;
182 };
183 struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ {
184 NI counter;
185 NI max;
186 tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg* head;
187 tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg** data;
188 };
189 struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ {
190 tyObject_GcStack__7fytPA5bBsob6See21YMRA stack;
191 NI cycleThreshold;
192 NI zctThreshold;
193 tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w zct;
194 tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w decStack;
195 tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tempStack;
196 NI recGcLock;
197 tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg region;
198 tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg stat;
199 tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ marked;
200 tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w additionalRoots;
201 NI gcThreadId;
202 };
203 struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA {
204 NCSTRING procname;
205 NI line;
206 NCSTRING filename;
207 };
208 struct tySequence__uB9b75OUPRENsBAu4AnoePA {
209   TGenericSeq Sup;
210   tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA data[SEQ_DECL_SIZE];
211 };
212 N_LIB_PRIVATE N_NIMCALL(tyObject_StandardFormatSpecifier__NDU7AW5Eu6Q69c8cH6RDouQ, parseStandardFormatSpecifier__pureZstrformat_56)(NimStringDesc* s, NI start, NIM_BOOL ignoreUnknownSuffix);
213 static N_INLINE(void, nimZeroMem)(void* p, NI size);
214 static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size);
215 N_LIB_PRIVATE N_NIMCALL(NI, parseSaturatedNatural__pureZparseutils_334)(NimStringDesc* s, NI* b, NI start);
216 N_LIB_PRIVATE N_NOINLINE(void*, newObj)(TNimType* typ, NI size);
217 static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
218 static N_INLINE(void, copyMem__system_1727)(void* dest, void* source, NI size);
219 static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
220 static N_INLINE(NimStringDesc*, X5BX5D___pureZunicode_3215)(NimStringDesc* s, tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA x);
221 N_NIMCALL(NimStringDesc*, mnewString)(NI len);
222 static N_INLINE(tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA, dotdot___stdZenumutils_80)(NI a, NI b);
223 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
224 static N_INLINE(void, asgnRef)(void** dest, void* src);
225 static N_INLINE(void, incRef__system_5300)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
226 static N_INLINE(NI, pluspercent___system_696)(NI x, NI y);
227 static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__system_5262)(void* usr);
228 static N_INLINE(NI, minuspercent___system_716)(NI x, NI y);
229 static N_INLINE(void, decRef__system_5307)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
230 static N_INLINE(NIM_BOOL, ltpercent___system_1005)(NI x, NI y);
231 static N_INLINE(void, rtlAddZCT__system_5305)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
232 N_LIB_PRIVATE N_NOINLINE(void, addZCT__system_5256)(tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w* s, tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
233 N_LIB_PRIVATE N_NIMCALL(void, raiseExceptionEx)(Exception* e, NCSTRING ename, NCSTRING procname, NCSTRING filename, NI line);
234 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
235 static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c);
236 N_LIB_PRIVATE N_NIMCALL(NI, nucruneLen)(NimStringDesc* s);
237 N_LIB_PRIVATE N_NIMCALL(NI, runeOffset__pureZunicode_635)(NimStringDesc* s, NI pos, NI start);
238 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newLen);
239 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, alignString__pureZstrformat_18)(NimStringDesc* s, NI minimumWidth, NIM_CHAR align, NIM_CHAR fill);
240 N_LIB_PRIVATE N_NIMCALL(NI, validateUtf8__pureZunicode_277)(NimStringDesc* s);
241 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nsuRepeatChar)(NIM_CHAR c, NI count);
242 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
243 N_LIB_PRIVATE N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
244 extern TNimType NTIrefvalueerror__Ie1m0dv1ZHg72IgPRr1cDw_;
245 extern TNimType NTIvalueerror__yoNlBGx0D2tRizIdhQuENw_;
246 STRING_LITERAL(TM__qDXzsifTQdn8ucTam9cFp4w_2, "invalid format string, cannot parse: ", 37);
247 STRING_LITERAL(TM__qDXzsifTQdn8ucTam9cFp4w_3, "invalid type in format string for string, expected \'s\', but got ", 64);
248 extern tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ gch__system_5209;
N_INLINE(void,nimSetMem__systemZmemory_7)249 static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size) {
250 	void* T1_;
251 	T1_ = (void*)0;
252 	T1_ = memset(a, v, ((size_t) (size)));
253 }
N_INLINE(void,nimZeroMem)254 static N_INLINE(void, nimZeroMem)(void* p, NI size) {
255 	nimSetMem__systemZmemory_7(p, ((int) 0), size);
256 }
N_INLINE(void,nimCopyMem)257 static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size) {
258 	void* T1_;
259 	T1_ = (void*)0;
260 	T1_ = memcpy(dest, source, ((size_t) (size)));
261 }
N_INLINE(void,copyMem__system_1727)262 static N_INLINE(void, copyMem__system_1727)(void* dest, void* source, NI size) {
263 	nimCopyMem(dest, source, size);
264 }
N_INLINE(void,appendString)265 static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
266 	{
267 		if (!!((src == ((NimStringDesc*) NIM_NIL)))) goto LA3_;
268 		copyMem__system_1727(((void*) ((&(*dest).data[(*dest).Sup.len]))), ((void*) ((*src).data)), ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
269 		(*dest).Sup.len += (*src).Sup.len;
270 	}
271 	LA3_: ;
272 }
N_INLINE(NimStringDesc *,X5BX5D___pureZunicode_3215)273 static N_INLINE(NimStringDesc*, X5BX5D___pureZunicode_3215)(NimStringDesc* s, tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA x) {
274 	NimStringDesc* result;
275 	NI a;
276 	NI L;
277 	result = NIM_NIL;
278 	a = x.a;
279 	L = (NI)((NI)((NI)((s ? s->Sup.len : 0) - x.b) - a) + ((NI) 1));
280 	result = mnewString(((NI) (L)));
281 	{
282 		NI i;
283 		NI i_2;
284 		i = (NI)0;
285 		i_2 = ((NI) 0);
286 		{
287 			while (1) {
288 				if (!(i_2 < L)) goto LA3;
289 				i = i_2;
290 				result->data[i] = s->data[(NI)(i + a)];
291 				i_2 += ((NI) 1);
292 			} LA3: ;
293 		}
294 	}
295 	return result;
296 }
N_INLINE(tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA,dotdot___stdZenumutils_80)297 static N_INLINE(tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA, dotdot___stdZenumutils_80)(NI a, NI b) {
298 	tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA result;
299 	nimZeroMem((void*)(&result), sizeof(tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA));
300 	nimZeroMem((void*)(&result), sizeof(tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA));
301 	result.a = a;
302 	result.b = b;
303 	return result;
304 }
N_INLINE(NI,pluspercent___system_696)305 static N_INLINE(NI, pluspercent___system_696)(NI x, NI y) {
306 	NI result;
307 	result = (NI)0;
308 	result = ((NI) ((NU)((NU32)(((NU) (x))) + (NU32)(((NU) (y))))));
309 	return result;
310 }
N_INLINE(void,incRef__system_5300)311 static N_INLINE(void, incRef__system_5300)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
312 	(*c).refcount = pluspercent___system_696((*c).refcount, ((NI) 8));
313 }
N_INLINE(NI,minuspercent___system_716)314 static N_INLINE(NI, minuspercent___system_716)(NI x, NI y) {
315 	NI result;
316 	result = (NI)0;
317 	result = ((NI) ((NU)((NU32)(((NU) (x))) - (NU32)(((NU) (y))))));
318 	return result;
319 }
N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g *,usrToCell__system_5262)320 static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__system_5262)(void* usr) {
321 	tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* result;
322 	NI T1_;
323 	result = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
324 	T1_ = (NI)0;
325 	T1_ = minuspercent___system_716(((NI) (ptrdiff_t) (usr)), ((NI) 8));
326 	result = ((tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*) (T1_));
327 	return result;
328 }
N_INLINE(NIM_BOOL,ltpercent___system_1005)329 static N_INLINE(NIM_BOOL, ltpercent___system_1005)(NI x, NI y) {
330 	NIM_BOOL result;
331 	result = (NIM_BOOL)0;
332 	result = ((NU32)(((NU) (x))) < (NU32)(((NU) (y))));
333 	return result;
334 }
N_INLINE(void,rtlAddZCT__system_5305)335 static N_INLINE(void, rtlAddZCT__system_5305)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
336 	addZCT__system_5256((&gch__system_5209.zct), c);
337 }
N_INLINE(void,decRef__system_5307)338 static N_INLINE(void, decRef__system_5307)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
339 	(*c).refcount = minuspercent___system_716((*c).refcount, ((NI) 8));
340 	{
341 		NIM_BOOL T3_;
342 		T3_ = (NIM_BOOL)0;
343 		T3_ = ltpercent___system_1005((*c).refcount, ((NI) 8));
344 		if (!T3_) goto LA4_;
345 		rtlAddZCT__system_5305(c);
346 	}
347 	LA4_: ;
348 }
N_INLINE(void,asgnRef)349 static N_INLINE(void, asgnRef)(void** dest, void* src) {
350 	{
351 		tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* T5_;
352 		if (!!((src == NIM_NIL))) goto LA3_;
353 		T5_ = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
354 		T5_ = usrToCell__system_5262(src);
355 		incRef__system_5300(T5_);
356 	}
357 	LA3_: ;
358 	{
359 		tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* T10_;
360 		if (!!(((*dest) == NIM_NIL))) goto LA8_;
361 		T10_ = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
362 		T10_ = usrToCell__system_5262((*dest));
363 		decRef__system_5307(T10_);
364 	}
365 	LA8_: ;
366 	(*dest) = src;
367 }
N_NIMCALL(tyObject_StandardFormatSpecifier__NDU7AW5Eu6Q69c8cH6RDouQ,parseStandardFormatSpecifier__pureZstrformat_56)368 N_LIB_PRIVATE N_NIMCALL(tyObject_StandardFormatSpecifier__NDU7AW5Eu6Q69c8cH6RDouQ, parseStandardFormatSpecifier__pureZstrformat_56)(NimStringDesc* s, NI start, NIM_BOOL ignoreUnknownSuffix) {
369 	tyObject_StandardFormatSpecifier__NDU7AW5Eu6Q69c8cH6RDouQ result;
370 	NI i;
371 	NI parsedLength;
372 	nimZeroMem((void*)(&result), sizeof(tyObject_StandardFormatSpecifier__NDU7AW5Eu6Q69c8cH6RDouQ));
373 	result.fill = 32;
374 	result.align = 0;
375 	result.sign = 45;
376 	i = start;
377 	{
378 		NIM_BOOL T3_;
379 		T3_ = (NIM_BOOL)0;
380 		T3_ = ((NI)(i + ((NI) 1)) < (s ? s->Sup.len : 0));
381 		if (!(T3_)) goto LA4_;
382 		T3_ = (((NU8)(s->data[(NI)(i + ((NI) 1))])) == ((NU8)(60)) || ((NU8)(s->data[(NI)(i + ((NI) 1))])) == ((NU8)(62)) || ((NU8)(s->data[(NI)(i + ((NI) 1))])) == ((NU8)(94)));
383 		LA4_: ;
384 		if (!T3_) goto LA5_;
385 		result.fill = s->data[i];
386 		result.align = s->data[(NI)(i + ((NI) 1))];
387 		i += ((NI) 2);
388 	}
389 	goto LA1_;
390 	LA5_: ;
391 	{
392 		NIM_BOOL T8_;
393 		T8_ = (NIM_BOOL)0;
394 		T8_ = (i < (s ? s->Sup.len : 0));
395 		if (!(T8_)) goto LA9_;
396 		T8_ = (((NU8)(s->data[i])) == ((NU8)(60)) || ((NU8)(s->data[i])) == ((NU8)(62)) || ((NU8)(s->data[i])) == ((NU8)(94)));
397 		LA9_: ;
398 		if (!T8_) goto LA10_;
399 		result.align = s->data[i];
400 		i += ((NI) 1);
401 	}
402 	goto LA1_;
403 	LA10_: ;
404 	LA1_: ;
405 	{
406 		NIM_BOOL T14_;
407 		T14_ = (NIM_BOOL)0;
408 		T14_ = (i < (s ? s->Sup.len : 0));
409 		if (!(T14_)) goto LA15_;
410 		T14_ = (((NU8)(s->data[i])) == ((NU8)(45)) || ((NU8)(s->data[i])) == ((NU8)(43)) || ((NU8)(s->data[i])) == ((NU8)(32)));
411 		LA15_: ;
412 		if (!T14_) goto LA16_;
413 		result.sign = s->data[i];
414 		i += ((NI) 1);
415 	}
416 	LA16_: ;
417 	{
418 		NIM_BOOL T20_;
419 		T20_ = (NIM_BOOL)0;
420 		T20_ = (i < (s ? s->Sup.len : 0));
421 		if (!(T20_)) goto LA21_;
422 		T20_ = ((NU8)(s->data[i]) == (NU8)(35));
423 		LA21_: ;
424 		if (!T20_) goto LA22_;
425 		result.alternateForm = NIM_TRUE;
426 		i += ((NI) 1);
427 	}
428 	LA22_: ;
429 	{
430 		NIM_BOOL T26_;
431 		NIM_BOOL T27_;
432 		T26_ = (NIM_BOOL)0;
433 		T27_ = (NIM_BOOL)0;
434 		T27_ = ((NI)(i + ((NI) 1)) < (s ? s->Sup.len : 0));
435 		if (!(T27_)) goto LA28_;
436 		T27_ = ((NU8)(s->data[i]) == (NU8)(48));
437 		LA28_: ;
438 		T26_ = T27_;
439 		if (!(T26_)) goto LA29_;
440 		T26_ = (((NU8)(s->data[(NI)(i + ((NI) 1))])) >= ((NU8)(48)) && ((NU8)(s->data[(NI)(i + ((NI) 1))])) <= ((NU8)(57)));
441 		LA29_: ;
442 		if (!T26_) goto LA30_;
443 		result.padWithZero = NIM_TRUE;
444 		i += ((NI) 1);
445 	}
446 	LA30_: ;
447 	parsedLength = parseSaturatedNatural__pureZparseutils_334(s, (&result.minimumWidth), i);
448 	i += parsedLength;
449 	{
450 		NIM_BOOL T34_;
451 		NI parsedLengthB;
452 		T34_ = (NIM_BOOL)0;
453 		T34_ = (i < (s ? s->Sup.len : 0));
454 		if (!(T34_)) goto LA35_;
455 		T34_ = ((NU8)(s->data[i]) == (NU8)(46));
456 		LA35_: ;
457 		if (!T34_) goto LA36_;
458 		i += ((NI) 1);
459 		parsedLengthB = parseSaturatedNatural__pureZparseutils_334(s, (&result.precision), i);
460 		i += parsedLengthB;
461 	}
462 	goto LA32_;
463 	LA36_: ;
464 	{
465 		result.precision = ((NI) -1);
466 	}
467 	LA32_: ;
468 	{
469 		NIM_BOOL T41_;
470 		T41_ = (NIM_BOOL)0;
471 		T41_ = (i < (s ? s->Sup.len : 0));
472 		if (!(T41_)) goto LA42_;
473 		T41_ = (((NU8)(s->data[i])) >= ((NU8)(65)) && ((NU8)(s->data[i])) <= ((NU8)(90)) || ((NU8)(s->data[i])) >= ((NU8)(97)) && ((NU8)(s->data[i])) <= ((NU8)(122)));
474 		LA42_: ;
475 		if (!T41_) goto LA43_;
476 		result.typ = s->data[i];
477 		i += ((NI) 1);
478 	}
479 	LA43_: ;
480 	result.endPosition = i;
481 	{
482 		NIM_BOOL T47_;
483 		tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw* T51_;
484 		NimStringDesc* T52_;
485 		tyObject_HSlice__EE5dzjqoOrHT6HJhIPXAvA T53_;
486 		NimStringDesc* T54_;
487 		T47_ = (NIM_BOOL)0;
488 		T47_ = !((i == (s ? s->Sup.len : 0)));
489 		if (!(T47_)) goto LA48_;
490 		T47_ = !(ignoreUnknownSuffix);
491 		LA48_: ;
492 		if (!T47_) goto LA49_;
493 		T51_ = NIM_NIL;
494 		T51_ = (tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw*) newObj((&NTIrefvalueerror__Ie1m0dv1ZHg72IgPRr1cDw_), sizeof(tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw));
495 		(*T51_).Sup.Sup.Sup.m_type = (&NTIvalueerror__yoNlBGx0D2tRizIdhQuENw_);
496 		(*T51_).Sup.Sup.name = "ValueError";
497 		T52_ = NIM_NIL;
498 		T53_ = dotdot___stdZenumutils_80(i, ((NI) 1));
499 		T54_ = NIM_NIL;
500 		T54_ = X5BX5D___pureZunicode_3215(s, T53_);
501 		T52_ = rawNewString((T54_ ? T54_->Sup.len : 0) + 37);
502 appendString(T52_, ((NimStringDesc*) &TM__qDXzsifTQdn8ucTam9cFp4w_2));
503 appendString(T52_, T54_);
504 		asgnRef((void**) (&(*T51_).Sup.Sup.message), T52_);
505 		asgnRef((void**) (&(*T51_).Sup.Sup.parent), ((Exception*) NIM_NIL));
506 		raiseExceptionEx((Exception*)T51_, "ValueError", "parseStandardFormatSpecifier", "strformat.nim", 468);
507 	}
508 	LA49_: ;
509 	return result;
510 }
N_INLINE(void,appendChar)511 static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c) {
512 	(*dest).data[(*dest).Sup.len] = c;
513 	(*dest).data[(NI)((*dest).Sup.len + ((NI) 1))] = 0;
514 	(*dest).Sup.len += ((NI) 1);
515 }
N_NIMCALL(NimStringDesc *,alignString__pureZstrformat_18)516 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, alignString__pureZstrformat_18)(NimStringDesc* s, NI minimumWidth, NIM_CHAR align, NIM_CHAR fill) {
517 	NimStringDesc* result;
518 	result = NIM_NIL;
519 	{
520 		if (!(minimumWidth == ((NI) 0))) goto LA3_;
521 		result = copyString(s);
522 	}
523 	goto LA1_;
524 	LA3_: ;
525 	{
526 		NI sRuneLen;
527 		NI toFill;
528 		{
529 			NI T8_;
530 			T8_ = (NI)0;
531 			T8_ = validateUtf8__pureZunicode_277(s);
532 			if (!(T8_ == ((NI) -1))) goto LA9_;
533 			sRuneLen = nucruneLen(s);
534 		}
535 		goto LA6_;
536 		LA9_: ;
537 		{
538 			sRuneLen = (s ? s->Sup.len : 0);
539 		}
540 		LA6_: ;
541 		toFill = (NI)(minimumWidth - sRuneLen);
542 		{
543 			if (!(toFill <= ((NI) 0))) goto LA14_;
544 			result = copyString(s);
545 		}
546 		goto LA12_;
547 		LA14_: ;
548 		{
549 			NIM_BOOL T17_;
550 			NimStringDesc* T21_;
551 			NimStringDesc* T22_;
552 			T17_ = (NIM_BOOL)0;
553 			T17_ = ((NU8)(align) == (NU8)(60));
554 			if (T17_) goto LA18_;
555 			T17_ = ((NU8)(align) == (NU8)(0));
556 			LA18_: ;
557 			if (!T17_) goto LA19_;
558 			T21_ = NIM_NIL;
559 			T22_ = NIM_NIL;
560 			T22_ = nsuRepeatChar(fill, ((NI) (toFill)));
561 			T21_ = rawNewString((s ? s->Sup.len : 0) + (T22_ ? T22_->Sup.len : 0) + 0);
562 appendString(T21_, s);
563 appendString(T21_, T22_);
564 			result = T21_;
565 		}
566 		goto LA12_;
567 		LA19_: ;
568 		{
569 			NI half;
570 			NimStringDesc* T26_;
571 			NimStringDesc* T27_;
572 			NimStringDesc* T28_;
573 			if (!((NU8)(align) == (NU8)(94))) goto LA24_;
574 			half = (NI)(toFill / ((NI) 2));
575 			T26_ = NIM_NIL;
576 			T27_ = NIM_NIL;
577 			T27_ = nsuRepeatChar(fill, ((NI) (half)));
578 			T28_ = NIM_NIL;
579 			T28_ = nsuRepeatChar(fill, ((NI) ((NI)(toFill - half))));
580 			T26_ = rawNewString((T27_ ? T27_->Sup.len : 0) + (s ? s->Sup.len : 0) + (T28_ ? T28_->Sup.len : 0) + 0);
581 appendString(T26_, T27_);
582 appendString(T26_, s);
583 appendString(T26_, T28_);
584 			result = T26_;
585 		}
586 		goto LA12_;
587 		LA24_: ;
588 		{
589 			NimStringDesc* T30_;
590 			NimStringDesc* T31_;
591 			T30_ = NIM_NIL;
592 			T31_ = NIM_NIL;
593 			T31_ = nsuRepeatChar(fill, ((NI) (toFill)));
594 			T30_ = rawNewString((T31_ ? T31_->Sup.len : 0) + (s ? s->Sup.len : 0) + 0);
595 appendString(T30_, T31_);
596 appendString(T30_, s);
597 			result = T30_;
598 		}
599 		LA12_: ;
600 	}
601 	LA1_: ;
602 	return result;
603 }
N_NIMCALL(void,formatValue__pureZstrformat_160)604 N_LIB_PRIVATE N_NIMCALL(void, formatValue__pureZstrformat_160)(NimStringDesc** result, NimStringDesc* value, NimStringDesc* specifier) {
605 	tyObject_StandardFormatSpecifier__NDU7AW5Eu6Q69c8cH6RDouQ spec;
606 	NimStringDesc* value_2;
607 	NimStringDesc* T15_;
608 	spec = parseStandardFormatSpecifier__pureZstrformat_56(specifier, ((NI) 0), NIM_FALSE);
609 	value_2 = copyString(value);
610 	switch (((NU8)(spec.typ))) {
611 	case 115:
612 	case 0:
613 	{
614 	}
615 	break;
616 	default:
617 	{
618 		tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw* T3_;
619 		NimStringDesc* T4_;
620 		T3_ = NIM_NIL;
621 		T3_ = (tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw*) newObj((&NTIrefvalueerror__Ie1m0dv1ZHg72IgPRr1cDw_), sizeof(tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw));
622 		(*T3_).Sup.Sup.Sup.m_type = (&NTIvalueerror__yoNlBGx0D2tRizIdhQuENw_);
623 		(*T3_).Sup.Sup.name = "ValueError";
624 		T4_ = NIM_NIL;
625 		T4_ = rawNewString(65);
626 appendString(T4_, ((NimStringDesc*) &TM__qDXzsifTQdn8ucTam9cFp4w_3));
627 appendChar(T4_, spec.typ);
628 		asgnRef((void**) (&(*T3_).Sup.Sup.message), T4_);
629 		asgnRef((void**) (&(*T3_).Sup.Sup.parent), ((Exception*) NIM_NIL));
630 		raiseExceptionEx((Exception*)T3_, "ValueError", "formatValue", "strformat.nim", 558);
631 	}
632 	break;
633 	}
634 	{
635 		if (!!((spec.precision == ((NI) -1)))) goto LA7_;
636 		{
637 			NI T11_;
638 			NI T14_;
639 			T11_ = (NI)0;
640 			T11_ = nucruneLen(value_2);
641 			if (!(spec.precision < T11_)) goto LA12_;
642 			T14_ = (NI)0;
643 			T14_ = runeOffset__pureZunicode_635(value_2, ((NI) (spec.precision)), ((NI) 0));
644 			value_2 = setLengthStr(value_2, ((NI) (T14_)));
645 		}
646 		LA12_: ;
647 	}
648 	LA7_: ;
649 	T15_ = NIM_NIL;
650 	T15_ = alignString__pureZstrformat_18(value_2, spec.minimumWidth, spec.align, spec.fill);
651 	unsureAsgnRef((void**) (&(*result)), resizeString((*result), (T15_ ? T15_->Sup.len : 0) + 0));
652 appendString((*result), T15_);
653 }
654