ExecutableFunction.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
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 Object subclass:#ExecutableFunction
    13 Object subclass:#ExecutableFunction
    14        instanceVariableNames:'code* flags'
    14        instanceVariableNames:'code* flags'
    15        classVariableNames:'InvalidCodeSignal'
    15        classVariableNames:'ExecutionErrorSignal InvalidCodeSignal'
    16        poolDictionaries:''
    16        poolDictionaries:''
    17        category:'Kernel-Methods'
    17        category:'Kernel-Methods'
    18 !
    18 !
    19 
    19 
    20 ExecutableFunction comment:'
    20 ExecutableFunction comment:'
    21 COPYRIGHT (c) 1994 by Claus Gittinger
    21 COPYRIGHT (c) 1994 by Claus Gittinger
    22               All Rights Reserved
    22 	      All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libbasic/ExecutableFunction.st,v 1.5 1994-08-22 12:20:41 claus Exp $
    24 $Header: /cvs/stx/stx/libbasic/ExecutableFunction.st,v 1.6 1994-10-10 00:25:44 claus Exp $
    25 '!
    25 '!
    26 
    26 
    27 !ExecutableFunction class methodsFor:'documentation'!
    27 !ExecutableFunction class methodsFor:'documentation'!
    28 
    28 
    29 copyright
    29 copyright
    30 "
    30 "
    31  COPYRIGHT (c) 1994 by Claus Gittinger
    31  COPYRIGHT (c) 1994 by Claus Gittinger
    32               All Rights Reserved
    32 	      All Rights Reserved
    33 
    33 
    34  This software is furnished under a license and may be used
    34  This software is furnished under a license and may be used
    35  only in accordance with the terms of that license and with the
    35  only in accordance with the terms of that license and with the
    36  inclusion of the above copyright notice.   This software may not
    36  inclusion of the above copyright notice.   This software may not
    37  be provided or otherwise made available to, or used by, any
    37  be provided or otherwise made available to, or used by, any
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 version
    43 version
    44 "
    44 "
    45 $Header: /cvs/stx/stx/libbasic/ExecutableFunction.st,v 1.5 1994-08-22 12:20:41 claus Exp $
    45 $Header: /cvs/stx/stx/libbasic/ExecutableFunction.st,v 1.6 1994-10-10 00:25:44 claus Exp $
    46 "
    46 "
    47 !
    47 !
    48 
    48 
    49 documentation
    49 documentation
    50 "
    50 "
    52     executable code objects; i.e. non-ST functions, Blocks and Methods.
    52     executable code objects; i.e. non-ST functions, Blocks and Methods.
    53 
    53 
    54     Instance variables:
    54     Instance variables:
    55 
    55 
    56     code        <not_an_object>   the function pointer to the machine code.
    56     code        <not_an_object>   the function pointer to the machine code.
    57                                   Not accessable from smalltalk code.
    57 				  Not accessable from smalltalk code.
    58 
    58 
    59     flags       <SmallInteger>    special flag bits coded in a number
    59     flags       <SmallInteger>    special flag bits coded in a number
    60 
    60 
    61     NOTICE: layout known by runtime system and compiler - do not change
    61     NOTICE: layout known by runtime system and compiler - do not change
    62 "
    62 "
    72 
    72 
    73 !ExecutableFunction class methodsFor:'initialization'!
    73 !ExecutableFunction class methodsFor:'initialization'!
    74 
    74 
    75 initialize
    75 initialize
    76     InvalidCodeSignal isNil ifTrue:[
    76     InvalidCodeSignal isNil ifTrue:[
    77         InvalidCodeSignal := (Signal new) mayProceed:true.
    77 	Object initialize.
    78         InvalidCodeSignal notifierString:'invalid code-object - not executable'.
    78 
       
    79 	ExecutionErrorSignal := ErrorSignal newSignalMayProceed:true.
       
    80 	ExecutionErrorSignal nameClass:self message:#executionErrorSignal.
       
    81 	ExecutionErrorSignal notifierString:'execution error'.
       
    82 
       
    83 	InvalidCodeSignal := ExecutionErrorSignal newSignalMayProceed:true.
       
    84 	InvalidCodeSignal nameClass:self message:#invalidCodeSignal.
       
    85 	InvalidCodeSignal notifierString:'invalid code-object - not executable'.
    79     ]
    86     ]
       
    87 ! !
       
    88 
       
    89 !ExecutableFunction class methodsFor:'signal access'!
       
    90 
       
    91 executionErrorSignal
       
    92     "return the parent-signal of all execution errors"
       
    93 
       
    94     ^ ExecutionErrorSignal
    80 ! !
    95 ! !
    81 
    96 
    82 !ExecutableFunction methodsFor:'accessing'!
    97 !ExecutableFunction methodsFor:'accessing'!
    83 
    98 
    84 instVarAt:index
    99 instVarAt:index
   100      Therefore an integer representing the code-address is returned"
   115      Therefore an integer representing the code-address is returned"
   101 
   116 
   102 %{  /* NOCONTEXT */
   117 %{  /* NOCONTEXT */
   103 
   118 
   104     if (_INST(code_) != nil) {
   119     if (_INST(code_) != nil) {
   105         RETURN ( _MKSMALLINT((int)(_INST(code_))) )
   120 	RETURN ( _MKSMALLINT((int)(_INST(code_))) )
   106     }
   121     }
   107 %}
   122 %}
   108 .
   123 .
   109     ^ nil
   124     ^ nil
   110 ! !
   125 ! !
   119      This method is for compiler support and very special cases (debugging) only
   134      This method is for compiler support and very special cases (debugging) only
   120      - do not use"
   135      - do not use"
   121 
   136 
   122 %{  /* NOCONTEXT */
   137 %{  /* NOCONTEXT */
   123     if (_isSmallInteger(anAddress))
   138     if (_isSmallInteger(anAddress))
   124         _INST(code_) = (OBJ)(_intVal(anAddress));
   139 	_INST(code_) = (OBJ)(_intVal(anAddress));
   125     else
   140     else
   126         _INST(code_) = (OBJ)0;
   141 	_INST(code_) = (OBJ)0;
   127 %}
   142 %}
   128 !
   143 !
   129 
   144 
   130 dynamic:aBoolean
   145 dynamic:aBoolean
   131     "set the flag bit stating that the machine code was created
   146     "set the flag bit stating that the machine code was created
   135 %{  /* NOCONTEXT */
   150 %{  /* NOCONTEXT */
   136     int newFlags = _intVal(_INST(flags));
   151     int newFlags = _intVal(_INST(flags));
   137 
   152 
   138     /* made this a primitive to get define in stc.h */
   153     /* made this a primitive to get define in stc.h */
   139     if (aBoolean == true)
   154     if (aBoolean == true)
   140         newFlags |= F_DYNAMIC;
   155 	newFlags |= F_DYNAMIC;
   141     else
   156     else
   142         newFlags &= ~F_DYNAMIC;
   157 	newFlags &= ~F_DYNAMIC;
   143 
   158 
   144     _INST(flags) = _MKSMALLINT(newFlags);
   159     _INST(flags) = _MKSMALLINT(newFlags);
   145 %}
   160 %}
   146 ! !
   161 ! !
   147 
   162