diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2018-12-30 14:03:05 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2018-12-30 14:03:05 +0100 |
commit | 41193613bdfd1dfba58a8153ae3c29711829e7d6 (patch) | |
tree | 8a1454428efee91ac54e22c82914cab6dfa20b7e /minie | |
parent | b6b969f02fc9f1bd242f1bbb6a91b637422a67b3 (diff) | |
download | compilertests-41193613bdfd1dfba58a8153ae3c29711829e7d6.tar.gz compilertests-41193613bdfd1dfba58a8153ae3c29711829e7d6.tar.bz2 |
fixed typeName to use proper type conversion functions
Diffstat (limited to 'minie')
-rw-r--r-- | minie/e2c.c | 34 | ||||
-rw-r--r-- | minie/sync_backup.sh | 8 |
2 files changed, 26 insertions, 16 deletions
diff --git a/minie/e2c.c b/minie/e2c.c index 9a26729..b98c253 100644 --- a/minie/e2c.c +++ b/minie/e2c.c @@ -508,9 +508,7 @@ typedef enum { TYPE_ARRAY, TYPE_RECORD, TYPE_FUNCTION, - TYPE_CONSTANT, - TYPE_NONE, - TYPE_ANY + TYPE_CONSTANT } BasicType; static BasicType strToBasicType( char *name ) @@ -606,8 +604,10 @@ static char *basicTypeToCType( BasicType type ) case TYPE_INTEGER: return "signed int"; case TYPE_BOOLEAN: + /* C89, no bool */ return "unsigned char"; case TYPE_CHAR: + /* TODO: Unicode, for now ASCII */ return "unsigned char"; case TYPE_BYTE: return "unsigned char"; @@ -648,7 +648,6 @@ static int length( char *name ) static char moduleName[MAX_IDENT_LEN+1]; static char varName[MAX_IDENT_LEN+1]; static Type lastType; -static char typeName[MAX_IDENT_LEN+1]; static char procName[MAX_IDENT_LEN+1]; static void Expect( Symbol expect ) @@ -1110,22 +1109,15 @@ static void simpleType( void ) type table */ if( strcmp( ident, "integer" ) == 0 ) { lastType.type = TYPE_INTEGER; - strcpy( typeName, "signed int" ); sym = getSym( ); } else if( strcmp( ident, "boolean" ) == 0 ) { lastType.type = TYPE_BOOLEAN; - /* C89, no bool */ - strcpy( typeName, "unsigned char" ); sym = getSym( ); } else if( strcmp( ident, "char" ) == 0 ) { lastType.type = TYPE_CHAR; - /* TODO: Unicode, for now ASCII */ - strcpy( typeName, "unsigned char" ); sym = getSym( ); } else if( strcmp( ident, "byte" ) == 0 ) { lastType.type = TYPE_BYTE; - /* C89, no bool */ - strcpy( typeName, "unsigned char" ); sym = getSym( ); } else { Abort( "Unknown type '%s'", ident ); @@ -1175,9 +1167,16 @@ static void variableDeclaration( void ) type( ); insert_symbol( lastType, varName ); if( lastType.type == TYPE_ARRAY ) { - emitLn( "static %s %s[%d];", typeName, varName, num ); + /* TODO: this works for now, though it's not correct */ + emitLn( "static %s %s[%d];", + basicTypeToCType( lastType.details.array.type->type ), + varName, num ); +/* emitLn( "static %s %s[%d];", typeName, varName, num );*/ } else { - emitLn( "static %s %s;", typeName, varName ); + emitLn( "static %s %s;", + basicTypeToCType( lastType.type ), + varName ); +/* emitLn( "static %s %s;", typeName, varName ); */ } } @@ -1247,9 +1246,12 @@ static void procedureDeclaration( void ) if( sym == S_colon ) { sym = getSym( ); type( ); - /* TODO: use proper type, not type string */ - strncpy( return_type, typeName, MAX_IDENT_LEN ); - return_type[MAX_IDENT_LEN-1] = '\0'; + /* TODO: handle more than just simple types here, or + * do we only have VAR parameters vor complex types + * because we run into allocation issues otherwise? */ + strncpy( return_type, + basicTypeToCType( lastType.type ), + MAX_IDENT_LEN ); } else { strncpy( return_type, "void", MAX_IDENT_LEN ); } diff --git a/minie/sync_backup.sh b/minie/sync_backup.sh new file mode 100644 index 0000000..acf0703 --- /dev/null +++ b/minie/sync_backup.sh @@ -0,0 +1,8 @@ +/bin/sh + +rsync -e 'ssh' -av \ + --usermap=abaumann:http \ + --groupmap=abaumann:http \ + --delete-after \ + --exclude '*~' \ + public/. root@eurobuild3:/srv/http/www.andreasbaumann.cc/. |