Removed 2 lingering TRUE/FALSE references

Removed 2 calls to cCode.appendDecl in walkCondExpr, replaced with
ostringstream usage + 1 call to cCode.appendDecl
Created Type helper class = TypeContainer
This commit is contained in:
Artur K
2012-03-13 00:35:32 +01:00
parent 14b06c252e
commit fe250a822d
4 changed files with 57 additions and 31 deletions

View File

@@ -11,7 +11,7 @@
#include <list>
#include <set>
#include <algorithm>
#include "types.h"
#include "Enums.h"
#include "machine_x86.h"
@@ -28,12 +28,6 @@ struct IDX_ARRAY : public std::vector<iICODE>
}
};
static constexpr const char * hlTypes[13] = {
"", "char", "unsigned char", "int", "unsigned int",
"long", "unsigned long", "record", "int *", "char *",
"", "float", "double"
};
typedef enum
{
STK_FRAME, /* For stack vars */
@@ -97,14 +91,13 @@ struct ID
bool isSigned() const { return (type==TYPE_BYTE_SIGN)||(type==TYPE_WORD_SIGN)||(type==TYPE_LONG_SIGN);}
uint16_t typeBitsize() const
{
switch(type)
{
case TYPE_WORD_SIGN: case TYPE_WORD_UNSIGN:
return 16;
case TYPE_BYTE_SIGN: case TYPE_BYTE_UNSIGN:
return 8;
}
return ~0;
return TypeContainer::typeSize(type)*8;
}
void setLocalName(int i)
{
// char buf[32];
//sprintf (buf, "loc%ld", i);
//name=buf;
}
};

View File

@@ -3,9 +3,10 @@
* (C) Cristina Cifuentes, Mike van Emmerik
****************************************************************************/
#pragma once
#include <cassert>
#include <stdint.h>
#include "Enums.h"
/**** Common definitions and macros ****/
typedef unsigned int uint32_t; /* 32 bits */
#define MAX 0x7FFFFFFF
/* Type definitions used in the program */
@@ -14,14 +15,6 @@ typedef unsigned short word;/* 16 bits */
typedef short int16; /* 16 bits */
typedef unsigned char boolT; /* 8 bits */
#if defined(__MSDOS__) | defined(WIN32)
#define unlink _unlink // Compiler is picky about non Ansi names
#endif
#define TRUE 1
#define FALSE 0
#define SYNTHESIZED_MIN 0x100000 /* Synthesized labs use bits 21..32 */
/* These are for C library signature detection */
@@ -73,3 +66,41 @@ struct eDuVal
}
bool isUSE_VAL() {return use&&val;} /* Use and Val */
};
static constexpr const char * hlTypes[13] = {
"", "char", "unsigned char", "int", "unsigned int",
"long", "unsigned long", "record", "int *", "char *",
"", "float", "double"
};
struct TypeContainer
{
hlType m_type;
size_t m_size;
TypeContainer(hlType t,size_t sz) : m_type(t),m_size(sz)
{
}
static size_t typeSize(hlType t)
{
switch(t)
{
case TYPE_WORD_SIGN: case TYPE_WORD_UNSIGN:
return 2;
case TYPE_BYTE_SIGN: case TYPE_BYTE_UNSIGN:
return 1;
}
return 0;
}
static hlType defaultTypeForSize(size_t x)
{
/* Type of the symbol according to the number of bytes it uses */
static hlType cbType[] = {TYPE_UNKNOWN, TYPE_BYTE_UNSIGN, TYPE_WORD_SIGN,
TYPE_UNKNOWN, TYPE_LONG_SIGN};
assert(x < sizeof(cbType)/sizeof(hlType));
return cbType[x];
}
static constexpr const char *typeName(hlType t)
{
return hlTypes[t];
}
};