Created
November 12, 2015 19:48
-
-
Save forflo/1b2200b3cf18d81ae2fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ffi_parser.h" | |
#include "ffi_nary_tree.h" | |
#include "ffi_node_defines.h" | |
#include "ffi_generate_dot.h" | |
#include "ffi_generate_ops.h" | |
#include "ffi_storage.h" | |
#include "ffi_util.h" | |
#include <stdlib.h> | |
#include <stdio.h> | |
#define DEBUG | |
extern int ffidebug; | |
extern void ffiset_in(FILE *f, void *scan); | |
extern int ffilex_init(void *ffi); | |
extern int ffilex_destroy(void *ffi); | |
extern int ffiparse(struct nary_node **r, void *scan); | |
struct t1 { | |
char a; | |
unsigned char b; | |
short c; | |
unsigned short d; | |
int e; | |
unsigned int f; | |
long g; | |
unsigned long h; | |
long long i; | |
unsigned long long j; | |
float k; | |
double l; | |
}; | |
struct t2 { | |
char a; | |
double b; | |
struct { | |
double c; | |
int d; | |
} anon2; | |
}; | |
struct t3 { | |
char a; | |
double b; | |
struct t3baz *c; | |
}; | |
struct t3baz { | |
struct t3foo *a; | |
struct t3foo *b; | |
}; | |
struct t3foo { | |
double a; | |
char b; | |
int c; | |
}; | |
void modify_t3(struct t3 *stru){ | |
stru->a = '6'; | |
stru->b = 123.123123123; | |
stru->c->b->b = '{'; | |
} | |
int main(void){ | |
struct nary_node *root; | |
struct ffi_instruction_obj *instructions; | |
void *res; | |
ffidebug = 1; | |
void *ffi_scan; | |
ffilex_init(&ffi_scan); | |
ffiset_in(stdin, ffi_scan); | |
ffiparse(&root, ffi_scan); | |
#ifdef DEBUG | |
printf("root: %p, root->nodes[0]: %p\n", root, root->nodes[0]); | |
#endif | |
genops(&instructions, root->nodes[0]); | |
printf("\n"); | |
emit_human(instructions); | |
printf("\n"); | |
get_storage(&res, instructions); | |
printf("Storage ok!"); | |
struct t3 *t = ((struct t3 *) res); | |
printf("\nVorher t: %p\n", t); | |
printf("a: %c b: %lf c: %lf d: %c\n", t->a, t->b, t->c->a->a, t->c->a->b); | |
printf("e: %d f: %lf g: %c h: %i\n", t->c->a->c, t->c->b->a, t->c->b->b, t->c->b->c); | |
modify_t3(t); | |
printf("\nNachher t: %p\n", t); | |
printf("a: %c b: %lf c: %lf d: %c\n", t->a, t->b, t->c->a->a, t->c->a->b); | |
printf("e: %d f: %lf g: %c h: %i\n", t->c->a->c, t->c->b->a, t->c->b->b, t->c->b->c); | |
ffilex_destroy(ffi_scan); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment