Make stack-checker throw proper errors for primitives that do not have static stack effects

db4
Slava Pestov 2010-01-20 16:37:58 +13:00
parent fc4686eaee
commit 580cbe75c6
4 changed files with 33 additions and 10 deletions

View File

@ -30,8 +30,6 @@ ERROR: unbalanced-recursion-error < inference-error word height ;
ERROR: inconsistent-recursive-call-error < inference-error word ; ERROR: inconsistent-recursive-call-error < inference-error word ;
ERROR: unknown-primitive-error < inference-error ;
ERROR: transform-expansion-error < inference-error error continuation word ; ERROR: transform-expansion-error < inference-error error continuation word ;
ERROR: bad-declaration-error < inference-error declaration ; ERROR: bad-declaration-error < inference-error declaration ;

View File

@ -50,9 +50,6 @@ M: inconsistent-recursive-call-error summary
"The recursive word " "The recursive word "
" calls itself with a different set of quotation parameters than were input" surround ; " calls itself with a different set of quotation parameters than were input" surround ;
M: unknown-primitive-error summary
drop "The do-primitive word cannot be called from here" ;
M: transform-expansion-error summary M: transform-expansion-error summary
word>> name>> "Macro expansion of " " threw an error" surround ; word>> name>> "Macro expansion of " " threw an error" surround ;

View File

@ -13,7 +13,7 @@ words.private definitions assocs summary compiler.units
system.private combinators combinators.short-circuit locals system.private combinators combinators.short-circuit locals
locals.backend locals.types combinators.private locals.backend locals.types combinators.private
stack-checker.values generic.single generic.single.private stack-checker.values generic.single generic.single.private
alien.libraries tools.dispatch.private tools.profiler.private alien.libraries tools.dispatch.private tools.profiler.private vm
stack-checker.alien stack-checker.alien
stack-checker.state stack-checker.state
stack-checker.errors stack-checker.errors
@ -221,8 +221,6 @@ M: bad-executable summary
dup '[ _ infer-call-effect ] "special" set-word-prop dup '[ _ infer-call-effect ] "special" set-word-prop
] each ] each
\ do-primitive [ unknown-primitive-error ] "special" set-word-prop
\ if [ infer-if ] "special" set-word-prop \ if [ infer-if ] "special" set-word-prop
\ dispatch [ infer-dispatch ] "special" set-word-prop \ dispatch [ infer-dispatch ] "special" set-word-prop
@ -231,6 +229,22 @@ M: bad-executable summary
\ alien-assembly [ infer-alien-assembly ] "special" set-word-prop \ alien-assembly [ infer-alien-assembly ] "special" set-word-prop
\ alien-callback [ infer-alien-callback ] "special" set-word-prop \ alien-callback [ infer-alien-callback ] "special" set-word-prop
{
do-primitive
mega-cache-miss
mega-cache-lookup
inline-cache-miss
inline-cache-miss-tail
unwind-native-frames
set-datastack
set-callstack
set-retainstack
unwind-native-frames
lazy-jit-compile
c-to-factor
call-clear
} [ dup '[ _ do-not-compile ] "special" set-word-prop ] each
: infer-special ( word -- ) : infer-special ( word -- )
[ current-word set ] [ "special" word-prop call( -- ) ] bi ; [ current-word set ] [ "special" word-prop call( -- ) ] bi ;
@ -722,3 +736,9 @@ M: bad-executable summary
\ (identity-hashcode) { object } { fixnum } define-primitive \ (identity-hashcode) { object } { fixnum } define-primitive
\ compute-identity-hashcode { object } { } define-primitive \ compute-identity-hashcode { object } { } define-primitive
\ (exit) { integer } { } define-primitive
\ vm-ptr { } { alien } define-primitive
\ quot-compiled? { quotation } { object } define-primitive

View File

@ -7,7 +7,7 @@ sorting assocs definitions prettyprint io inspector
classes.tuple classes.union classes.predicate debugger classes.tuple classes.union classes.predicate debugger
threads.private io.streams.string io.timeouts io.thread threads.private io.streams.string io.timeouts io.thread
sequences.private destructors combinators eval locals.backend sequences.private destructors combinators eval locals.backend
system compiler.units shuffle ; system compiler.units shuffle vocabs ;
IN: stack-checker.tests IN: stack-checker.tests
[ 1234 infer ] must-fail [ 1234 infer ] must-fail
@ -392,5 +392,13 @@ DEFER: eee'
[ [ call-effect ] infer ] [ T{ unknown-macro-input f call-effect } = ] must-fail-with [ [ call-effect ] infer ] [ T{ unknown-macro-input f call-effect } = ] must-fail-with
[ [ execute-effect ] infer ] [ T{ unknown-macro-input f execute-effect } = ] must-fail-with [ [ execute-effect ] infer ] [ T{ unknown-macro-input f execute-effect } = ] must-fail-with
[ \ set-datastack def>> infer ] [ T{ unknown-primitive-error } = ] must-fail-with [ \ set-datastack def>> infer ] [ T{ do-not-compile f do-primitive } = ] must-fail-with
[ ] [ [ \ set-datastack def>> infer ] try ] unit-test [ ] [ [ \ set-datastack def>> infer ] try ] unit-test
! Make sure all primitives are covered
[ { } ] [
all-words [ primitive? ] filter
[ "default-output-classes" word-prop not ] filter
[ "special" word-prop not ] filter
[ "shuffle" word-prop not ] filter
] unit-test