- 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;
- constant = (const const_t*) expression;
- if(is_type_integer(expression->datatype)) {
- fprintf(out, "%d", constant->v.int_value);
+ constant = &expression->conste;
+ if(is_type_integer(expression->base.type)) {
+ fprintf(out, "%lld", constant->v.int_value);
static void write_enum(const symbol_t *symbol, const enum_type_t *type)
{
fprintf(out, "enum %s:\n", symbol->string);
static void write_enum(const symbol_t *symbol, const enum_type_t *type)
{
fprintf(out, "enum %s:\n", symbol->string);
for ( ; entry != NULL && entry->storage_class == STORAGE_CLASS_ENUM_ENTRY;
entry = entry->next) {
fprintf(out, "\t%s", entry->symbol->string);
if(entry->init.initializer != NULL) {
fprintf(out, " <- ");
for ( ; entry != NULL && entry->storage_class == STORAGE_CLASS_ENUM_ENTRY;
entry = entry->next) {
fprintf(out, "\t%s", entry->symbol->string);
if(entry->init.initializer != NULL) {
fprintf(out, " <- ");
fprintf(out, "func extern %s(",
declaration->symbol->string);
fprintf(out, "func extern %s(",
declaration->symbol->string);
- const type_t *result_type = method_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);
if(declaration->storage_class == STORAGE_CLASS_TYPEDEF
|| declaration->storage_class == STORAGE_CLASS_ENUM_ENTRY)
continue;
type_t *type = declaration->type;
if(declaration->storage_class == STORAGE_CLASS_TYPEDEF
|| declaration->storage_class == STORAGE_CLASS_ENUM_ENTRY)
continue;
type_t *type = declaration->type;
if(declaration->storage_class == STORAGE_CLASS_TYPEDEF
|| declaration->storage_class == STORAGE_CLASS_ENUM_ENTRY)
continue;
type_t *type = declaration->type;
if(declaration->storage_class == STORAGE_CLASS_TYPEDEF
|| declaration->storage_class == STORAGE_CLASS_ENUM_ENTRY)
continue;
type_t *type = declaration->type;