Fossil SCM

Fix using the unary bitwise NOT operator in TH1.

mistachkin 2014-04-01 22:28 trunk
Commit ee1aa460a40e91f502f9540053612c64c78128bb
2 files changed +1 +50
+1
--- src/th.c
+++ src/th.c
@@ -1996,10 +1996,11 @@
19961996
case OP_BITWISE_OR: iRes = iLeft|iRight; break;
19971997
case OP_LOGICAL_AND: iRes = iLeft&&iRight; break;
19981998
case OP_LOGICAL_OR: iRes = iLeft||iRight; break;
19991999
case OP_UNARY_MINUS: iRes = -iLeft; break;
20002000
case OP_UNARY_PLUS: iRes = +iLeft; break;
2001
+ case OP_BITWISE_NOT: iRes = ~iLeft; break;
20012002
case OP_LOGICAL_NOT: iRes = !iLeft; break;
20022003
default: assert(!"Internal error");
20032004
}
20042005
Th_SetResultInt(interp, iRes);
20052006
}else if( rc==TH_OK && eArgType==ARG_NUMBER ){
20062007
--- src/th.c
+++ src/th.c
@@ -1996,10 +1996,11 @@
1996 case OP_BITWISE_OR: iRes = iLeft|iRight; break;
1997 case OP_LOGICAL_AND: iRes = iLeft&&iRight; break;
1998 case OP_LOGICAL_OR: iRes = iLeft||iRight; break;
1999 case OP_UNARY_MINUS: iRes = -iLeft; break;
2000 case OP_UNARY_PLUS: iRes = +iLeft; break;
 
2001 case OP_LOGICAL_NOT: iRes = !iLeft; break;
2002 default: assert(!"Internal error");
2003 }
2004 Th_SetResultInt(interp, iRes);
2005 }else if( rc==TH_OK && eArgType==ARG_NUMBER ){
2006
--- src/th.c
+++ src/th.c
@@ -1996,10 +1996,11 @@
1996 case OP_BITWISE_OR: iRes = iLeft|iRight; break;
1997 case OP_LOGICAL_AND: iRes = iLeft&&iRight; break;
1998 case OP_LOGICAL_OR: iRes = iLeft||iRight; break;
1999 case OP_UNARY_MINUS: iRes = -iLeft; break;
2000 case OP_UNARY_PLUS: iRes = +iLeft; break;
2001 case OP_BITWISE_NOT: iRes = ~iLeft; break;
2002 case OP_LOGICAL_NOT: iRes = !iLeft; break;
2003 default: assert(!"Internal error");
2004 }
2005 Th_SetResultInt(interp, iRes);
2006 }else if( rc==TH_OK && eArgType==ARG_NUMBER ){
2007
--- test/th1.test
+++ test/th1.test
@@ -362,5 +362,55 @@
362362
363363
###############################################################################
364364
365365
fossil test-th-eval "expr +2147483649.0"
366366
test th1-expr-13 {$RESULT eq {2147483649.0}}
367
+
368
+###############################################################################
369
+
370
+fossil test-th-eval "expr ~(-1)"
371
+test th1-expr-14 {$RESULT eq {0}}
372
+
373
+###############################################################################
374
+
375
+fossil test-th-eval "expr ~-1"
376
+test th1-expr-15 {$RESULT eq {0}}
377
+
378
+###############################################################################
379
+
380
+fossil test-th-eval "expr ~0"
381
+test th1-expr-16 {$RESULT eq {-1}}
382
+
383
+###############################################################################
384
+
385
+fossil test-th-eval "expr ~+0"
386
+test th1-expr-17 {$RESULT eq {-1}}
387
+
388
+###############################################################################
389
+
390
+fossil test-th-eval "expr ~-0"
391
+test th1-expr-18 {$RESULT eq {-1}}
392
+
393
+###############################################################################
394
+
395
+fossil test-th-eval "expr ~(+0)"
396
+test th1-expr-19 {$RESULT eq {-1}}
397
+
398
+###############################################################################
399
+
400
+fossil test-th-eval "expr ~(-0)"
401
+test th1-expr-20 {$RESULT eq {-1}}
402
+
403
+###############################################################################
404
+
405
+fossil test-th-eval "expr ~1"
406
+test th1-expr-21 {$RESULT eq {-2}}
407
+
408
+###############################################################################
409
+
410
+fossil test-th-eval "expr ~+1"
411
+test th1-expr-22 {$RESULT eq {-2}}
412
+
413
+###############################################################################
414
+
415
+fossil test-th-eval "expr ~(+1)"
416
+test th1-expr-23 {$RESULT eq {-2}}
367417
--- test/th1.test
+++ test/th1.test
@@ -362,5 +362,55 @@
362
363 ###############################################################################
364
365 fossil test-th-eval "expr +2147483649.0"
366 test th1-expr-13 {$RESULT eq {2147483649.0}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
--- test/th1.test
+++ test/th1.test
@@ -362,5 +362,55 @@
362
363 ###############################################################################
364
365 fossil test-th-eval "expr +2147483649.0"
366 test th1-expr-13 {$RESULT eq {2147483649.0}}
367
368 ###############################################################################
369
370 fossil test-th-eval "expr ~(-1)"
371 test th1-expr-14 {$RESULT eq {0}}
372
373 ###############################################################################
374
375 fossil test-th-eval "expr ~-1"
376 test th1-expr-15 {$RESULT eq {0}}
377
378 ###############################################################################
379
380 fossil test-th-eval "expr ~0"
381 test th1-expr-16 {$RESULT eq {-1}}
382
383 ###############################################################################
384
385 fossil test-th-eval "expr ~+0"
386 test th1-expr-17 {$RESULT eq {-1}}
387
388 ###############################################################################
389
390 fossil test-th-eval "expr ~-0"
391 test th1-expr-18 {$RESULT eq {-1}}
392
393 ###############################################################################
394
395 fossil test-th-eval "expr ~(+0)"
396 test th1-expr-19 {$RESULT eq {-1}}
397
398 ###############################################################################
399
400 fossil test-th-eval "expr ~(-0)"
401 test th1-expr-20 {$RESULT eq {-1}}
402
403 ###############################################################################
404
405 fossil test-th-eval "expr ~1"
406 test th1-expr-21 {$RESULT eq {-2}}
407
408 ###############################################################################
409
410 fossil test-th-eval "expr ~+1"
411 test th1-expr-22 {$RESULT eq {-2}}
412
413 ###############################################################################
414
415 fossil test-th-eval "expr ~(+1)"
416 test th1-expr-23 {$RESULT eq {-2}}
417

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button