CompCode.st
changeset 159 514c749165c3
parent 131 39599c151f30
child 225 7c8e57cc5b13
equal deleted inserted replaced
158:be947d4e7fb2 159:514c749165c3
     1 "
     1 "
     2  COPYRIGHT (c) 1994 by Claus Gittinger
     2  COPYRIGHT (c) 1994 by Claus Gittinger
     3               All Rights Reserved
     3 	      All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
    11 "
    11 "
    12 
    12 
    13 ExecutableFunction subclass:#ExecutableCodeObject
    13 ExecutableFunction subclass:#ExecutableCodeObject
    14        instanceVariableNames:'byteCode literals'
    14        instanceVariableNames:'byteCode literals'
    15        classVariableNames:'NoByteCodeSignal InvalidByteCodeSignal
    15        classVariableNames:'NoByteCodeSignal InvalidByteCodeSignal
    16                            InvalidInstructionSignal BadLiteralsSignal
    16 			   InvalidInstructionSignal BadLiteralsSignal
    17                            NonBooleanReceiverSignal ArgumentSignal
    17 			   NonBooleanReceiverSignal ArgumentSignal'
    18                            AnyExecutionErrorSignal'
       
    19        poolDictionaries:''
    18        poolDictionaries:''
    20        category:'Kernel-Methods'
    19        category:'Kernel-Methods'
    21 !
    20 !
    22 
    21 
    23 ExecutableCodeObject comment:'
    22 ExecutableCodeObject comment:'
    24 COPYRIGHT (c) 1994 by Claus Gittinger
    23 COPYRIGHT (c) 1994 by Claus Gittinger
    25               All Rights Reserved
    24 	      All Rights Reserved
    26 
    25 
    27 $Header: /cvs/stx/stx/libbasic/Attic/CompCode.st,v 1.5 1994-08-22 12:20:34 claus Exp $
    26 $Header: /cvs/stx/stx/libbasic/Attic/CompCode.st,v 1.6 1994-10-10 00:25:41 claus Exp $
    28 '!
    27 '!
    29 
    28 
    30 !ExecutableCodeObject class methodsFor:'documentation'!
    29 !ExecutableCodeObject class methodsFor:'documentation'!
    31 
    30 
    32 copyright
    31 copyright
    33 "
    32 "
    34  COPYRIGHT (c) 1994 by Claus Gittinger
    33  COPYRIGHT (c) 1994 by Claus Gittinger
    35               All Rights Reserved
    34 	      All Rights Reserved
    36 
    35 
    37  This software is furnished under a license and may be used
    36  This software is furnished under a license and may be used
    38  only in accordance with the terms of that license and with the
    37  only in accordance with the terms of that license and with the
    39  inclusion of the above copyright notice.   This software may not
    38  inclusion of the above copyright notice.   This software may not
    40  be provided or otherwise made available to, or used by, any
    39  be provided or otherwise made available to, or used by, any
    43 "
    42 "
    44 !
    43 !
    45 
    44 
    46 version
    45 version
    47 "
    46 "
    48 $Header: /cvs/stx/stx/libbasic/Attic/CompCode.st,v 1.5 1994-08-22 12:20:34 claus Exp $
    47 $Header: /cvs/stx/stx/libbasic/Attic/CompCode.st,v 1.6 1994-10-10 00:25:41 claus Exp $
    49 "
    48 "
    50 !
    49 !
    51 
    50 
    52 documentation
    51 documentation
    53 "
    52 "
    54     This is an abstract class, to merge common attributes of Blocks and
    53     This is an abstract class, to merge common attributes of Blocks and
    55     Methods i.e. describe all objects consisting of compiled or interpreted code.
    54     Methods i.e. describe all objects consisting of compiled or interpreted code.
    56 
    55 
    57     Instance variables:
    56     Instance variables:
    58 
    57 
    59     byteCode    <ByteArray>       bytecode of home method if its an interpreted codeobject
    58     byteCode    <ByteArray>       bytecode if its an interpreted codeobject
    60     literals    <Array>           the blocks literal array
    59     literals    <Array>           the block/methods literal array
    61 
    60 
    62     NOTICE: layout known by runtime system and compiler - do not change
    61     NOTICE: layout known by runtime system and compiler - do not change
    63 "
    62 "
    64 ! !
    63 ! !
    65 
    64 
    66 !ExecutableCodeObject class methodsFor:'initialization'!
    65 !ExecutableCodeObject class methodsFor:'initialization'!
    67 
    66 
    68 initialize
    67 initialize
    69     NoByteCodeSignal isNil ifTrue:[
    68     NoByteCodeSignal isNil ifTrue:[
    70         NoByteCodeSignal := (Signal new) mayProceed:true.
    69 	ExecutableFunction initialize.
    71         NoByteCodeSignal notifierString:'nil byteCode in code-object - not executable'.
    70 
    72         InvalidByteCodeSignal := (Signal new) mayProceed:true.
    71 	NoByteCodeSignal := ExecutionErrorSignal newSignalMayProceed:true.
    73         InvalidByteCodeSignal notifierString:'invalid byteCode in code-object - not executable'.
    72 	NoByteCodeSignal nameClass:self message:#noByteCodeSignal.
    74         InvalidInstructionSignal := (Signal new) mayProceed:true.
    73 	NoByteCodeSignal notifierString:'nil byteCode in code-object - not executable'.
    75         InvalidInstructionSignal notifierString:'invalid instruction in code-object - not executable'.
    74 
    76         BadLiteralsSignal := (Signal new) mayProceed:true.
    75 	InvalidByteCodeSignal := ExecutionErrorSignal newSignalMayProceed:true.
    77         BadLiteralsSignal notifierString:'bad literal table in code-object - should not happen'.
    76 	InvalidByteCodeSignal nameClass:self message:#invalidByteCodeSignal.
    78         NonBooleanReceiverSignal := (Signal new) mayProceed:true.
    77 	InvalidByteCodeSignal notifierString:'invalid byteCode in code-object - not executable'.
    79         NonBooleanReceiverSignal notifierString:'if/while on non-boolean receiver'.
    78 
    80         ArgumentSignal := (Signal new) mayProceed:true.
    79 	InvalidInstructionSignal := ExecutionErrorSignal newSignalMayProceed:true.
    81         ArgumentSignal notifierString:'bad argument(s)'.
    80 	InvalidInstructionSignal nameClass:self message:#invalidInstructionSignal.
       
    81 	InvalidInstructionSignal notifierString:'invalid instruction in code-object - not executable'.
       
    82 
       
    83 	BadLiteralsSignal := ExecutionErrorSignal newSignalMayProceed:true.
       
    84 	BadLiteralsSignal nameClass:self message:#badLiteralsSignal.
       
    85 	BadLiteralsSignal notifierString:'bad literal table in code-object - should not happen'.
       
    86 
       
    87 	NonBooleanReceiverSignal := ExecutionErrorSignal newSignalMayProceed:true.
       
    88 	NonBooleanReceiverSignal nameClass:self message:#nonBooleanReceiverSignal.
       
    89 	NonBooleanReceiverSignal notifierString:'if/while on non-boolean receiver'.
       
    90 
       
    91 	ArgumentSignal := ExecutionErrorSignal newSignalMayProceed:true.
       
    92 	ArgumentSignal nameClass:self message:#argumentSignal.
       
    93 	ArgumentSignal notifierString:'bad argument(s)'.
    82     ]
    94     ]
    83 ! !
    95 ! !
    84 
    96 
    85 !ExecutableCodeObject class methodsFor:'signal access'!
    97 !ExecutableCodeObject class methodsFor:'signal access'!
    86 
    98 
    87 anyExecutionErrorSignal
    99 executionErrorSignal
    88     "return a signalSet with any execution signal.
   100     "return the parent-signal of all execution errors"
    89      This allows easy handling (catching) of execution errors
   101 
    90      in end-user applications."
   102     ^ ExecutionErrorSignal
    91 
       
    92     AnyExecutionErrorSignal isNil ifTrue:[
       
    93         AnyExecutionErrorSignal := SignalSet new.
       
    94         AnyExecutionErrorSignal add:ArgumentSignal;
       
    95                                 add:NonBooleanReceiverSignal;
       
    96                                 add:BadLiteralsSignal;
       
    97                                 add:InvalidInstructionSignal;
       
    98                                 add:InvalidByteCodeSignal;
       
    99                                 add:NoByteCodeSignal;
       
   100                                 add:InvalidCodeSignal.
       
   101     ].
       
   102     ^ AnyExecutionErrorSignal
       
   103 !
   103 !
   104 
   104 
   105 argumentSignal
   105 argumentSignal
   106     "return the signal raised when something's wrong with the
   106     "return the signal raised when something's wrong with the
   107      arguments"
   107      arguments"
   195     "this error is triggered, when a method/block tries to perform a send with
   195     "this error is triggered, when a method/block tries to perform a send with
   196      more arguments than supported by the interpreter. This can only happen,
   196      more arguments than supported by the interpreter. This can only happen,
   197      if the compiler has been changed without updating the VM."
   197      if the compiler has been changed without updating the VM."
   198 
   198 
   199     ^ ArgumentSignal
   199     ^ ArgumentSignal
   200         raiseRequestWith:self
   200 	raiseRequestWith:self
   201         errorString:'too many args in send'
   201 	errorString:'too many args in send'
   202 !
   202 !
   203 
   203 
   204 badArgumentArray
   204 badArgumentArray
   205     "this error is triggered, if a non array is passed to #perform:with:
   205     "this error is triggered, if a non array is passed to #perform:with:
   206      or #value:with:."
   206      or #value:with:."
   207 
   207 
   208     ^ ArgumentSignal
   208     ^ ArgumentSignal
   209         raiseRequestWith:self
   209 	raiseRequestWith:self
   210         errorString:'argumentArray must be an Array'
   210 	errorString:'argumentArray must be an Array'
   211 ! !
   211 ! !