bignum bitnot, bitop tests
parent
c8cc64b031
commit
0c609f4a48
|
|
@ -1,5 +1,3 @@
|
|||
- bitwise operations
|
||||
- clone-hashtable
|
||||
- sidekick: error source not removed
|
||||
- lineno/file for native
|
||||
- jedit for native with socket communication
|
||||
|
|
@ -8,7 +6,6 @@
|
|||
- maple-like: press enter at old commands to evaluate there
|
||||
- sending ^C on socket
|
||||
- read#
|
||||
- describe-word
|
||||
- enforce bottom-up in native bootstrap
|
||||
- standalone listener input style
|
||||
- log-client: fix for native
|
||||
|
|
@ -32,8 +29,11 @@
|
|||
|
||||
+ listener/plugin:
|
||||
|
||||
- auto insert USE:
|
||||
- why > 1 popup
|
||||
- listener backspace overzealous
|
||||
- lineno/file for shuffle defs
|
||||
- completion popups for shuffle defs
|
||||
- balance needs USE:
|
||||
- completion: enter no good
|
||||
- completion: don't show automatically
|
||||
|
|
@ -47,6 +47,7 @@
|
|||
- postpone errors until actual read/write op
|
||||
- multitasking
|
||||
- parsing should be parsing
|
||||
- better error reporting
|
||||
|
||||
+ JVM compiler:
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@ The Factor plugin adds a menu to jEdit's <b>Plugins</b> menu with the following
|
|||
<li><b>Evaluate selection</b> evaluates the current selection.</li>
|
||||
<li><b>Apropos word at caret</b> performs an apropos search on the current selection, or the word at the caret if there is no selection. An "apropos search" lists all words in all vocabularies whose names contain a certain string. For example, you can use this to list all string words by searching for "str", or to find out which vocabulary contains the word "unparse" by searching for "unparse".</li>
|
||||
<li><b>See word at caret</b> shows the definition of the word at the caret in the listener dockable window.</li>
|
||||
<li><b>Edit word at caret</b> opens the source file containing the definition of the word at the caret.
|
||||
For this to work with words defined in the standard library, you must set the "resource-path" variable in your <code>~/.factor-rc</code> to point to the location of the library sources:
|
||||
|
||||
<pre>"/home/slava/Factor/" "resource-path" set</pre>
|
||||
</li>
|
||||
<li><b>Word usages at caret</b> shows all usages of the word at the caret in the listener dockable window.</li>
|
||||
</ul>
|
||||
|
||||
|
|
@ -62,19 +67,5 @@ The Factor plugin uses the SideKick plugin to perform background parsing of Fact
|
|||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 class="fancy-heading">Jumping to a word definition</h2>
|
||||
|
||||
If you add the following line to your <code>~/.factor-rc</code>:
|
||||
|
||||
<pre>USE: jedit</pre>
|
||||
|
||||
You can then jump to a word definition using the <code>jedit</code> word in the Factor interpreter:
|
||||
|
||||
<pre>"numbers-game" jedit</pre>
|
||||
|
||||
For this to work with words defined in the standard library, you must set the "resource-path" variable in your <code>~/.factor-rc</code> to point to the location of the library sources:
|
||||
|
||||
<pre>"/home/slava/Factor/" "resource-path" set</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
IN: scratchpad
|
||||
USE: arithmetic
|
||||
USE: kernel
|
||||
USE: stack
|
||||
USE: test
|
||||
|
||||
[ -2 ] [ 1 bitnot ] unit-test
|
||||
[ -2 ] [ 1 >bignum bitnot ] unit-test
|
||||
[ -2 ] [ 1 >bignum bitnot ] unit-test
|
||||
[ 0 ] [ 123 dup bitnot bitand ] unit-test
|
||||
[ 0 ] [ 123 >bignum dup bitnot bitand ] unit-test
|
||||
[ 0 ] [ 123 dup bitnot >bignum bitand ] unit-test
|
||||
[ 0 ] [ 123 dup bitnot bitand >bignum ] unit-test
|
||||
[ -1 ] [ 123 dup bitnot bitor ] unit-test
|
||||
[ -1 ] [ 123 >bignum dup bitnot bitor ] unit-test
|
||||
[ -1 ] [ 123 dup bitnot >bignum bitor ] unit-test
|
||||
[ -1 ] [ 123 dup bitnot bitor >bignum ] unit-test
|
||||
[ -1 ] [ 123 dup bitnot bitxor ] unit-test
|
||||
[ -1 ] [ 123 >bignum dup bitnot bitxor ] unit-test
|
||||
[ -1 ] [ 123 dup bitnot >bignum bitxor ] unit-test
|
||||
[ -1 ] [ 123 dup bitnot bitxor >bignum ] unit-test
|
||||
|
|
@ -80,6 +80,7 @@ USE: unparser
|
|||
"vectors"
|
||||
"unparser"
|
||||
"random"
|
||||
"math/bitops"
|
||||
"math/rational"
|
||||
"math/float"
|
||||
"math/complex"
|
||||
|
|
|
|||
|
|
@ -151,3 +151,7 @@ BINARY_OP(greatereq)
|
|||
BINARY_OP_INTEGER_ONLY(gcd)
|
||||
BINARY_OP_NUMBER_ONLY(gcd)
|
||||
BINARY_OP(gcd)
|
||||
|
||||
UNARY_OP_INTEGER_ONLY(not)
|
||||
UNARY_OP_NUMBER_ONLY(not)
|
||||
UNARY_OP(not)
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ CELL OP##_anytype(CELL x, CELL y) \
|
|||
return F; \
|
||||
}
|
||||
|
||||
#define UNARY_OP(OP,anytype,integerOnly) \
|
||||
#define UNARY_OP(OP) \
|
||||
CELL OP(CELL x) \
|
||||
{ \
|
||||
switch(type_of(x)) \
|
||||
|
|
@ -165,39 +165,15 @@ CELL OP(CELL x) \
|
|||
case FIXNUM_TYPE: \
|
||||
return OP##_fixnum(x); \
|
||||
case RATIO_TYPE: \
|
||||
if(integerOnly) \
|
||||
{ \
|
||||
type_error(INTEGER_TYPE,x); \
|
||||
return F; \
|
||||
} \
|
||||
else \
|
||||
return OP##_ratio(x); \
|
||||
case COMPLEX_TYPE: \
|
||||
if(integerOnly) \
|
||||
{ \
|
||||
type_error(INTEGER_TYPE,x); \
|
||||
return F; \
|
||||
} \
|
||||
else \
|
||||
return OP##_complex(x); \
|
||||
case BIGNUM_TYPE: \
|
||||
return OP##_bignum(x); \
|
||||
case FLOAT_TYPE: \
|
||||
if(integerOnly) \
|
||||
{ \
|
||||
type_error(INTEGER_TYPE,x); \
|
||||
return F; \
|
||||
} \
|
||||
else \
|
||||
return OP##_float(x); \
|
||||
default: \
|
||||
if(anytype) \
|
||||
return OP##_anytype(x); \
|
||||
else \
|
||||
{ \
|
||||
type_error(NUMBER_TYPE,x); \
|
||||
return F; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
|
|
@ -206,6 +182,34 @@ void primitive_##OP(void) \
|
|||
drepl(OP(dpeek())); \
|
||||
}
|
||||
|
||||
#define UNARY_OP_INTEGER_ONLY(OP) \
|
||||
\
|
||||
CELL OP##_ratio(CELL x) \
|
||||
{ \
|
||||
type_error(INTEGER_TYPE,x); \
|
||||
return F; \
|
||||
} \
|
||||
\
|
||||
CELL OP##_complex(CELL x) \
|
||||
{ \
|
||||
type_error(INTEGER_TYPE,x); \
|
||||
return F; \
|
||||
} \
|
||||
\
|
||||
CELL OP##_float(CELL x) \
|
||||
{ \
|
||||
type_error(INTEGER_TYPE,x); \
|
||||
return F; \
|
||||
}
|
||||
|
||||
#define UNARY_OP_NUMBER_ONLY(OP) \
|
||||
\
|
||||
CELL OP##_anytype(CELL x) \
|
||||
{ \
|
||||
type_error(NUMBER_TYPE,x); \
|
||||
return F; \
|
||||
}
|
||||
|
||||
bool realp(CELL tagged);
|
||||
bool numberp(CELL tagged);
|
||||
void primitive_numberp(void);
|
||||
|
|
|
|||
|
|
@ -198,3 +198,8 @@ CELL greatereq_bignum(CELL x, CELL y)
|
|||
return tag_boolean(((BIGNUM*)UNTAG(x))->n
|
||||
>= ((BIGNUM*)UNTAG(y))->n);
|
||||
}
|
||||
|
||||
CELL not_bignum(CELL x)
|
||||
{
|
||||
return tag_object(bignum(~((BIGNUM*)UNTAG(x))->n));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,3 +51,4 @@ CELL less_bignum(CELL x, CELL y);
|
|||
CELL lesseq_bignum(CELL x, CELL y);
|
||||
CELL greater_bignum(CELL x, CELL y);
|
||||
CELL greatereq_bignum(CELL x, CELL y);
|
||||
CELL not_bignum(CELL x);
|
||||
|
|
|
|||
|
|
@ -5,12 +5,6 @@ void primitive_fixnump(void)
|
|||
drepl(tag_boolean(TAG(dpeek()) == FIXNUM_TYPE));
|
||||
}
|
||||
|
||||
void primitive_not(void)
|
||||
{
|
||||
type_check(FIXNUM_TYPE,dpeek());
|
||||
drepl(RETAG(UNTAG(~dpeek()),FIXNUM_TYPE));
|
||||
}
|
||||
|
||||
FIXNUM to_fixnum(CELL tagged)
|
||||
{
|
||||
RATIO* r;
|
||||
|
|
@ -192,3 +186,8 @@ CELL greatereq_fixnum(CELL x, CELL y)
|
|||
{
|
||||
return tag_boolean((FIXNUM)x >= (FIXNUM)y);
|
||||
}
|
||||
|
||||
CELL not_fixnum(CELL n)
|
||||
{
|
||||
return RETAG(UNTAG(~n),FIXNUM_TYPE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,3 +38,4 @@ CELL less_fixnum(CELL x, CELL y);
|
|||
CELL lesseq_fixnum(CELL x, CELL y);
|
||||
CELL greater_fixnum(CELL x, CELL y);
|
||||
CELL greatereq_fixnum(CELL x, CELL y);
|
||||
CELL not_fixnum(CELL n);
|
||||
|
|
|
|||
Loading…
Reference in New Issue