intentionally do reSign in printing %d

This commit is contained in:
Alon Zakai 2011-09-14 18:08:52 -07:00
Родитель 55013f30bc
Коммит ce07f2aa77
5 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -2338,9 +2338,9 @@ LibraryManager.library = {
var argText;
var prefix = '';
if (next == 'd'.charCodeAt(0) || next == 'i'.charCodeAt(0)) {
argText = currAbsArg.toString(10);
argText = reSign(currArg, 8 * argSize, 1).toString(10);
} else if (next == 'u'.charCodeAt(0)) {
argText = unSign(currArg, 8 * argSize).toString(10);
argText = unSign(currArg, 8 * argSize, 1).toString(10);
currArg = Math.abs(currArg);
} else if (next == 'o'.charCodeAt(0)) {
argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
@ -2377,11 +2377,13 @@ LibraryManager.library = {
}
}
// Add sign.
if (currArg < 0) {
prefix = '-' + prefix;
} else if (flagAlwaysSigned) {
prefix = '+' + prefix;
// Add sign if needed
if (flagAlwaysSigned) {
if (currArg < 0) {
prefix = '-' + prefix;
} else {
prefix = '+' + prefix;
}
}
// Add padding.

Просмотреть файл

@ -268,7 +268,7 @@ function reSign(value, bits, ignore, sig) {
#if CHECK_SIGNS
var noted = false;
#endif
if (value >= half) {
if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
#if CHECK_SIGNS
if (!ignore) {
CorrectionsMonitor.note('ReSign', 0, sig);

Просмотреть файл

@ -217,7 +217,7 @@ class RunnerCore(unittest.TestCase):
return ret
def run_llvm_interpreter(self, args):
return Popen([LLVM_INTERPRETER] + args, stdout=PIPE, stderr=STDOUT).communicate()[0]
return Popen([EXEC_LLVM] + args, stdout=PIPE, stderr=STDOUT).communicate()[0]
def build_native(self, filename, compiler='g++'):
Popen([compiler, '-O3', filename, '-o', filename+'.native'], stdout=PIPE, stderr=STDOUT).communicate()[0]
@ -429,6 +429,13 @@ if 'benchmark' not in str(sys.argv):
const signed char cvals[2] = { -1, -2 }; // compiler can store this is a string, so -1 becomes \FF, and needs re-signing
int main()
{
{
unsigned char x = 200;
printf("*%d*\\n", x);
unsigned char y = -22;
printf("*%d*\\n", y);
}
int varey = 100;
unsigned int MAXEY = -1, MAXEY2 = -77;
printf("*%u,%d,%u*\\n", MAXEY, varey >= MAXEY, MAXEY2); // 100 >= -1? not in unsigned!
@ -453,7 +460,7 @@ if 'benchmark' not in str(sys.argv):
return 0;
}
'''
self.do_test(src, '*4294967295,0,4294967219*\n*-1,1,-1,1*\n*-2,1,-2,1*\n*246,296*\n*1,0*')
self.do_test(src)#, '*4294967295,0,4294967219*\n*-1,1,-1,1*\n*-2,1,-2,1*\n*246,296*\n*1,0*')
# Now let's see some code that should just work in USE_TYPED_ARRAYS == 2, but requires
# corrections otherwise

Просмотреть файл

@ -41,8 +41,6 @@ def path_from_root(*pathelems):
return os.path.join(os.path.sep, *(abspath.split(os.sep)[:-1] + list(pathelems)))
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
print '// EXEC_LLVM: ', sys.argv
Popen([LLVM_OPT, sys.argv[1], '-strip-debug', '-o=' + sys.argv[1]+'.clean.bc']).communicate()[0]
# Execute with empty environment - just like the JS script will have

Просмотреть файл

@ -23,6 +23,7 @@ LLVM_INTERPRETER=os.path.expanduser(os.path.join(LLVM_ROOT, 'lli'))
LLVM_COMPILER=os.path.expanduser(os.path.join(LLVM_ROOT, 'llc'))
BINDINGS_GENERATOR = path_from_root('tools', 'bindings_generator.py')
EXEC_LLVM = path_from_root('tools', 'exec_llvm.py')
# Engine tweaks