/* Generated by Nim Compiler v0.10.2 */
/*   (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 64
#include "nimbase.h"

#include <string.h>
typedef struct tsym226846 tsym226846;
typedef struct tcontext291021 tcontext291021;
typedef struct tscope226840 tscope226840;
typedef struct tidentiter236141 tidentiter236141;
typedef struct tident201021 tident201021;
typedef struct tstrtable226820 tstrtable226820;
typedef struct tsymseq226818 tsymseq226818;
typedef struct TGenericSeq TGenericSeq;
typedef struct tnodeseq226810 tnodeseq226810;
typedef struct tnode226816 tnode226816;
typedef struct tidobj201015 tidobj201015;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct ttypeseq226848 ttypeseq226848;
typedef struct ttype226852 ttype226852;
typedef struct TY226947 TY226947;
typedef struct tinstantiation226836 tinstantiation226836;
typedef struct tlineinfo196539 tlineinfo196539;
typedef struct tloc226830 tloc226830;
typedef struct trope178009 trope178009;
typedef struct tlib226834 tlib226834;
typedef struct NimStringDesc NimStringDesc;
typedef struct tpasscontext287005 tpasscontext287005;
typedef struct tproccon291011 tproccon291011;
typedef struct intset223056 intset223056;
typedef struct ttrunk223052 ttrunk223052;
typedef struct ttrunkseq223054 ttrunkseq223054;
typedef struct tlinkedlist129028 tlinkedlist129028;
typedef struct tlistentry129022 tlistentry129022;
typedef struct tidtable226864 tidtable226864;
typedef struct tidpairseq226862 tidpairseq226862;
typedef struct tidpair226860 tidpair226860;
typedef struct tctx290048 tctx290048;
typedef struct TY291133 TY291133;
typedef struct tinstantiationpair291013 tinstantiationpair291013;
typedef struct TY226936 TY226936;
typedef struct TY290250 TY290250;
typedef struct TY197414 TY197414;
typedef struct pprocHEX3Aobjecttype290230 pprocHEX3Aobjecttype290230;
typedef struct TY290269 TY290269;
typedef struct TY290270 TY290270;
typedef struct vmargs290042 vmargs290042;
typedef struct TY290231 TY290231;
typedef struct tblock290030 tblock290030;
typedef struct TY290211 TY290211;
typedef struct TY290237 TY290237;
struct  tidentiter236141  {
NI H;
tident201021* Name;
};
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  tstrtable226820  {
NI Counter;
tsymseq226818* Data;
};
struct  tscope226840  {
NI Depthlevel;
tstrtable226820 Symbols;
tnodeseq226810* Usingsyms;
tscope226840* Parent;
};
typedef N_NIMCALL_PTR(void, TY3089) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3094) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3089 marker;
TY3094 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  tidobj201015  {
  TNimObject Sup;
NI Id;
};
struct  tlineinfo196539  {
NI16 Line;
NI16 Col;
NI32 Fileindex;
};
struct  tloc226830  {
NU8 K;
NU8 S;
NU8 Flags;
ttype226852* T;
trope178009* R;
trope178009* Heaproot;
};
struct  tsym226846  {
  tidobj201015 Sup;
NU8 Kind;
union {
struct {ttypeseq226848* Typeinstcache;
tscope226840* Typscope;
} S1;
struct {TY226947* Procinstcache;
tscope226840* Scope;
} S2;
struct {TY226947* Usedgenerics;
tstrtable226820 Tab;
} S3;
struct {tsym226846* Guard;
} S4;
} kindU;
NU16 Magic;
ttype226852* Typ;
tident201021* Name;
tlineinfo196539 Info;
tsym226846* Owner;
NU32 Flags;
tnode226816* Ast;
NU32 Options;
NI Position;
NI Offset;
tloc226830 Loc;
tlib226834* Annex;
tnode226816* Constraint;
};
struct  ttype226852  {
  tidobj201015 Sup;
NU8 Kind;
NU8 Callconv;
NU32 Flags;
ttypeseq226848* Sons;
tnode226816* N;
tsym226846* Owner;
tsym226846* Sym;
tsym226846* Destructor;
tsym226846* Deepcopy;
NI64 Size;
NI16 Align;
NI16 Locklevel;
tloc226830 Loc;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NimStringDesc* TY170951[2];
struct  tident201021  {
  tidobj201015 Sup;
NimStringDesc* S;
tident201021* Next;
NI H;
};
struct  tpasscontext287005  {
  TNimObject Sup;
NIM_BOOL Fromcache;
};
struct  intset223056  {
NI Counter;
NI Max;
ttrunk223052* Head;
ttrunkseq223054* Data;
};
struct  tlinkedlist129028  {
tlistentry129022* Head;
tlistentry129022* Tail;
NI Counter;
};
struct  tidpair226860  {
tidobj201015* Key;
TNimObject* Val;
};
struct  tidtable226864  {
NI Counter;
tidpairseq226862* Data;
};
typedef N_NIMCALL_PTR(tnode226816*, TY291064) (tcontext291021* c, tnode226816* n);
typedef N_NIMCALL_PTR(tnode226816*, TY291069) (tcontext291021* c, tnode226816* n, NU16 flags);
typedef N_NIMCALL_PTR(tnode226816*, TY291077) (tcontext291021* c, tnode226816* n, NU16 flags);
typedef N_NIMCALL_PTR(tnode226816*, TY291085) (tcontext291021* c, tnode226816* n);
typedef N_NIMCALL_PTR(tnode226816*, TY291090) (tcontext291021* c, tnode226816* n, NU16 flags);
typedef N_NIMCALL_PTR(tnode226816*, TY291098) (tcontext291021* c, tnode226816* n);
typedef N_NIMCALL_PTR(tnode226816*, TY291103) (tcontext291021* c, tnode226816* n, tnode226816* norig, NU32 filter);
typedef N_NIMCALL_PTR(ttype226852*, TY291110) (tcontext291021* c, tnode226816* n, ttype226852* prev);
typedef struct {
N_NIMCALL_PTR(tnode226816*, ClPrc) (tcontext291021* c, tidtable226864 pt, tnode226816* n, void* ClEnv);
void* ClEnv;
} TY291116;
typedef struct {
N_NIMCALL_PTR(tsym226846*, ClPrc) (tcontext291021* c, tsym226846* fn, tidtable226864 pt, tlineinfo196539 info, void* ClEnv);
void* ClEnv;
} TY291122;
struct  tinstantiationpair291013  {
tsym226846* Genericsym;
tinstantiation226836* Inst;
};
typedef N_NIMCALL_PTR(tsym226846*, TY291138) (tcontext291021* c, tsym226846* dc, ttype226852* t, tlineinfo196539 info);
struct  tcontext291021  {
  tpasscontext287005 Sup;
tsym226846* Module;
tscope226840* Currentscope;
tscope226840* Importtable;
tscope226840* Toplevelscope;
tproccon291011* P;
tsymseq226818* Friendmodules;
NI Instcounter;
intset223056 Ambiguoussymbols;
NI Intypeclass;
NI Ingenericcontext;
NI Inunrolledcontext;
NI Incompilescontext;
NI Ingenericinst;
tsymseq226818* Converters;
tsymseq226818* Patterns;
tlinkedlist129028 Optionstack;
tidtable226864 Symmapping;
tlinkedlist129028 Libs;
TY291064 Semconstexpr;
TY291069 Semexpr;
TY291077 Semtryexpr;
TY291085 Semtryconstexpr;
TY291090 Semoperand;
TY291098 Semconstboolexpr;
TY291103 Semoverloadedcall;
TY291110 Semtypenode;
TY291116 Seminferredlambda;
TY291122 Semgenerateinstance;
intset223056 Includedfiles;
tstrtable226820 Userpragmas;
tctx290048* Evalcontext;
intset223056 Unknownidents;
TY291133* Generics;
NI Lastgenericidx;
NI Hloloopdetector;
NI Inparallelstmt;
TY291138 Instdeepcopy;
};
struct  tnode226816  {
ttype226852* Typ;
tlineinfo196539 Info;
NU16 Flags;
NU8 Kind;
union {
struct {NI64 Intval;
} S1;
struct {NF Floatval;
} S2;
struct {NimStringDesc* Strval;
} S3;
struct {tsym226846* Sym;
} S4;
struct {tident201021* Ident;
} S5;
struct {tnodeseq226810* Sons;
} S6;
} kindU;
NimStringDesc* Comment;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  tinstantiation226836  {
tsym226846* Sym;
ttypeseq226848* Concretetypes;
TY226936* Usedby;
};
struct  trope178009  {
  TNimObject Sup;
trope178009* Left;
trope178009* Right;
NI Length;
NimStringDesc* Data;
};
struct  tlistentry129022  {
  TNimObject Sup;
tlistentry129022* Prev;
tlistentry129022* Next;
};
struct  tlib226834  {
  tlistentry129022 Sup;
NU8 Kind;
NIM_BOOL Generated;
NIM_BOOL Isoverriden;
trope178009* Name;
tnode226816* Path;
};
struct  tproccon291011  {
tsym226846* Owner;
tsym226846* Resultsym;
NI Nestedloopcounter;
NI Nestedblockcounter;
NI Intrystmt;
tproccon291011* Next;
};
typedef NI TY26220[8];
struct  ttrunk223052  {
ttrunk223052* Next;
NI Key;
TY26220 Bits;
};
struct  vmargs290042  {
NI Ra;
NI Rb;
NI Rc;
void* Slots;
tnode226816* Currentexception;
};
typedef struct {
N_NIMCALL_PTR(void, ClPrc) (vmargs290042* args, void* ClEnv);
void* ClEnv;
} vmcallback290044;
struct TY290270 {
NimStringDesc* Field0;
vmcallback290044 Field1;
};
struct  tctx290048  {
  tpasscontext287005 Sup;
TY290250* Code;
TY197414* Debug;
tnode226816* Globals;
tnode226816* Constants;
ttypeseq226848* Types;
tnode226816* Currentexceptiona;
tnode226816* Currentexceptionb;
NI Exceptioninstr;
pprocHEX3Aobjecttype290230* Prc;
tsym226846* Module;
tnode226816* Callsite;
NU8 Mode;
NU8 Features;
NIM_BOOL Traceactive;
NI Loopiterations;
tlineinfo196539 Comesfromheuristic;
TY290269* Callbacks;
NimStringDesc* Errorflag;
};
struct  tblock290030  {
tsym226846* Label;
TY290211* Fixups;
};
struct TY290237 {
NIM_BOOL Field0;
NU8 Field1;
};
typedef TY290237 TY290234[256];
struct  pprocHEX3Aobjecttype290230  {
TY290231* Blocks;
tsym226846* Sym;
TY290234 Slots;
NI Maxslots;
};
struct tsymseq226818 {
  TGenericSeq Sup;
  tsym226846* data[SEQ_DECL_SIZE];
};
struct tnodeseq226810 {
  TGenericSeq Sup;
  tnode226816* data[SEQ_DECL_SIZE];
};
struct ttypeseq226848 {
  TGenericSeq Sup;
  ttype226852* data[SEQ_DECL_SIZE];
};
struct TY226947 {
  TGenericSeq Sup;
  tinstantiation226836* data[SEQ_DECL_SIZE];
};
struct ttrunkseq223054 {
  TGenericSeq Sup;
  ttrunk223052* data[SEQ_DECL_SIZE];
};
struct tidpairseq226862 {
  TGenericSeq Sup;
  tidpair226860 data[SEQ_DECL_SIZE];
};
struct TY291133 {
  TGenericSeq Sup;
  tinstantiationpair291013 data[SEQ_DECL_SIZE];
};
struct TY226936 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
struct TY290250 {
  TGenericSeq Sup;
  NU32 data[SEQ_DECL_SIZE];
};
struct TY197414 {
  TGenericSeq Sup;
  tlineinfo196539 data[SEQ_DECL_SIZE];
};
struct TY290269 {
  TGenericSeq Sup;
  TY290270 data[SEQ_DECL_SIZE];
};
struct TY290211 {
  TGenericSeq Sup;
  NI data[SEQ_DECL_SIZE];
};
struct TY290231 {
  TGenericSeq Sup;
  tblock290030 data[SEQ_DECL_SIZE];
};
N_NIMCALL(tsym226846*, searchforprocnew_310328)(tcontext291021* c, tscope226840* scope, tsym226846* fn);
N_NIMCALL(tsym226846*, initidentiter_236147)(tidentiter236141* ti, tstrtable226820 tab, tident201021* s);
N_NIMCALL(NIM_BOOL, sametype_269351)(ttype226852* a, ttype226852* b, NU8 flags);
N_NIMCALL(NU8, equalparams_264085)(tnode226816* a, tnode226816* b);
N_NIMCALL(NimStringDesc*, nsuFormatOpenArray)(NimStringDesc* formatstr, NimStringDesc** a, NI aLen0);
N_NIMCALL(NimStringDesc*, getprocheader_264519)(tsym226846* sym, NU8 prefer);
static N_INLINE(NimStringDesc*, tofilelinecol_198103)(tlineinfo196539 info);
N_NIMCALL(NimStringDesc*, tofilename_198025)(NI32 fileidx);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(void, localerror_198955)(tlineinfo196539 info, NU16 msg, NimStringDesc* arg);
N_NIMCALL(tsym226846*, nextidentiter_236156)(tidentiter236141* ti, tstrtable226820 tab);
STRING_LITERAL(TMP3040, "public implementation \'$1\' has non-public forward declaration i"
"n $2", 67);
STRING_LITERAL(TMP3041, "(", 1);
STRING_LITERAL(TMP3042, ",", 1);
STRING_LITERAL(TMP3043, ")", 1);

static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	memcpy(((NCSTRING) ((&(*dest).data[((*dest).Sup.len)- 0]))), ((NCSTRING) ((*src).data)), (NI64)((*src).Sup.len + 1));
	(*dest).Sup.len += (*src).Sup.len;
}

static N_INLINE(NimStringDesc*, tofilelinecol_198103)(tlineinfo196539 info) {
	NimStringDesc* result;
	NimStringDesc* LOC1;
	NimStringDesc* LOC2;
	NimStringDesc* LOC3;
	NimStringDesc* LOC4;
	result = 0;
	LOC1 = 0;
	LOC2 = 0;
	LOC2 = tofilename_198025(info.Fileindex);
	LOC3 = 0;
	LOC3 = nimIntToStr(((NI) (info.Line)));
	LOC4 = 0;
	LOC4 = nimIntToStr(((NI) (info.Col)));
	LOC1 = rawNewString(LOC2->Sup.len + LOC3->Sup.len + LOC4->Sup.len + 3);
appendString(LOC1, LOC2);
appendString(LOC1, ((NimStringDesc*) &TMP3041));
appendString(LOC1, LOC3);
appendString(LOC1, ((NimStringDesc*) &TMP3042));
appendString(LOC1, LOC4);
appendString(LOC1, ((NimStringDesc*) &TMP3043));
	result = LOC1;
	return result;
}

N_NIMCALL(tsym226846*, searchforprocnew_310328)(tcontext291021* c, tscope226840* scope, tsym226846* fn) {
	tsym226846* result;
	tidentiter236141 it;
	result = 0;
	memset((void*)(&it), 0, sizeof(it));
	result = initidentiter_236147((&it), (*scope).Symbols, (*fn).Name);
	{
		while (1) {
			if (!!((result == NIM_NIL))) goto LA2;
			{
				NIM_BOOL LOC5;
				NU8 LOC9;
				LOC5 = 0;
				LOC5 = ((520192 &(1<<(((*result).Kind)&31)))!=0);
				if (!(LOC5)) goto LA6;
				LOC5 = sametype_269351((*result).Typ, (*fn).Typ, 30);
				LA6: ;
				if (!LOC5) goto LA7;
				LOC9 = 0;
				LOC9 = equalparams_264085((*(*result).Typ).N, (*(*fn).Typ).N);
				switch (LOC9) {
				case ((NU8) 1):
				{
					{
						NIM_BOOL LOC13;
						NimStringDesc* message;
						TY170951 LOC17;
						LOC13 = 0;
						LOC13 = !((((*result).Flags &(1<<((((NU8) 1))&31)))!=0));
						if (!(LOC13)) goto LA14;
						LOC13 = (((*fn).Flags &(1<<((((NU8) 1))&31)))!=0);
						LA14: ;
						if (!LOC13) goto LA15;
						memset((void*)LOC17, 0, sizeof(LOC17));
						LOC17[0] = getprocheader_264519(result, ((NU8) 0));
						LOC17[1] = tofilelinecol_198103((*result).Info);
						message = nsuFormatOpenArray(((NimStringDesc*) &TMP3040), LOC17, 2);
						localerror_198955((*fn).Info, ((NU16) 4), message);
					}
					LA15: ;
					goto BeforeRet;
				}
				break;
				case ((NU8) 2):
				{
					localerror_198955((*fn).Info, ((NU16) 66), (*(*fn).Name).S);
					goto BeforeRet;
				}
				break;
				case ((NU8) 0):
				{
				}
				break;
				}
			}
			LA7: ;
			result = nextidentiter_236156((&it), (*scope).Symbols);
		} LA2: ;
	}
	result = NIM_NIL;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(tsym226846*, searchforproc_310414)(tcontext291021* c, tscope226840* scope, tsym226846* fn) {
	tsym226846* result;
	result = 0;
	result = searchforprocnew_310328(c, scope, fn);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, HEX00_procfindInit)(void) {
}

NIM_EXTERNC N_NOINLINE(void, HEX00_procfindDatInit)(void) {
}

