Context.st
changeset 18289 9d906f0b71eb
parent 18280 5710a93b9ffa
child 18291 610fcf903bed
equal deleted inserted replaced
18288:1232fc152674 18289:9d906f0b71eb
   344 argumentCount
   344 argumentCount
   345     "ANSI alias for numArgs: return the number of arguments to the Block/Method"
   345     "ANSI alias for numArgs: return the number of arguments to the Block/Method"
   346 
   346 
   347 %{  /* NOCONTEXT */
   347 %{  /* NOCONTEXT */
   348 #ifdef __SCHTEAM__
   348 #ifdef __SCHTEAM__
   349     return context._RETURN( STInteger._new( ((STContinuation)self).numStArgs() ) );
   349     return context._RETURN( STInteger._new( self.asSTContinuation().numStArgs() ) );
   350 #else
   350 #else
   351     RETURN ( __mkSmallInteger( (__intVal(__INST(flags)) >> __NARG_SHIFT) & __NARG_MASK) );
   351     RETURN ( __mkSmallInteger( (__intVal(__INST(flags)) >> __NARG_SHIFT) & __NARG_MASK) );
   352 #endif
   352 #endif
   353 %}
   353 %}
   354 !
   354 !
   395 #ifdef __SCHTEAM__
   395 #ifdef __SCHTEAM__
   396     {
   396     {
   397 	int idx = context.stArg(0).intValue("[instVarAt:]");
   397 	int idx = context.stArg(0).intValue("[instVarAt:]");
   398 
   398 
   399 	if (idx == I_sender) {
   399 	if (idx == I_sender) {
   400 	    return context._RETURN( ((STContinuation)self).caller() );
   400 	    return context._RETURN( self.asSTContinuation().caller() );
   401 	}
   401 	}
   402 	if (idx == I_retvalTemp) {
   402 	if (idx == I_retvalTemp) {
   403 	    return context._RETURN( Nil );
   403 	    return context._RETURN( Nil );
   404 	}
   404 	}
   405 	if (idx == I_handle) {
   405 	if (idx == I_handle) {
   669 numArgs
   669 numArgs
   670     "return the number of arguments to the Block/Method"
   670     "return the number of arguments to the Block/Method"
   671 
   671 
   672 %{  /* NOCONTEXT */
   672 %{  /* NOCONTEXT */
   673 #ifdef __SCHTEAM__
   673 #ifdef __SCHTEAM__
   674     return context._RETURN(STInteger._new(self.numStArgs()));
   674     return context._RETURN(STInteger._new(self.asSTContinuation().numStArgs()));
   675 #else
   675 #else
   676     RETURN ( __mkSmallInteger( (__intVal(__INST(flags)) >> __NARG_SHIFT) & __NARG_MASK) );
   676     RETURN ( __mkSmallInteger( (__intVal(__INST(flags)) >> __NARG_SHIFT) & __NARG_MASK) );
   677 #endif
   677 #endif
   678 %}
   678 %}
   679 !
   679 !
   691 numVars
   691 numVars
   692     "return the number of local variables of the Block/Method"
   692     "return the number of local variables of the Block/Method"
   693 
   693 
   694 %{  /* NOCONTEXT */
   694 %{  /* NOCONTEXT */
   695 #ifdef __SCHTEAM__
   695 #ifdef __SCHTEAM__
   696     return context._RETURN(STInteger._new(self.numLocals(context)));
   696     return context._RETURN(STInteger._new(self.asSTContinuation().numLocals(context)));
   697 #else
   697 #else
   698     RETURN ( __mkSmallInteger( (__intVal(__INST(flags)) >> __NVAR_SHIFT) & __NVAR_MASK) );
   698     RETURN ( __mkSmallInteger( (__intVal(__INST(flags)) >> __NVAR_SHIFT) & __NVAR_MASK) );
   699 #endif
   699 #endif
   700 %}
   700 %}
   701 !
   701 !
   721 
   721 
   722 receiver
   722 receiver
   723     "return the receiver of the context"
   723     "return the receiver of the context"
   724 %{  /* NOCONTEXT */
   724 %{  /* NOCONTEXT */
   725 #ifdef __SCHTEAM__
   725 #ifdef __SCHTEAM__
   726     return context._RETURN( self.stSelf(context) );
   726     return context._RETURN( self.asSTContinuation().stSelf(context) );
   727 #endif
   727 #endif
   728 %}.
   728 %}.
   729     ^ receiver
   729     ^ receiver
   730 !
   730 !
   731 
   731 
   758 !
   758 !
   759 
   759 
   760 selector
   760 selector
   761     "return the selector of the method for which the context was created"
   761     "return the selector of the method for which the context was created"
   762 
   762 
   763 %{  /* NOCONTEXT */
       
   764 #ifdef __SCHTEAM__
       
   765     return context._RETURN(self.selector());
       
   766     /* NOTREACHED */
       
   767 #endif
       
   768 %}.
       
   769     ^ selector
   763     ^ selector
   770 !
   764 !
   771 
   765 
   772 sender
   766 sender
   773     "return the sender of the context"
   767     "return the sender of the context"
   774 
   768 
   775 %{  /* NOCONTEXT */
   769 %{  /* NOCONTEXT */
   776 #ifdef __SCHTEAM__
   770 #ifdef __SCHTEAM__
   777     return context._RETURN(self.sender());
   771     return context._RETURN(self.asSTContinuation().sender());
   778     /* NOTREACHED */
   772     /* NOTREACHED */
   779 #else
   773 #else
   780     OBJ theContext;
   774     OBJ theContext;
   781 
   775 
   782     theContext = __INST(sender_);
   776     theContext = __INST(sender_);
   815      directly accessed by smalltalk code. The reason is that the sender field
   809      directly accessed by smalltalk code. The reason is that the sender field
   816      is lazily filled in by the VM, in the sender-accessor, and is usually
   810      is lazily filled in by the VM, in the sender-accessor, and is usually
   817      invalid until needed."
   811      invalid until needed."
   818 
   812 
   819 %{  /* NOCONTEXT */
   813 %{  /* NOCONTEXT */
   820 #ifdef __SCHTEAM__
       
   821     ERROR("unimplemented");
       
   822 #else
       
   823     if ( __INST(sender_) == nil ) {
   814     if ( __INST(sender_) == nil ) {
   824 	RETURN (true);
   815 	RETURN (true);
   825     }
   816     }
   826     RETURN (false);
   817     RETURN (false);
   827 #endif
       
   828 %}.
   818 %}.
       
   819     ^ self sender isNil
   829 !
   820 !
   830 
   821 
   831 setLineNumber:aNumber
   822 setLineNumber:aNumber
   832     "private entry for uncompiledCodeObject ..."
   823     "private entry for uncompiledCodeObject ..."
   833 
   824 
  2024     |receiverClassName|
  2015     |receiverClassName|
  2025 
  2016 
  2026 %{
  2017 %{
  2027 #ifdef __SCHTEAM__
  2018 #ifdef __SCHTEAM__
  2028     {
  2019     {
  2029 	STObject rcvr = self.stSelf(context);
  2020 	STObject rcvr = self.asSTContinuation().stSelf(context);
  2030 	STClass cls = rcvr.clazz();
  2021 	STClass cls = rcvr.clazz();
  2031 
  2022 
  2032 	return context._RETURN( cls.className() );
  2023 	return context._RETURN( cls.className() );
  2033     }
  2024     }
  2034     /* NOT REACHED */
  2025     /* NOT REACHED */
  2055      The VM needs this to know that some special action is to be performed with
  2046      The VM needs this to know that some special action is to be performed with
  2056      this context - a highly internal mechanism and not for public use."
  2047      this context - a highly internal mechanism and not for public use."
  2057 
  2048 
  2058 %{  /* NOCONTEXT */
  2049 %{  /* NOCONTEXT */
  2059 #ifdef __SCHTEAM__
  2050 #ifdef __SCHTEAM__
  2060     context._RETURN (self.isMarkedForUnwind() ? STObject.True : STObject.False);
  2051     return context._RETURN (self.asSTContinuation().isMarkedForUnwind() ? STObject.True : STObject.False);
  2061 #else
  2052 #else
  2062     RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__UNWIND_MARK)) ? true : false );
  2053     RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__UNWIND_MARK)) ? true : false );
  2063 #endif
  2054 #endif
  2064 %}
  2055 %}
  2065     "
  2056     "
  2072      The VM needs this to know that some special action is to be performed with
  2063      The VM needs this to know that some special action is to be performed with
  2073      this context - a highly internal mechanism and not for public use."
  2064      this context - a highly internal mechanism and not for public use."
  2074 
  2065 
  2075 %{  /* NOCONTEXT */
  2066 %{  /* NOCONTEXT */
  2076 #ifdef __SCHTEAM__
  2067 #ifdef __SCHTEAM__
  2077     self.markForHandle();
  2068     self.asSTContinuation().markForHandle();
  2078 #else
  2069 #else
  2079      __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__HANDLE_MARK));
  2070      __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__HANDLE_MARK));
  2080 #endif
  2071 #endif
  2081 %}
  2072 %}
  2082 
  2073 
  2088      The VM needs this to know that some special action is to be performed with
  2079      The VM needs this to know that some special action is to be performed with
  2089      this context upon return - a highly internal mechanism and not for public use."
  2080      this context upon return - a highly internal mechanism and not for public use."
  2090 
  2081 
  2091 %{  /* NOCONTEXT */
  2082 %{  /* NOCONTEXT */
  2092 #ifdef __SCHTEAM__
  2083 #ifdef __SCHTEAM__
  2093     self.markForInterrupt();
  2084     self.asSTContinuation().markForInterrupt();
  2094 #else
  2085 #else
  2095      __markInterrupted(__ContextInstPtr(self));
  2086      __markInterrupted(__ContextInstPtr(self));
  2096 #endif
  2087 #endif
  2097 %}
  2088 %}
  2098 !
  2089 !
  2103      is unwound. This is used by the debugger for faster single-stepping;
  2094      is unwound. This is used by the debugger for faster single-stepping;
  2104      - a highly internal mechanism and not for public use."
  2095      - a highly internal mechanism and not for public use."
  2105 
  2096 
  2106 %{  /* NOCONTEXT */
  2097 %{  /* NOCONTEXT */
  2107 #ifdef __SCHTEAM__
  2098 #ifdef __SCHTEAM__
  2108     self.markForInterruptOnUnwind();
  2099     self.asSTContinuation().markForInterruptOnUnwind();
  2109 #else
  2100 #else
  2110      __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__IRQ_ON_UNWIND));
  2101      __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__IRQ_ON_UNWIND));
  2111 #endif
  2102 #endif
  2112 %}
  2103 %}
  2113 !
  2104 !
  2117      The VM needs this to know that some special action is to be performed with
  2108      The VM needs this to know that some special action is to be performed with
  2118      this context - a highly internal mechanism and not for public use."
  2109      this context - a highly internal mechanism and not for public use."
  2119 
  2110 
  2120 %{  /* NOCONTEXT */
  2111 %{  /* NOCONTEXT */
  2121 #ifdef __SCHTEAM__
  2112 #ifdef __SCHTEAM__
  2122     self.markForRaise();
  2113     self.asSTContinuation().markForRaise();
  2123 #else
  2114 #else
  2124      __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__RAISE_MARK));
  2115      __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__RAISE_MARK));
  2125 #endif
  2116 #endif
  2126 %}
  2117 %}
  2127 
  2118 
  2133      The VM needs this to know that some special action is to be performed with
  2124      The VM needs this to know that some special action is to be performed with
  2134      this context - a highly internal mechanism and not for public use."
  2125      this context - a highly internal mechanism and not for public use."
  2135 
  2126 
  2136 %{  /* NOCONTEXT */
  2127 %{  /* NOCONTEXT */
  2137 #ifdef __SCHTEAM__
  2128 #ifdef __SCHTEAM__
  2138     self.markForUnwind();
  2129     self.asSTContinuation().markForUnwind();
  2139 #else
  2130 #else
  2140      __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__UNWIND_MARK));
  2131      __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__UNWIND_MARK));
  2141 #endif
  2132 #endif
  2142 %}
  2133 %}
  2143 
  2134 
  2169      The VM needs this to know that some special action is to be performed with
  2160      The VM needs this to know that some special action is to be performed with
  2170      this context - a highly internal mechanism and not for public use."
  2161      this context - a highly internal mechanism and not for public use."
  2171 
  2162 
  2172 %{  /* NOCONTEXT */
  2163 %{  /* NOCONTEXT */
  2173 #ifdef __SCHTEAM__
  2164 #ifdef __SCHTEAM__
  2174     self.unmarkForUnwind();
  2165     self.asSTContinuation().unmarkForUnwind();
  2175 #else
  2166 #else
  2176     __INST(flags) = (OBJ)((INT)__INST(flags) & ~__MASKSMALLINT(__UNWIND_MARK));
  2167     __INST(flags) = (OBJ)((INT)__INST(flags) & ~__MASKSMALLINT(__UNWIND_MARK));
  2177 #endif
  2168 #endif
  2178 %}
  2169 %}
  2179 ! !
  2170 ! !
  2203     "/  although they aren't really - this is expert knowledge, no need to understand that ...)
  2194     "/  although they aren't really - this is expert knowledge, no need to understand that ...)
  2204 
  2195 
  2205 %{  /* NOCONTEXT */
  2196 %{  /* NOCONTEXT */
  2206 #ifdef __SCHTEAM__
  2197 #ifdef __SCHTEAM__
  2207     {
  2198     {
  2208 	STObject caller = self.sender();
  2199 	STObject caller = self.asSTContinuation().sender();
  2209 
  2200 
  2210 	while (caller != Nil) {
  2201 	while (caller != Nil) {
  2211 	    if (caller.isExceptionalSmalltalkContext()) {
  2202 	    if (caller.isExceptionalSmalltalkContext()) {
  2212 		return context._RETURN(caller);
  2203 		return context._RETURN(caller);
  2213 	    }
  2204 	    }
  2601      starting with this context, find the one below
  2592      starting with this context, find the one below
  2602      (i.e. the one that I have called) and return from it.
  2593      (i.e. the one that I have called) and return from it.
  2603     "
  2594     "
  2604 %{
  2595 %{
  2605 #ifdef __SCHTEAM__
  2596 #ifdef __SCHTEAM__
  2606     return context._RETURN( STObject.True );
  2597     return context._RETURN_true();
  2607 #else
  2598 #else
  2608     OBJ sndr;
  2599     OBJ sndr;
  2609 
  2600 
  2610     theContext = __thisContext;
  2601     theContext = __thisContext;
  2611     while (theContext != nil) {
  2602     while (theContext != nil) {
  2638      invocation and makes overall execution faster, the system classes
  2629      invocation and makes overall execution faster, the system classes
  2639      are all compiled with this flag turned on."
  2630      are all compiled with this flag turned on."
  2640 
  2631 
  2641 %{  /* NOCONTEXT */
  2632 %{  /* NOCONTEXT */
  2642 #ifdef __SCHTEAM__
  2633 #ifdef __SCHTEAM__
  2643     return context._RETURN( STObject.True );
  2634     return context._RETURN_true();
  2644 #else
  2635 #else
  2645     RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(__CANNOT_RETURN)) ? false : true );
  2636     RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(__CANNOT_RETURN)) ? false : true );
  2646 #endif
  2637 #endif
  2647 %}.
  2638 %}.
  2648     ^ true
  2639     ^ true
  2858 ! !
  2849 ! !
  2859 
  2850 
  2860 !Context class methodsFor:'documentation'!
  2851 !Context class methodsFor:'documentation'!
  2861 
  2852 
  2862 version
  2853 version
  2863     ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.217 2015-04-24 08:19:46 cg Exp $'
  2854     ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.218 2015-04-26 11:30:22 cg Exp $'
  2864 !
  2855 !
  2865 
  2856 
  2866 version_CVS
  2857 version_CVS
  2867     ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.217 2015-04-24 08:19:46 cg Exp $'
  2858     ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.218 2015-04-26 11:30:22 cg Exp $'
  2868 !
  2859 !
  2869 
  2860 
  2870 version_HG
  2861 version_HG
  2871 
  2862 
  2872     ^ '$Changeset: <not expanded> $'
  2863     ^ '$Changeset: <not expanded> $'