mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-21 14:50:44 +01:00
First version of the simplifications.
Change-Id: Idbddb92b6bd098d6b862f5fc4abd741948e15194
This commit is contained in:
@@ -344,6 +344,30 @@ ExpressionLayout * Integer::createLayout() {
|
||||
return new StringLayout(buffer, size);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
int Integer::getPrintableVersion(char* txt) {
|
||||
Integer base = Integer(10);
|
||||
Division d = Division(*this, base);
|
||||
int size = 0;
|
||||
while (!(d.m_remainder == Integer((native_int_t)0))) {
|
||||
assert(size<255); //TODO: malloc an extra buffer
|
||||
char c = char_from_digit(d.m_remainder.m_digits[0]);
|
||||
txt[size++] = c;
|
||||
d = Division(d.m_quotient, base);
|
||||
}
|
||||
txt[size] = 0;
|
||||
|
||||
// Flip the string
|
||||
for (int i=0, j=size-1 ; i < j ; i++, j--) {
|
||||
char c = txt[i];
|
||||
txt[i] = txt[j];
|
||||
txt[j] = c;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Integer::valueEquals(Expression * e) {
|
||||
assert(e->type() == Expression::Type::Integer);
|
||||
return (*this == *(Integer *)e); // FIXME: Remove operator overloading
|
||||
|
||||
Reference in New Issue
Block a user