summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-12-29 12:10:44 -0500
committerAdrian Thurston <thurston@complang.org>2012-12-29 12:10:44 -0500
commit36103e2f45d5212ba4e7c964051747259e130d00 (patch)
tree33c2059ea1cdc84dcac1fcef563374ce3a4e0308
parentef06860fcad0cf52dae7272f2866eafbed8e37b7 (diff)
downloadcolm-36103e2f45d5212ba4e7c964051747259e130d00.tar.gz
more simplification: removed isSigned from keyOps and host type
-rw-r--r--colm/fsmcodegen.cc37
-rw-r--r--colm/keyops.h49
-rw-r--r--colm/main.cc2
3 files changed, 6 insertions, 82 deletions
diff --git a/colm/fsmcodegen.cc b/colm/fsmcodegen.cc
index 7843fab8..e05f3a22 100644
--- a/colm/fsmcodegen.cc
+++ b/colm/fsmcodegen.cc
@@ -52,29 +52,6 @@ FsmCodeGen::FsmCodeGen( const char *sourceFileName, const char *fsmName, ostream
{
}
-unsigned int FsmCodeGen::arrayTypeSize( unsigned long maxVal )
-{
- long long maxValLL = (long long) maxVal;
- HostType *arrayType = keyOps->typeSubsumes( maxValLL );
- assert( arrayType != 0 );
- return arrayType->size;
-}
-
-string FsmCodeGen::ARRAY_TYPE( unsigned long maxVal )
-{
- long long maxValLL = (long long) maxVal;
- HostType *arrayType = keyOps->typeSubsumes( maxValLL );
- assert( arrayType != 0 );
-
- string ret = arrayType->data1;
- if ( arrayType->data2 != 0 ) {
- ret += " ";
- ret += arrayType->data2;
- }
- return ret;
-}
-
-
/* Write out the fsm name. */
string FsmCodeGen::FSM_NAME()
{
@@ -362,19 +339,7 @@ string FsmCodeGen::ALPH_TYPE()
string FsmCodeGen::WIDE_ALPH_TYPE()
{
string ret;
- if ( redFsm->maxKey <= keyOps->maxKey )
- ret = ALPH_TYPE();
- else {
- long long maxKeyVal = redFsm->maxKey.getLongLong();
- HostType *wideType = keyOps->typeSubsumes( true, maxKeyVal );
- assert( wideType != 0 );
-
- ret = wideType->data1;
- if ( wideType->data2 != 0 ) {
- ret += " ";
- ret += wideType->data2;
- }
- }
+ ret = ALPH_TYPE();
return ret;
}
diff --git a/colm/keyops.h b/colm/keyops.h
index c9a405e9..de0e0c06 100644
--- a/colm/keyops.h
+++ b/colm/keyops.h
@@ -90,7 +90,6 @@ struct HostType
{
const char *data1;
const char *data2;
- bool isSigned;
long long minVal;
long long maxVal;
unsigned int size;
@@ -122,66 +121,26 @@ extern HostLang hostLangC;
struct KeyOps
{
/* Default to signed alphabet. */
- KeyOps() :
- isSigned(true),
- alphType(0)
- {}
+ KeyOps() : alphType(0) {}
- /* Default to signed alphabet. */
- KeyOps( bool isSigned )
- :isSigned(isSigned) {}
-
- bool isSigned;
Key minKey, maxKey;
HostType *alphType;
void setAlphType( HostType *alphType )
{
this->alphType = alphType;
- isSigned = alphType->isSigned;
- if ( isSigned ) {
- minKey = (long) alphType->minVal;
- maxKey = (long) alphType->maxVal;
- }
- else {
- minKey = (long) (unsigned long) alphType->minVal;
- maxKey = (long) (unsigned long) alphType->maxVal;
- }
+ minKey = (long) alphType->minVal;
+ maxKey = (long) alphType->maxVal;
}
/* Compute the distance between two keys. */
Size span( Key key1, Key key2 )
{
- return isSigned ?
- (unsigned long long)(
- (long long)key2.key -
- (long long)key1.key + 1) :
- (unsigned long long)(
- (unsigned long)key2.key) -
- (unsigned long long)((unsigned long)key1.key) + 1;
+ return (unsigned long long)( (long long)key2.key - (long long)key1.key + 1) ;
}
Size alphSize()
{ return span( minKey, maxKey ); }
-
- HostType *typeSubsumes( long long maxVal )
- {
- for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
- if ( maxVal <= hostLang->hostTypes[i].maxVal )
- return hostLang->hostTypes + i;
- }
- return 0;
- }
-
- HostType *typeSubsumes( bool isSigned, long long maxVal )
- {
- for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
- if ( ( (isSigned && hostLang->hostTypes[i].isSigned) || !isSigned ) &&
- maxVal <= hostLang->hostTypes[i].maxVal )
- return hostLang->hostTypes + i;
- }
- return 0;
- }
};
inline bool operator<( const Key key1, const Key key2 )
diff --git a/colm/main.cc b/colm/main.cc
index 72f876ae..201de8d4 100644
--- a/colm/main.cc
+++ b/colm/main.cc
@@ -92,7 +92,7 @@ int gblErrorCount = 0;
HostType hostTypesC[] =
{
- { "char", 0, true, CHAR_MIN, CHAR_MAX, sizeof(char) },
+ { "char", 0, CHAR_MIN, CHAR_MAX, sizeof(char) },
};
HostLang hostLangC = { hostTypesC, 8, hostTypesC+0, true };