--- a/Context.st Tue Aug 19 16:30:21 2003 +0200
+++ b/Context.st Tue Aug 19 18:01:10 2003 +0200
@@ -1833,6 +1833,104 @@
!Context methodsFor:'special accessing'!
+argAndVarNames
+ "helper: given a context, return a collection of arg&var names"
+
+ |homeContext method block numArgs numVars m src
+ sel isDoIt blocksLineNr extractFromBlock|
+
+ numArgs := self numArgs.
+ numVars := self numVars.
+ (numArgs == 0 and:[numVars == 0]) ifTrue:[^ #()].
+
+ homeContext := self methodHome.
+ sel := homeContext selector.
+ method := homeContext method.
+
+ extractFromBlock :=
+ [
+ |blockNode argNames varNames vars args|
+
+ blockNode := Compiler
+ blockAtLine:blocksLineNr
+ in:m
+ orSource:src
+ numArgs:numArgs
+ numVars:numVars.
+
+ blockNode notNil ifTrue:[
+ argNames := #().
+ varNames := #().
+
+ numArgs > 0 ifTrue:[
+ vars := blockNode arguments.
+ vars size > 0 ifTrue:[
+ argNames := vars collect:[:var | var name]
+ ]
+ ].
+ numVars > 0 ifTrue:[
+ vars := blockNode variables.
+ vars size > 0 ifTrue:[
+ varNames := vars collect:[:var | var name].
+ ]
+ ].
+ ^ argNames , varNames
+ ].
+ ].
+
+ "/ #doIt needs special handling below
+ isDoIt := (sel == #'doIt') or:[sel == #'doIt:'].
+ self isBlockContext ifFalse:[
+ isDoIt ifTrue:[
+ method notNil ifTrue:[
+ "/ special for #doIt
+ m := nil.
+ src := ('[' , method source , '\]') withCRs.
+ blocksLineNr := self lineNumber.
+ extractFromBlock value.
+ ]
+ ].
+
+ method notNil ifTrue:[
+ ^ method methodArgAndVarNames.
+ ].
+ ^ #()
+ ].
+
+ method notNil ifTrue:[
+ isDoIt ifTrue:[
+ "/ special for #doIt
+ "/ my source is found in the method.
+ m := nil.
+ src := ('[' , method source , '\]') withCRs.
+ ] ifFalse:[
+ m := method.
+ src := nil.
+ ].
+ blocksLineNr := self lineNumber.
+ extractFromBlock value.
+ ].
+
+ blocksLineNr isNil ifTrue:[
+ self isBlockContext ifTrue:[
+ (self sender notNil
+ and:[self sender receiver isBlock
+ and:[self sender selector startsWith:'value']])
+ ifTrue:[
+ block := self sender receiver.
+ src := block source.
+ src isNil ifTrue:[
+self halt.
+ ].
+ blocksLineNr := 1.
+ extractFromBlock value.
+ ].
+ ].
+ ].
+
+ ^ #()
+!
+
canResume
"return true, if the receiver allows to be resumed.
Due to the implementation, this requires that the context which
@@ -2011,7 +2109,7 @@
!Context class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.118 2003-06-02 09:58:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.119 2003-08-19 16:01:10 penk Exp $'
! !
Context initialize!