- case ATOMIC_TYPE_VOID: return "void";
- case ATOMIC_TYPE_CHAR: return "byte";
- case ATOMIC_TYPE_SCHAR: return "byte";
- case ATOMIC_TYPE_UCHAR: return "unsigned byte";
- case ATOMIC_TYPE_SHORT: return "short";
- case ATOMIC_TYPE_USHORT: return "unsigned short";
- case ATOMIC_TYPE_INT: return "int";
- case ATOMIC_TYPE_UINT: return "unsigned int";
- case ATOMIC_TYPE_LONG: return "int";
- case ATOMIC_TYPE_ULONG: return "unsigned int";
- case ATOMIC_TYPE_LONGLONG: return "long";
- case ATOMIC_TYPE_ULONGLONG: return "unsigned long";
- case ATOMIC_TYPE_FLOAT: return "float";
- case ATOMIC_TYPE_DOUBLE: return "double";
+ case ATOMIC_TYPE_VOID: return "void";
+ case ATOMIC_TYPE_CHAR: return "byte";
+ case ATOMIC_TYPE_SCHAR: return "byte";
+ case ATOMIC_TYPE_UCHAR: return "unsigned byte";
+ case ATOMIC_TYPE_SHORT: return "short";
+ case ATOMIC_TYPE_USHORT: return "unsigned short";
+ case ATOMIC_TYPE_INT: return "int";
+ case ATOMIC_TYPE_UINT: return "unsigned int";
+ case ATOMIC_TYPE_LONG: return "int";
+ case ATOMIC_TYPE_ULONG: return "unsigned int";
+ case ATOMIC_TYPE_LONGLONG: return "long";
+ case ATOMIC_TYPE_ULONGLONG: return "unsigned long";
+ case ATOMIC_TYPE_FLOAT: return "float";
+ case ATOMIC_TYPE_DOUBLE: return "double";
static declaration_t *find_typedef(const type_t *type)
{
/* first: search for a matching typedef in the global type... */
static declaration_t *find_typedef(const type_t *type)
{
/* first: search for a matching typedef in the global type... */
while(declaration != NULL) {
if(! (declaration->storage_class == STORAGE_CLASS_TYPEDEF)) {
declaration = declaration->next;
while(declaration != NULL) {
if(! (declaration->storage_class == STORAGE_CLASS_TYPEDEF)) {
declaration = declaration->next;
while(declaration != NULL) {
write_struct_entry(declaration);
declaration = declaration->next;
while(declaration != NULL) {
write_struct_entry(declaration);
declaration = declaration->next;
while(declaration != NULL) {
write_struct_entry(declaration);
declaration = declaration->next;
while(declaration != NULL) {
write_struct_entry(declaration);
declaration = declaration->next;
fprintf(out, "%lld", constant->v.int_value);
} else {
fprintf(out, "%Lf", constant->v.float_value);
}
break;
fprintf(out, "%lld", constant->v.int_value);
} else {
fprintf(out, "%Lf", constant->v.float_value);
}
break;
- const type_t *result_type = function_type->result_type;
- if(result_type->type != TYPE_ATOMIC ||
- ((const atomic_type_t*) result_type)->atype != ATOMIC_TYPE_VOID) {
+ const type_t *return_type = function_type->return_type;
+ if(!is_type_atomic(return_type, ATOMIC_TYPE_VOID)) {
-#if 0
- out = fopen("out.fluffy", "w");
- if(out == NULL) {
- fprintf(stderr, "Couldn't open out.fluffy: %s\n", strerror(errno));
- exit(1);
- }
-#endif
- out = stdout;
- global_context = &unit->context;
+ out = output;
+ global_scope = &unit->scope;
fprintf(out, "/* WARNING: Automatically generated file */\n");
/* write structs,unions + enums */
fprintf(out, "/* WARNING: Automatically generated file */\n");
/* write structs,unions + enums */
for( ; declaration != NULL; declaration = declaration->next) {
//fprintf(out, "// Decl: %s\n", declaration->symbol->string);
if(! (declaration->storage_class == STORAGE_CLASS_TYPEDEF)) {
continue;
}
type_t *type = declaration->type;
for( ; declaration != NULL; declaration = declaration->next) {
//fprintf(out, "// Decl: %s\n", declaration->symbol->string);
if(! (declaration->storage_class == STORAGE_CLASS_TYPEDEF)) {
continue;
}
type_t *type = declaration->type;
- if(type->type == TYPE_COMPOUND_STRUCT) {
- write_struct(declaration->symbol, (compound_type_t*) type);
- } else if(type->type == TYPE_COMPOUND_UNION) {
- write_union(declaration->symbol, (compound_type_t*) type);
- } else if(type->type == TYPE_ENUM) {
- write_enum(declaration->symbol, (enum_type_t*) type);
+ if(type->kind == TYPE_COMPOUND_STRUCT) {
+ write_struct(declaration->symbol, &type->compound);
+ } else if(type->kind == TYPE_COMPOUND_UNION) {
+ write_union(declaration->symbol, &type->compound);
+ } else if(type->kind == TYPE_ENUM) {
+ write_enum(declaration->symbol, &type->enumt);
for( ; declaration != NULL; declaration = declaration->next) {
if(declaration->namespc != NAMESPACE_NORMAL)
continue;
for( ; declaration != NULL; declaration = declaration->next) {
if(declaration->namespc != NAMESPACE_NORMAL)
continue;
for( ; declaration != NULL; declaration = declaration->next) {
if(declaration->namespc != NAMESPACE_NORMAL)
continue;
for( ; declaration != NULL; declaration = declaration->next) {
if(declaration->namespc != NAMESPACE_NORMAL)
continue;