kernel: symbolic constants for the various kernel errors
							parent
							
								
									7bde6a53da
								
							
						
					
					
						commit
						6627a3327b
					
				|  | @ -10,7 +10,7 @@ FUNCTION: void this_does_not_exist ( ) ; | ||||||
| [ this_does_not_exist ] try | [ this_does_not_exist ] try | ||||||
| 
 | 
 | ||||||
| [ this_does_not_exist ] [ | [ this_does_not_exist ] [ | ||||||
|     { "kernel-error" 9 $[ "this_does_not_exist" string>symbol ] f } |     ${ "kernel-error" ERROR-UNDEFINED-SYMBOL "this_does_not_exist" string>symbol f } | ||||||
|     = |     = | ||||||
| ] must-fail-with | ] must-fail-with | ||||||
| 
 | 
 | ||||||
|  | @ -31,10 +31,10 @@ FUNCTION: void no_such_function ( ) ; | ||||||
| [ no_such_function ] try | [ no_such_function ] try | ||||||
| 
 | 
 | ||||||
| [ no_such_function ] [ | [ no_such_function ] [ | ||||||
|     { |     ${ | ||||||
|         "kernel-error" 9 |         "kernel-error" ERROR-UNDEFINED-SYMBOL | ||||||
|         $[ "no_such_function" string>symbol ] |         "no_such_function" string>symbol | ||||||
|         $[ "no_such_library" load-library ] |         "no_such_library" load-library | ||||||
|     } |     } | ||||||
|     = |     = | ||||||
| ] must-fail-with | ] must-fail-with | ||||||
|  |  | ||||||
|  | @ -143,7 +143,7 @@ PREDICATE: vm-error < array | ||||||
|     dup length 2 < [ drop f ] [ |     dup length 2 < [ drop f ] [ | ||||||
|         { |         { | ||||||
|             [ first-unsafe "kernel-error" = ] |             [ first-unsafe "kernel-error" = ] | ||||||
|             [ second-unsafe 0 18 between? ] |             [ second-unsafe 0 kernel-error-count 1 - between? ] | ||||||
|         } 1&& |         } 1&& | ||||||
|     ] if ; |     ] if ; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| USING: kernel math math.floats.env math.floats.env.private | USING: kernel math math.floats.env math.floats.env.private | ||||||
| math.functions math.libm sequences tools.test locals | math.functions math.libm literals sequences tools.test locals | ||||||
| compiler.units kernel.private fry compiler.test math.private | compiler.units kernel.private fry compiler.test math.private | ||||||
| words system memory ; | words system memory ; | ||||||
| IN: math.floats.env.tests | IN: math.floats.env.tests | ||||||
|  | @ -111,7 +111,7 @@ os linux? cpu x86.64? and [ | ||||||
| ] unit-test | ] unit-test | ||||||
| 
 | 
 | ||||||
| : fp-trap-error? ( error -- ? ) | : fp-trap-error? ( error -- ? ) | ||||||
|     2 head { "kernel-error" 17 } = ; |     2 head ${ "kernel-error" ERROR-FP-TRAP } = ; | ||||||
| 
 | 
 | ||||||
| : test-traps ( traps inputs quot -- quot' fail-quot ) | : test-traps ( traps inputs quot -- quot' fail-quot ) | ||||||
|     append '[ _ _ with-fp-traps ] [ fp-trap-error? ] ; |     append '[ _ _ with-fp-traps ] [ fp-trap-error? ] ; | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| USING: arrays byte-arrays kernel kernel.private math memory | USING: arrays byte-arrays kernel kernel.private literals math | ||||||
| namespaces sequences tools.test math.private quotations | memory namespaces sequences tools.test math.private quotations | ||||||
| continuations prettyprint io.streams.string debugger assocs | continuations prettyprint io.streams.string debugger assocs | ||||||
| sequences.private accessors locals.backend grouping words | sequences.private accessors locals.backend grouping words | ||||||
| system alien alien.accessors ; | system alien alien.accessors ; | ||||||
|  | @ -14,11 +14,16 @@ IN: kernel.tests | ||||||
| [ ] [ 1000 [ [ -1 f <array> ] ignore-errors ] times ] unit-test | [ ] [ 1000 [ [ -1 f <array> ] ignore-errors ] times ] unit-test | ||||||
| 
 | 
 | ||||||
| ! Make sure we report the correct error on stack underflow | ! Make sure we report the correct error on stack underflow | ||||||
| [ clear drop ] [ { "kernel-error" 10 f f } = ] must-fail-with | [ clear drop ] [ | ||||||
|  |     ${ "kernel-error" ERROR-DATASTACK-UNDERFLOW f f } = | ||||||
|  | ] must-fail-with | ||||||
| 
 | 
 | ||||||
| [ ] [ :c ] unit-test | [ ] [ :c ] unit-test | ||||||
| 
 | 
 | ||||||
| [ 3 [ { } set-retainstack ] dip ] [ { "kernel-error" 12 f f } = ] must-fail-with | [ | ||||||
|  |     3 [ { } set-retainstack ] dip ] | ||||||
|  |     [ ${ "kernel-error" ERROR-RETAINSTACK-UNDERFLOW f f } = | ||||||
|  | ] must-fail-with | ||||||
| 
 | 
 | ||||||
| [ ] [ :c ] unit-test | [ ] [ :c ] unit-test | ||||||
| 
 | 
 | ||||||
|  | @ -35,15 +40,21 @@ IN: kernel.tests | ||||||
| [ t "no-compile" set-word-prop ] each | [ t "no-compile" set-word-prop ] each | ||||||
| >> | >> | ||||||
| 
 | 
 | ||||||
| [ overflow-d ] [ { "kernel-error" 11 f f } = ] must-fail-with | [ overflow-d ] [ | ||||||
|  |     ${ "kernel-error" ERROR-DATASTACK-OVERFLOW f f } = | ||||||
|  | ] must-fail-with | ||||||
| 
 | 
 | ||||||
| [ ] [ :c ] unit-test | [ ] [ :c ] unit-test | ||||||
| 
 | 
 | ||||||
| [ overflow-d-alt ] [ { "kernel-error" 11 f f } = ] must-fail-with | [ overflow-d-alt ] [ | ||||||
|  |     ${ "kernel-error" ERROR-DATASTACK-OVERFLOW f f } = | ||||||
|  | ] must-fail-with | ||||||
| 
 | 
 | ||||||
| [ ] [ [ :c ] with-string-writer drop ] unit-test | [ ] [ [ :c ] with-string-writer drop ] unit-test | ||||||
| 
 | 
 | ||||||
| [ overflow-r ] [ { "kernel-error" 13 f f } = ] must-fail-with | [ overflow-r ] [ | ||||||
|  |     ${ "kernel-error" ERROR-RETAINSTACK-OVERFLOW f f } = | ||||||
|  | ] must-fail-with | ||||||
| 
 | 
 | ||||||
| [ ] [ :c ] unit-test | [ ] [ :c ] unit-test | ||||||
| 
 | 
 | ||||||
|  | @ -53,7 +64,9 @@ IN: kernel.tests | ||||||
| ! because no facility exists to run memory protection | ! because no facility exists to run memory protection | ||||||
| ! fault handlers on an alternate callstack. | ! fault handlers on an alternate callstack. | ||||||
| os windows? [ | os windows? [ | ||||||
|     [ overflow-c ] [ { "kernel-error" 15 f f } = ] must-fail-with |     [ overflow-c ] [ | ||||||
|  |         ${ "kernel-error" ERROR-CALLSTACK-OVERFLOW f f } = | ||||||
|  |     ] must-fail-with | ||||||
| ] unless | ] unless | ||||||
| 
 | 
 | ||||||
| [ -7 <byte-array> ] must-fail | [ -7 <byte-array> ] must-fail | ||||||
|  |  | ||||||
|  | @ -364,3 +364,26 @@ CONSTANT: CONTEXT-OBJ-CONTEXT 2 | ||||||
| CONSTANT: CONTEXT-OBJ-IN-CALLBACK-P 3 | CONSTANT: CONTEXT-OBJ-IN-CALLBACK-P 3 | ||||||
| 
 | 
 | ||||||
| PRIVATE> | PRIVATE> | ||||||
|  | 
 | ||||||
|  | ! Runtime errors must be kept in sync with: | ||||||
|  | !   vm/errors.hpp | ||||||
|  | CONSTANT: kernel-error-count 19 | ||||||
|  | CONSTANT: ERROR-EXPIRED 0 | ||||||
|  | CONSTANT: ERROR-IO      1 | ||||||
|  | CONSTANT: ERROR-NOT-IMPLEMENTED 2 | ||||||
|  | CONSTANT: ERROR-TYPE 3 | ||||||
|  | CONSTANT: ERROR-DIVIDE-BY-ZERO 4 | ||||||
|  | CONSTANT: ERROR-SIGNAL 5 | ||||||
|  | CONSTANT: ERROR-ARRAY-SIZE 6 | ||||||
|  | CONSTANT: ERROR-C-STRING 7 | ||||||
|  | CONSTANT: ERROR-FFI 8 | ||||||
|  | CONSTANT: ERROR-UNDEFINED-SYMBOL 9 | ||||||
|  | CONSTANT: ERROR-DATASTACK-UNDERFLOW 10 | ||||||
|  | CONSTANT: ERROR-DATASTACK-OVERFLOW 11 | ||||||
|  | CONSTANT: ERROR-RETAINSTACK-UNDERFLOW 12 | ||||||
|  | CONSTANT: ERROR-RETAINSTACK-OVERFLOW 13 | ||||||
|  | CONSTANT: ERROR-CALLSTACK-UNDERFLOW 14 | ||||||
|  | CONSTANT: ERROR-CALLSTACK-OVERFLOW 15 | ||||||
|  | CONSTANT: ERROR-MEMORY 16 | ||||||
|  | CONSTANT: ERROR-FP-TRAP 17 | ||||||
|  | CONSTANT: ERROR-INTERRUPT 18 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| USING: continuations kernel math math.order namespaces make | USING: continuations kernel literals math math.order namespaces make | ||||||
| strings strings.private sbufs tools.test sequences vectors | strings strings.private sbufs tools.test sequences vectors | ||||||
| arrays memory prettyprint io.streams.null ; | arrays memory prettyprint io.streams.null ; | ||||||
| IN: strings.tests | IN: strings.tests | ||||||
|  | @ -58,7 +58,8 @@ unit-test | ||||||
| [ "\u001234bc\0\0\0" ] [ 6 "\u001234bc" resize-string ] unit-test | [ "\u001234bc\0\0\0" ] [ 6 "\u001234bc" resize-string ] unit-test | ||||||
| 
 | 
 | ||||||
| ! Random tester found this | ! Random tester found this | ||||||
| [ 2 -7 resize-string ] [ { "kernel-error" 3 11 -7 } = ] must-fail-with | [ 2 -7 resize-string ] | ||||||
|  | [ ${ "kernel-error" ERROR-TYPE 11 -7 } = ] must-fail-with | ||||||
| 
 | 
 | ||||||
| ! Make sure 24-bit strings work | ! Make sure 24-bit strings work | ||||||
| "hello world" "s" set | "hello world" "s" set | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| ! Copyright (C) 2009 Doug Coleman. | ! Copyright (C) 2009 Doug Coleman. | ||||||
| ! See http://factorcode.org/license.txt for BSD license. | ! See http://factorcode.org/license.txt for BSD license. | ||||||
| USING: continuations decimals grouping kernel locals math | USING: continuations decimals grouping kernel literals locals | ||||||
| math.functions math.order math.ratios prettyprint random | math math.functions math.order math.ratios prettyprint random | ||||||
| sequences tools.test ; | sequences tools.test ; | ||||||
| IN: decimals.tests | IN: decimals.tests | ||||||
| 
 | 
 | ||||||
|  | @ -33,7 +33,7 @@ ERROR: decimal-test-failure D1 D2 quot ; | ||||||
|     1000 [ |     1000 [ | ||||||
|         drop |         drop | ||||||
|         [ [ 100 D/ ] [ /f ] test-decimal-op ] |         [ [ 100 D/ ] [ /f ] test-decimal-op ] | ||||||
|         [ { "kernel-error" 4 f f } = ] recover |         [ ${ "kernel-error" ERROR-DIVIDE-BY-ZERO f f } = ] recover | ||||||
|     ] all-integers? |     ] all-integers? | ||||||
| ] unit-test | ] unit-test | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| namespace factor { | namespace factor { | ||||||
| 
 | 
 | ||||||
| /* Runtime errors */ | // Runtime errors must be kept in sync with:
 | ||||||
|  | //   core/kernel/kernel.factor
 | ||||||
| enum vm_error_type { | enum vm_error_type { | ||||||
|   ERROR_EXPIRED = 0, |   ERROR_EXPIRED = 0, | ||||||
|   ERROR_IO, |   ERROR_IO, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue