-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
voyage server blocks need to be able to customize the server-side met…
…hod for evaluating block with variable bindings ... make it so
- Loading branch information
1 parent
40cfa6f
commit 391880e
Showing
4 changed files
with
44 additions
and
37 deletions.
There are no files selected for viewing
39 changes: 4 additions & 35 deletions
39
...-Minimal-Client-Core.package/TDMinimalClient.class/instance/onServerDo.serializeBlock..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,6 @@ | ||
server blocks | ||
onServerDo: aBlock serializeBlock: serializeBlock | ||
| serverSource variableBindings stonString blockAst blockScopes blockScope outerContext blockContext | | ||
aBlock numArgs > 0 | ||
ifTrue: [ self error: 'only zeroArg blocks may be executed on the server' ]. | ||
outerContext := aBlock outerContext. | ||
outerContext hasInstVarRef | ||
ifTrue: [ self error: 'cannot reference instance variables in server block' ]. | ||
blockContext := aBlock asContext. | ||
blockAst := aBlock sourceNode. | ||
blockScopes := (OCScopesCollector new visitNode: blockAst) scopes. | ||
blockScope := blockScopes at: 1. | ||
variableBindings := Dictionary new. | ||
blockScope copiedVars | ||
do: [ :tempVar | | ||
| val tempName index | | ||
tempVar isStoringTempVector | ||
ifTrue: [ tempVar tempVectorForTempStoringIt | ||
do: [ :tempVectorVars | | ||
tempName := tempVectorVars name. | ||
index := aBlock asContext tempNames indexOf: tempName. | ||
index > 0 | ||
ifTrue: [ val := aBlock asContext namedTempAt: index. | ||
variableBindings at: tempName put: (serializeBlock value: val) ] ] ] | ||
ifFalse: [ tempName := tempVar name. | ||
index := outerContext tempNames indexOf: tempName. | ||
index > 0 | ||
ifTrue: [ val := outerContext namedTempAt: index. | ||
variableBindings at: tempName put: (serializeBlock value: val) ] ] ]. | ||
serverSource := aBlock sourceNode body formattedCode. | ||
stonString := self session | ||
send: #evaluateSTONSmalltalk:variableBindings: | ||
to: todeServerOopType | ||
withArgs: | ||
{serverSource. | ||
(self objectSerializer toString: variableBindings)}. | ||
^ self objectSerializer fromString: stonString | ||
^ self | ||
onServerDo: aBlock | ||
serializeBlock: serializeBlock | ||
serverSelector: #evaluateSTONSmalltalk:variableBindings: |
37 changes: 37 additions & 0 deletions
37
...-Core.package/TDMinimalClient.class/instance/onServerDo.serializeBlock.serverSelector..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
server blocks | ||
onServerDo: aBlock serializeBlock: serializeBlock serverSelector: serverSelector | ||
| serverSource variableBindings stonString blockAst blockScopes blockScope outerContext blockContext | | ||
aBlock numArgs > 0 | ||
ifTrue: [ self error: 'only zeroArg blocks may be executed on the server' ]. | ||
outerContext := aBlock outerContext. | ||
outerContext hasInstVarRef | ||
ifTrue: [ self error: 'cannot reference instance variables in server block' ]. | ||
blockContext := aBlock asContext. | ||
blockAst := aBlock sourceNode. | ||
blockScopes := (OCScopesCollector new visitNode: blockAst) scopes. | ||
blockScope := blockScopes at: 1. | ||
variableBindings := Dictionary new. | ||
blockScope copiedVars | ||
do: [ :tempVar | | ||
| val tempName index | | ||
tempVar isStoringTempVector | ||
ifTrue: [ tempVar tempVectorForTempStoringIt | ||
do: [ :tempVectorVars | | ||
tempName := tempVectorVars name. | ||
index := aBlock asContext tempNames indexOf: tempName. | ||
index > 0 | ||
ifTrue: [ val := aBlock asContext namedTempAt: index. | ||
variableBindings at: tempName put: (serializeBlock value: val) ] ] ] | ||
ifFalse: [ tempName := tempVar name. | ||
index := outerContext tempNames indexOf: tempName. | ||
index > 0 | ||
ifTrue: [ val := outerContext namedTempAt: index. | ||
variableBindings at: tempName put: (serializeBlock value: val) ] ] ]. | ||
serverSource := aBlock sourceNode body formattedCode. | ||
stonString := self session | ||
send: serverSelector | ||
to: todeServerOopType | ||
withArgs: | ||
{serverSource. | ||
(self objectSerializer toString: variableBindings)}. | ||
^ self objectSerializer fromString: stonString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
repository/Tode-Minimal-Client-Core.package/monticello.meta/version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters