Skip to content

Instantly share code, notes, and snippets.

@zielmicha
Created July 9, 2015 22:40
Show Gist options
  • Save zielmicha/9a72ab049820a154d4e3 to your computer and use it in GitHub Desktop.
Save zielmicha/9a72ab049820a154d4e3 to your computer and use it in GitHub Desktop.
Bad code generated for a.nim
/* Generated by Nim Compiler v0.11.3 */
/* (c) 2015 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Linux, amd64, gcc */
/* Command for C compiler:
gcc -c -w -I/home/michal/apps/nim/lib -o /home/michal/apps/bug/nimcache/a.o /home/michal/apps/bug/nimcache/a.c */
#define NIM_INTBITS 64
#include "nimbase.h"
typedef struct DbusfoobarHEX3Aobjecttype91012 DbusfoobarHEX3Aobjecttype91012;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
struct DbusfoobarHEX3Aobjecttype91012 {
NU8 kind;
union{
struct {NI foo;
} S1;
struct {NI bar;
} S2;
} kindU;
};
typedef N_NIMCALL_PTR(void, TY3289) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3294) (void* p);
struct TNimType {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3289 marker;
TY3294 deepcopy;
};
struct TNimNode {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
N_NIMCALL(void, FieldDiscriminantCheck)(NI olddiscval, NI newdiscval, TNimNode** a, NI L);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_NOINLINE(void, setStackBottom)(void* thestackbottom);
static N_INLINE(void, nimFrame)(TFrame* s);
N_NOINLINE(void, stackoverflow_21801)(void);
static N_INLINE(void, popFrame)(void);
NIM_EXTERNC N_NOINLINE(void, systemInit)(void);
NIM_EXTERNC N_NOINLINE(void, systemDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, aInit)(void);
NIM_EXTERNC N_NOINLINE(void, aDatInit)(void);
TNimNode* NimDT_91012_kind[28];
DbusfoobarHEX3Aobjecttype91012* foobar_91020;
TNimType NTI91012; /* DbusFoobar:ObjectType */
TNimType NTI91004; /* DbusTypeChar */
extern TNimType NTI108; /* int */
extern TNimNode* NimDT_91012_kind[28];
extern TFrame* frameptr_19042;
static N_INLINE(void, initStackBottomWith)(void* locals) {
setStackBottom(locals);
}
void PreMainInner() {
systemInit();
aDatInit();
}
void PreMain() {
void (*volatile inner)();
systemDatInit();
inner = PreMainInner;
initStackBottomWith((void *)&inner);
(*inner)();
}
int cmdCount;
char** cmdLine;
char** gEnv;
N_CDECL(void, NimMainInner)(void) {
aInit();
}
N_CDECL(void, NimMain)(void) {
void (*volatile inner)();
PreMain();
inner = NimMainInner;
initStackBottomWith((void *)&inner);
(*inner)();
}
int main(int argc, char** args, char** env) {
cmdLine = args;
cmdCount = argc;
gEnv = env;
NimMain();
return nim_program_result;
}
static N_INLINE(void, nimFrame)(TFrame* s) {
NI LOC1;
LOC1 = 0;
{
if (!(frameptr_19042 == NIM_NIL)) goto LA4;
LOC1 = ((NI) 0);
}
goto LA2;
LA4: ;
{
LOC1 = ((NI) ((NI16)((*frameptr_19042).calldepth + ((NI16) 1))));
}
LA2: ;
(*s).calldepth = ((NI16) (LOC1));
(*s).prev = frameptr_19042;
frameptr_19042 = s;
{
if (!((*s).calldepth == ((NI16) 2000))) goto LA9;
stackoverflow_21801();
}
LA9: ;
}
static N_INLINE(void, popFrame)(void) {
frameptr_19042 = (*frameptr_19042).prev;
}
NIM_EXTERNC N_NOINLINE(void, aInit)(void) {
NU8 LOC1;
nimfr("a", "a.nim")
nimln(14, "a.nim");
LOC1 = 0;
LOC1 = ((NU8) 123);
FieldDiscriminantCheck((NI)(NU)((*foobar_91020).kind), (NI)(NU)(LOC1), NimDT_91012_kind, 28);
(*foobar_91020).kind = LOC1;
popFrame();
}
NIM_EXTERNC N_NOINLINE(void, aDatInit)(void) {
static TNimNode* TMP139[2];
NI TMP141;
static char* NIM_CONST TMP140[2] = {
"dtArray",
"dtDict"};
static TNimNode TMP137[6];
NTI91012.size = sizeof(DbusfoobarHEX3Aobjecttype91012);
NTI91012.kind = 18;
NTI91012.base = 0;
NTI91012.flags = 3;
NTI91004.size = sizeof(NU8);
NTI91004.kind = 14;
NTI91004.base = 0;
NTI91004.flags = 3;
for (TMP141 = 0; TMP141 < 2; TMP141++) {
TMP137[TMP141+1].kind = 1;
TMP137[TMP141+1].offset = TMP141;
TMP137[TMP141+1].name = TMP140[TMP141];
TMP139[TMP141] = &TMP137[TMP141+1];
}
TMP137[1].offset = 97;
TMP137[2].offset = 123;
TMP137[3].len = 2; TMP137[3].kind = 2; TMP137[3].sons = &TMP139[0];
NTI91004.node = &TMP137[3];
NTI91004.flags = 1<<2;
TMP137[0].kind = 3;
TMP137[0].offset = offsetof(DbusfoobarHEX3Aobjecttype91012, kind);
TMP137[0].typ = (&NTI91004);
TMP137[0].name = "kind";
TMP137[0].sons = &NimDT_91012_kind[0];
TMP137[0].len = 27;
TMP137[4].kind = 1;
TMP137[4].offset = offsetof(DbusfoobarHEX3Aobjecttype91012, kindU.S1.foo);
TMP137[4].typ = (&NTI108);
TMP137[4].name = "foo";
NimDT_91012_kind[123] = &TMP137[4];
TMP137[5].kind = 1;
TMP137[5].offset = offsetof(DbusfoobarHEX3Aobjecttype91012, kindU.S2.bar);
TMP137[5].typ = (&NTI108);
TMP137[5].name = "bar";
NimDT_91012_kind[27] = &TMP137[5];
NTI91012.node = &TMP137[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment