Skip to content

Instantly share code, notes, and snippets.

@Parashurama
Created May 25, 2016 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Parashurama/faac3c179b2efc4733d0583d32a5d026 to your computer and use it in GitHub Desktop.
Save Parashurama/faac3c179b2efc4733d0583d32a5d026 to your computer and use it in GitHub Desktop.
simplified tcc_debug0.c even further.
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
typedef struct TFrame TFrame;
struct TFrame {
TFrame* prev;
char *procname;
int64_t line;
char *filename;
int16_t len;
int16_t calldepth;
};
typedef struct anontuple {
uint8_t Field0;
} anontuple;
TFrame *frameptr = NULL;
void nimFrame(TFrame *s) {
s->calldepth = (!frameptr) ? 0 : frameptr->calldepth+1;
s->prev = frameptr;
frameptr = s;
if (s->calldepth == 2000) {
printf("stackoverfloaw!");
exit(1);
}
}
static void popFrame(void) {
frameptr = (*frameptr).prev;
}
static anontuple split() {
TFrame FR;
nimFrame(&FR);
anontuple result0 = {0};
popFrame();
return result0;
}
static anontuple f4() {
TFrame FR;
nimFrame(&FR);
anontuple result0;
result0 = split();
popFrame();
return result0;
}
static anontuple f3() {
TFrame FR;
nimFrame(&FR);
anontuple result0;
result0 = f4();
popFrame();
return result0;
}
void main() {
anontuple temp = f3();
printf("%x, %x\n", temp.Field0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment