common.h (ragel-6.9) | : | common.h (ragel-6.10) | ||
---|---|---|---|---|
skipping to change at line 118 | skipping to change at line 118 | |||
}; | }; | |||
struct HostType | struct HostType | |||
{ | { | |||
const char *data1; | const char *data1; | |||
const char *data2; | const char *data2; | |||
const char *internalName; | const char *internalName; | |||
bool isSigned; | bool isSigned; | |||
bool isOrd; | bool isOrd; | |||
bool isChar; | bool isChar; | |||
long long minVal; | long long sMinVal; | |||
long long maxVal; | long long sMaxVal; | |||
unsigned long long uMinVal; | ||||
unsigned long long uMaxVal; | ||||
unsigned int size; | unsigned int size; | |||
}; | }; | |||
struct HostLang | struct HostLang | |||
{ | { | |||
/* Target language. */ | /* Target language. */ | |||
enum Lang | enum Lang | |||
{ | { | |||
C, D, D2, Go, Java, Ruby, CSharp, OCaml | C, D, D2, Go, Java, Ruby, CSharp, OCaml | |||
}; | }; | |||
skipping to change at line 176 | skipping to change at line 178 | |||
bool isSigned; | bool isSigned; | |||
Key minKey, maxKey; | Key minKey, maxKey; | |||
HostType *alphType; | HostType *alphType; | |||
void setAlphType( HostType *alphType ) | void setAlphType( HostType *alphType ) | |||
{ | { | |||
this->alphType = alphType; | this->alphType = alphType; | |||
isSigned = alphType->isSigned; | isSigned = alphType->isSigned; | |||
if ( isSigned ) { | if ( isSigned ) { | |||
minKey = (long) alphType->minVal; | minKey = (long) alphType->sMinVal; | |||
maxKey = (long) alphType->maxVal; | maxKey = (long) alphType->sMaxVal; | |||
} | } | |||
else { | else { | |||
minKey = (long) (unsigned long) alphType->minVal; | minKey = (long) (unsigned long) alphType->uMinVal; | |||
maxKey = (long) (unsigned long) alphType->maxVal; | maxKey = (long) (unsigned long) alphType->uMaxVal; | |||
} | } | |||
} | } | |||
/* Compute the distance between two keys. */ | /* Compute the distance between two keys. */ | |||
Size span( Key key1, Key key2 ) | Size span( Key key1, Key key2 ) | |||
{ | { | |||
return isSigned ? | return isSigned ? | |||
(unsigned long long)( | (unsigned long long)( | |||
(long long)key2.key - | (long long)key2.key - | |||
(long long)key1.key + 1) : | (long long)key1.key + 1) : | |||
(unsigned long long)( | (unsigned long long)( | |||
(unsigned long)key2.key) - | (unsigned long)key2.key) - | |||
(unsigned long long)((unsigned long)key1.key) + 1 ; | (unsigned long long)((unsigned long)key1.key) + 1 ; | |||
} | } | |||
Size alphSize() | Size alphSize() | |||
{ return span( minKey, maxKey ); } | { return span( minKey, maxKey ); } | |||
HostType *typeSubsumes( long long maxVal ) | HostType *typeSubsumes( long long maxVal ) | |||
{ | { | |||
HostType *hostTypes = hostLang->hostTypes; | ||||
for ( int i = 0; i < hostLang->numHostTypes; i++ ) { | for ( int i = 0; i < hostLang->numHostTypes; i++ ) { | |||
if ( maxVal <= hostLang->hostTypes[i].maxVal ) | long long typeMaxVal = hostTypes[i].isSigned ? hostTypes[ | |||
return hostLang->hostTypes + i; | i].sMaxVal : hostTypes[i].uMaxVal; | |||
if ( maxVal <= typeMaxVal ) | ||||
return &hostLang->hostTypes[i]; | ||||
} | } | |||
return 0; | return 0; | |||
} | } | |||
HostType *typeSubsumes( bool isSigned, long long maxVal ) | HostType *typeSubsumes( bool isSigned, long long maxVal ) | |||
{ | { | |||
HostType *hostTypes = hostLang->hostTypes; | ||||
for ( int i = 0; i < hostLang->numHostTypes; i++ ) { | for ( int i = 0; i < hostLang->numHostTypes; i++ ) { | |||
if ( ( ( isSigned && hostLang->hostTypes[i].isSigned ) || | long long typeMaxVal = hostTypes[i].isSigned ? hostTypes[ | |||
!isSigned ) && | i].sMaxVal : hostTypes[i].uMaxVal; | |||
maxVal <= hostLang->hostTypes[i].maxVal ) | if ( ( ( isSigned && hostTypes[i].isSigned ) || !isSigned | |||
) && | ||||
maxVal <= typeMaxVal ) | ||||
return hostLang->hostTypes + i; | return hostLang->hostTypes + i; | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
}; | }; | |||
extern KeyOps *keyOps; | extern KeyOps *keyOps; | |||
inline bool operator<( const Key key1, const Key key2 ) | inline bool operator<( const Key key1, const Key key2 ) | |||
{ | { | |||
End of changes. 8 change blocks. | ||||
11 lines changed or deleted | 22 lines changed or added |