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 tyTuple__7q7q3E6Oj24ZNVJb9aonhAg tyTuple__7q7q3E6Oj24ZNVJb9aonhAg;
24 struct TGenericSeq {
25 NI len;
26 NI reserved;
27 };
28 struct NimStringDesc {
29   TGenericSeq Sup;
30 NIM_CHAR data[SEQ_DECL_SIZE];
31 };
32 typedef NimStringDesc* tyArray__Re75IspeoxXy2oCZHwcRrA[2];
33 struct tyTuple__7q7q3E6Oj24ZNVJb9aonhAg {
34 NimStringDesc* Field0;
35 NimStringDesc* Field1;
36 NimStringDesc* Field2;
37 };
38 typedef NimStringDesc* tyArray__sMpvt1sOxOJ3LFGulnbeMQ[4];
39 typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1];
40 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nsuFormatOpenArray)(NimStringDesc* formatstr, NimStringDesc** a, NI aLen_0);
41 static N_INLINE(void, nimZeroMem)(void* p, NI size);
42 static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size);
43 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
44 static N_INLINE(NIM_BOOL, contains__pureZos_660)(NIM_CHAR* a, NI aLen_0, NIM_CHAR item);
45 static N_INLINE(NI, find__pureZos_665)(NIM_CHAR* a, NI aLen_0, NIM_CHAR item);
46 N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__systemZassertions_56)(NimStringDesc* msg);
47 static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
48 static N_INLINE(void, copyMem__system_1727)(void* dest, void* source, NI size);
49 static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
50 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___nimpaths_29)(tyTuple__7q7q3E6Oj24ZNVJb9aonhAg x);
51 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
52 N_LIB_PRIVATE N_NIMCALL(void, addQuoted__pureZos_449)(NimStringDesc** s, NimStringDesc* x);
53 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
54 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, interp__nimpaths_25)(NimStringDesc* path, NimStringDesc* nimr);
55 N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosfileExists)(NimStringDesc* filename);
56 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nospquoteShell)(NimStringDesc* s);
57 N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0);
58 N_LIB_PRIVATE N_NIMCALL(NI, nosexecShellCmd)(NimStringDesc* command);
59 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_2, "nimr", 4);
60 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_3, "nimpaths.nim(37, 12) `\'$\' notin result` ", 40);
61 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_4, "(", 1);
62 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_5, ", ", 2);
63 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_6, ",", 1);
64 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_7, ")", 1);
65 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_8, "$nimr/tools/dochack/dochack.js", 30);
66 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_9, "$nim js -d:release $file", 24);
67 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_10, "nim", 3);
68 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_11, "file", 4);
69 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_12, "$nimr/tools/dochack/dochack.nim", 31);
70 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_13, "getDocHacksJs: cmd: ", 20);
71 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_14, "nimpaths.nim(46, 14) `execShellCmd(cmd) == 0` ", 46);
72 STRING_LITERAL(TM__O9aA9byHYLJvQWppK9cdLra6Q_15, "nimpaths.nim(47, 12) `docHackJs2.fileExists` ", 45);
N_INLINE(void,nimSetMem__systemZmemory_7)73 static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size) {
74 	void* T1_;
75 	T1_ = (void*)0;
76 	T1_ = memset(a, v, ((size_t) (size)));
77 }
N_INLINE(void,nimZeroMem)78 static N_INLINE(void, nimZeroMem)(void* p, NI size) {
79 	nimSetMem__systemZmemory_7(p, ((int) 0), size);
80 }
N_INLINE(NI,find__pureZos_665)81 static N_INLINE(NI, find__pureZos_665)(NIM_CHAR* a, NI aLen_0, NIM_CHAR item) {
82 	NI result;
83 {	result = (NI)0;
84 	result = ((NI) 0);
85 	{
86 		NIM_CHAR i;
87 		NI i_2;
88 		i = (NIM_CHAR)0;
89 		i_2 = ((NI) 0);
90 		{
91 			while (1) {
92 				if (!(i_2 < aLen_0)) goto LA3;
93 				i = a[i_2];
94 				{
95 					if (!((NU8)(i) == (NU8)(item))) goto LA6_;
96 					goto BeforeRet_;
97 				}
98 				LA6_: ;
99 				result += ((NI) 1);
100 				i_2 += ((NI) 1);
101 			} LA3: ;
102 		}
103 	}
104 	result = ((NI) -1);
105 	}BeforeRet_: ;
106 	return result;
107 }
N_INLINE(NIM_BOOL,contains__pureZos_660)108 static N_INLINE(NIM_BOOL, contains__pureZos_660)(NIM_CHAR* a, NI aLen_0, NIM_CHAR item) {
109 	NIM_BOOL result;
110 	NI T1_;
111 {	result = (NIM_BOOL)0;
112 	T1_ = (NI)0;
113 	T1_ = find__pureZos_665(a, aLen_0, item);
114 	result = (((NI) 0) <= T1_);
115 	goto BeforeRet_;
116 	}BeforeRet_: ;
117 	return result;
118 }
N_INLINE(void,nimCopyMem)119 static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size) {
120 	void* T1_;
121 	T1_ = (void*)0;
122 	T1_ = memcpy(dest, source, ((size_t) (size)));
123 }
N_INLINE(void,copyMem__system_1727)124 static N_INLINE(void, copyMem__system_1727)(void* dest, void* source, NI size) {
125 	nimCopyMem(dest, source, size);
126 }
N_INLINE(void,appendString)127 static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
128 	{
129 		if (!!((src == ((NimStringDesc*) NIM_NIL)))) goto LA3_;
130 		copyMem__system_1727(((void*) ((&(*dest).data[(*dest).Sup.len]))), ((void*) ((*src).data)), ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
131 		(*dest).Sup.len += (*src).Sup.len;
132 	}
133 	LA3_: ;
134 }
N_NIMCALL(NimStringDesc *,dollar___nimpaths_29)135 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___nimpaths_29)(tyTuple__7q7q3E6Oj24ZNVJb9aonhAg x) {
136 	NimStringDesc* result;
137 	NI count;
138 	result = NIM_NIL;
139 	result = copyString(((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_4));
140 	count = ((NI) 0);
141 	{
142 		if (!(((NI) 0) < count)) goto LA3_;
143 		result = resizeString(result, 2);
144 appendString(result, ((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_5));
145 	}
146 	LA3_: ;
147 	count += ((NI) 1);
148 	addQuoted__pureZos_449((&result), x.Field0);
149 	{
150 		if (!(((NI) 0) < count)) goto LA7_;
151 		result = resizeString(result, 2);
152 appendString(result, ((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_5));
153 	}
154 	LA7_: ;
155 	count += ((NI) 1);
156 	addQuoted__pureZos_449((&result), x.Field1);
157 	{
158 		if (!(((NI) 0) < count)) goto LA11_;
159 		result = resizeString(result, 2);
160 appendString(result, ((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_5));
161 	}
162 	LA11_: ;
163 	count += ((NI) 1);
164 	addQuoted__pureZos_449((&result), x.Field2);
165 	{
166 		if (!(count == ((NI) 1))) goto LA15_;
167 		result = resizeString(result, 1);
168 appendString(result, ((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_6));
169 	}
170 	LA15_: ;
171 	result = resizeString(result, 1);
172 appendString(result, ((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_7));
173 	return result;
174 }
N_NIMCALL(NimStringDesc *,interp__nimpaths_25)175 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, interp__nimpaths_25)(NimStringDesc* path, NimStringDesc* nimr) {
176 	NimStringDesc* result;
177 	tyArray__Re75IspeoxXy2oCZHwcRrA T1_;
178 	result = NIM_NIL;
179 	nimZeroMem((void*)T1_, sizeof(tyArray__Re75IspeoxXy2oCZHwcRrA));
180 	T1_[0] = copyString(((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_2));
181 	T1_[1] = copyString(nimr);
182 	result = nsuFormatOpenArray(path, T1_, 2);
183 	{
184 		NIM_BOOL T4_;
185 		NimStringDesc* T7_;
186 		tyTuple__7q7q3E6Oj24ZNVJb9aonhAg T8_;
187 		NimStringDesc* T9_;
188 		T4_ = (NIM_BOOL)0;
189 		T4_ = contains__pureZos_660(result->data, (result ? result->Sup.len : 0), 36);
190 		if (!!(!(T4_))) goto LA5_;
191 		T7_ = NIM_NIL;
192 		nimZeroMem((void*)(&T8_), sizeof(tyTuple__7q7q3E6Oj24ZNVJb9aonhAg));
193 		T8_.Field0 = copyString(path);
194 		T8_.Field1 = copyString(nimr);
195 		T8_.Field2 = copyString(result);
196 		T9_ = NIM_NIL;
197 		T9_ = dollar___nimpaths_29(T8_);
198 		T7_ = rawNewString((T9_ ? T9_->Sup.len : 0) + 40);
199 appendString(T7_, ((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_3));
200 appendString(T7_, T9_);
201 		failedAssertImpl__systemZassertions_56(T7_);
202 	}
203 	LA5_: ;
204 	return result;
205 }
N_NIMCALL(NimStringDesc *,getDocHacksJs__nimpaths_84)206 N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, getDocHacksJs__nimpaths_84)(NimStringDesc* nimr, NimStringDesc* nim, NIM_BOOL forceRebuild) {
207 	NimStringDesc* result;
208 	NimStringDesc* docHackJs2;
209 	result = NIM_NIL;
210 	docHackJs2 = interp__nimpaths_25(((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_8), nimr);
211 	{
212 		NIM_BOOL T3_;
213 		NIM_BOOL T5_;
214 		NimStringDesc* cmd;
215 		tyArray__sMpvt1sOxOJ3LFGulnbeMQ T8_;
216 		NimStringDesc* T9_;
217 		tyArray__nHXaesL0DJZHyVS07ARPRA T10_;
218 		NimStringDesc* T11_;
219 		T3_ = (NIM_BOOL)0;
220 		T3_ = forceRebuild;
221 		if (T3_) goto LA4_;
222 		T5_ = (NIM_BOOL)0;
223 		T5_ = nosfileExists(docHackJs2);
224 		T3_ = !(T5_);
225 		LA4_: ;
226 		if (!T3_) goto LA6_;
227 		nimZeroMem((void*)T8_, sizeof(tyArray__sMpvt1sOxOJ3LFGulnbeMQ));
228 		T8_[0] = copyString(((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_10));
229 		T8_[1] = nospquoteShell(nim);
230 		T8_[2] = copyString(((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_11));
231 		T9_ = NIM_NIL;
232 		T9_ = interp__nimpaths_25(((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_12), nimr);
233 		T8_[3] = nospquoteShell(T9_);
234 		cmd = nsuFormatOpenArray(((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_9), T8_, 4);
235 		nimZeroMem((void*)T10_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA));
236 		T11_ = NIM_NIL;
237 		T11_ = rawNewString((cmd ? cmd->Sup.len : 0) + 20);
238 appendString(T11_, ((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_13));
239 appendString(T11_, cmd);
240 		T10_[0] = T11_;
241 		echoBinSafe(T10_, 1);
242 		{
243 			NI T14_;
244 			NimStringDesc* T17_;
245 			T14_ = (NI)0;
246 			T14_ = nosexecShellCmd(cmd);
247 			if (!!((T14_ == ((NI) 0)))) goto LA15_;
248 			T17_ = NIM_NIL;
249 			T17_ = rawNewString((cmd ? cmd->Sup.len : 0) + 46);
250 appendString(T17_, ((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_14));
251 appendString(T17_, cmd);
252 			failedAssertImpl__systemZassertions_56(T17_);
253 		}
254 		LA15_: ;
255 	}
256 	LA6_: ;
257 	{
258 		NIM_BOOL T20_;
259 		T20_ = (NIM_BOOL)0;
260 		T20_ = nosfileExists(docHackJs2);
261 		if (!!(T20_)) goto LA21_;
262 		failedAssertImpl__systemZassertions_56(((NimStringDesc*) &TM__O9aA9byHYLJvQWppK9cdLra6Q_15));
263 	}
264 	LA21_: ;
265 	result = copyString(docHackJs2);
266 	return result;
267 }
268