12 |
12 |
13 "{ Package: 'stx:libbasic' }" |
13 "{ Package: 'stx:libbasic' }" |
14 |
14 |
15 ExecutableFunction variableSubclass:#CompiledCode |
15 ExecutableFunction variableSubclass:#CompiledCode |
16 instanceVariableNames:'flags byteCode' |
16 instanceVariableNames:'flags byteCode' |
17 classVariableNames:'NoByteCodeSignal InvalidByteCodeSignal InvalidInstructionSignal |
17 classVariableNames:'' |
18 BadLiteralsSignal NonBooleanReceiverSignal ArgumentSignal' |
|
19 poolDictionaries:'' |
18 poolDictionaries:'' |
20 category:'Kernel-Methods' |
19 category:'Kernel-Methods' |
21 ! |
20 ! |
22 |
21 |
23 !CompiledCode class methodsFor:'documentation'! |
22 !CompiledCode class methodsFor:'documentation'! |
73 [author:] |
72 [author:] |
74 Claus Gittinger |
73 Claus Gittinger |
75 " |
74 " |
76 ! ! |
75 ! ! |
77 |
76 |
78 !CompiledCode class methodsFor:'initialization'! |
|
79 |
|
80 initialize |
|
81 "create signals raised by various errors." |
|
82 |
|
83 "uses class-based exceptions now (but remain backward compatible)" |
|
84 |
|
85 NoByteCodeSignal isNil ifTrue:[ |
|
86 "/ NoByteCodeSignal := ExecutionErrorSignal newSignalMayProceed:true. |
|
87 "/ NoByteCodeSignal nameClass:self message:#noByteCodeSignal. |
|
88 NoByteCodeSignal := NoByteCodeError. |
|
89 NoByteCodeSignal notifierString:'nil byteCode in code-object - not executable'. |
|
90 |
|
91 "/ InvalidByteCodeSignal := ExecutionErrorSignal newSignalMayProceed:true. |
|
92 "/ InvalidByteCodeSignal nameClass:self message:#invalidByteCodeSignal. |
|
93 InvalidByteCodeSignal := InvalidByteCodeError. |
|
94 InvalidByteCodeSignal notifierString:'invalid byteCode in code-object - not executable'. |
|
95 |
|
96 "/ InvalidInstructionSignal := ExecutionErrorSignal newSignalMayProceed:true. |
|
97 "/ InvalidInstructionSignal nameClass:self message:#invalidInstructionSignal. |
|
98 InvalidInstructionSignal := InvalidInstructionError. |
|
99 InvalidInstructionSignal notifierString:'invalid instruction in code-object - not executable'. |
|
100 |
|
101 "/ BadLiteralsSignal := ExecutionErrorSignal newSignalMayProceed:true. |
|
102 "/ BadLiteralsSignal nameClass:self message:#badLiteralsSignal. |
|
103 BadLiteralsSignal := BadLiteralsError. |
|
104 BadLiteralsSignal notifierString:'bad literal table in code-object - should not happen'. |
|
105 |
|
106 "/ NonBooleanReceiverSignal := ExecutionErrorSignal newSignalMayProceed:true. |
|
107 "/ NonBooleanReceiverSignal nameClass:self message:#nonBooleanReceiverSignal. |
|
108 NonBooleanReceiverSignal := NonBooleanReceiverError. |
|
109 NonBooleanReceiverSignal notifierString:'if/while on non-boolean receiver'. |
|
110 |
|
111 "/ ArgumentSignal := ExecutionErrorSignal newSignalMayProceed:true. |
|
112 "/ ArgumentSignal nameClass:self message:#argumentSignal. |
|
113 ArgumentSignal := ArgumentError. |
|
114 ArgumentSignal notifierString:'bad argument(s)'. |
|
115 |
|
116 "/ WrongNumberOfArgumentsSignal := WrongNumberOfArgumentsError. |
|
117 WrongNumberOfArgumentsError notifierString:'wrong number of argument(s)'. |
|
118 ] |
|
119 |
|
120 "Modified: 22.4.1996 / 16:33:38 / cg" |
|
121 ! ! |
|
122 |
|
123 !CompiledCode class methodsFor:'instance creation'! |
77 !CompiledCode class methodsFor:'instance creation'! |
124 |
78 |
125 new |
79 new |
126 "create a new method with an indirect literal array |
80 "create a new method with an indirect literal array |
127 stored in the first and only indexed instvar" |
81 stored in the first and only indexed instvar" |
151 "Created: 24.6.1996 / 17:20:13 / stefan" |
105 "Created: 24.6.1996 / 17:20:13 / stefan" |
152 "Modified: 25.6.1996 / 14:25:14 / stefan" |
106 "Modified: 25.6.1996 / 14:25:14 / stefan" |
153 ! ! |
107 ! ! |
154 |
108 |
155 !CompiledCode class methodsFor:'Signal constants'! |
109 !CompiledCode class methodsFor:'Signal constants'! |
156 |
|
157 argumentSignal |
|
158 "return the signal raised when something's wrong with the |
|
159 arguments" |
|
160 |
|
161 ^ ArgumentSignal |
|
162 ! |
|
163 |
|
164 executionErrorSignal |
|
165 "return the parent-signal of all execution errors" |
|
166 |
|
167 ^ ExecutionErrorSignal |
|
168 ! |
|
169 |
110 |
170 wongNumberOfArgumentsSignal |
111 wongNumberOfArgumentsSignal |
171 "return the signal raised when the number of arguments is wrong in a call" |
112 "return the signal raised when the number of arguments is wrong in a call" |
172 |
113 |
173 ^ WrongNumberOfArgumentsError |
114 ^ WrongNumberOfArgumentsError |
750 "{ Pragma: +optSpace }" |
691 "{ Pragma: +optSpace }" |
751 |
692 |
752 "this error is triggered, if a non-array is passed to |
693 "this error is triggered, if a non-array is passed to |
753 #valueWithReceiver:.. type of methods" |
694 #valueWithReceiver:.. type of methods" |
754 |
695 |
755 ^ ArgumentSignal |
696 ^ ArgumentError |
756 raiseRequestWith:self |
697 raiseRequestWith:self |
757 errorString:' - argumentArray is not an Array' |
698 errorString:' - argumentArray is not an Array' |
758 |
699 |
759 "Modified: 4.11.1996 / 22:46:52 / cg" |
700 "Modified: 4.11.1996 / 22:46:52 / cg" |
760 ! |
701 ! |
765 "this error is triggered, when a block/method is called with a bad literal |
706 "this error is triggered, when a block/method is called with a bad literal |
766 array (i.e. non-array) - this can only happen, if the |
707 array (i.e. non-array) - this can only happen, if the |
767 compiler is broken or someone played around with a blocks/methods |
708 compiler is broken or someone played around with a blocks/methods |
768 literal table or the GC is broken and corrupted it." |
709 literal table or the GC is broken and corrupted it." |
769 |
710 |
770 ^ BadLiteralsSignal raise. |
711 ^ BadLiteralsError raise. |
771 |
712 |
772 "Modified: 4.11.1996 / 22:46:55 / cg" |
713 "Modified: 4.11.1996 / 22:46:55 / cg" |
773 ! |
714 ! |
774 |
715 |
775 interpretWithReceiver:aReceiver |
716 interpretWithReceiver:aReceiver |
808 "this error is triggered when the interpreter tries to execute a |
749 "this error is triggered when the interpreter tries to execute a |
809 code object, where the byteCode is nonNil, but not a ByteArray. |
750 code object, where the byteCode is nonNil, but not a ByteArray. |
810 Can only happen when Compiler/runtime system is broken or |
751 Can only happen when Compiler/runtime system is broken or |
811 someone played around with a blocks/methods code." |
752 someone played around with a blocks/methods code." |
812 |
753 |
813 ^ InvalidByteCodeSignal raise. |
754 ^ InvalidByteCodeError raise. |
814 |
755 |
815 "Modified: 4.11.1996 / 22:46:59 / cg" |
756 "Modified: 4.11.1996 / 22:46:59 / cg" |
816 ! |
757 ! |
817 |
758 |
818 invalidInstruction |
759 invalidInstruction |
821 "this error is triggered when the bytecode-interpreter tries to |
762 "this error is triggered when the bytecode-interpreter tries to |
822 execute an invalid bytecode instruction. |
763 execute an invalid bytecode instruction. |
823 Can only happen when Compiler/runtime system is broken or |
764 Can only happen when Compiler/runtime system is broken or |
824 someone played around with a blocks/methods code." |
765 someone played around with a blocks/methods code." |
825 |
766 |
826 ^ InvalidInstructionSignal raise. |
767 ^ InvalidInstructionError raise. |
827 |
768 |
828 "Modified: 4.11.1996 / 22:47:03 / cg" |
769 "Modified: 4.11.1996 / 22:47:03 / cg" |
829 ! |
770 ! |
830 |
771 |
831 noByteCode |
772 noByteCode |
845 - an unloaded object modules method is called for. |
786 - an unloaded object modules method is called for. |
846 |
787 |
847 Only the first case is to be considered serious |
788 Only the first case is to be considered serious |
848 - it should not happen if the system is used correctly." |
789 - it should not happen if the system is used correctly." |
849 |
790 |
850 ^ NoByteCodeSignal raise. |
791 ^ NoByteCodeError raise. |
851 |
792 |
852 "Modified: 4.11.1996 / 22:47:07 / cg" |
793 "Modified: 4.11.1996 / 22:47:07 / cg" |
853 ! |
794 ! |
854 |
795 |
855 receiverNotBoolean:anObject |
796 receiverNotBoolean:anObject |
858 "this error is triggered when the bytecode-interpreter tries to |
799 "this error is triggered when the bytecode-interpreter tries to |
859 execute ifTrue:/ifFalse or whileTrue: - type of expressions where the |
800 execute ifTrue:/ifFalse or whileTrue: - type of expressions where the |
860 receiver is neither true nor false. |
801 receiver is neither true nor false. |
861 Machine compiled code does not detect this, and may behave undeterministec." |
802 Machine compiled code does not detect this, and may behave undeterministec." |
862 |
803 |
863 ^ NonBooleanReceiverSignal raise. |
804 ^ NonBooleanReceiverError raise. |
864 |
805 |
865 "Modified: 4.11.1996 / 22:47:11 / cg" |
806 "Modified: 4.11.1996 / 22:47:11 / cg" |
866 ! |
807 ! |
867 |
808 |
868 tooManyArguments |
809 tooManyArguments |
872 more arguments than supported by the interpreter. |
813 more arguments than supported by the interpreter. |
873 This can only happen, if the compiler has been changed without |
814 This can only happen, if the compiler has been changed without |
874 updating the VM, since the compiler checks for allowed number of |
815 updating the VM, since the compiler checks for allowed number of |
875 arguments." |
816 arguments." |
876 |
817 |
877 ^ ArgumentSignal |
818 ^ ArgumentError |
878 raiseRequestWith:self |
819 raiseRequestWith:self |
879 errorString:' - too many args in send' |
820 errorString:' - too many args in send' |
880 |
821 |
881 "Modified: 4.11.1996 / 22:47:14 / cg" |
822 "Modified: 4.11.1996 / 22:47:14 / cg" |
882 ! |
823 ! |