First version of the simplifications.

Change-Id: Idbddb92b6bd098d6b862f5fc4abd741948e15194
This commit is contained in:
Felix Raimundo
2016-04-01 10:40:54 +02:00
parent 6232079f02
commit ed2c4cfb59
37 changed files with 460 additions and 149 deletions

View File

@@ -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