-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
508 additions
and
4 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/README.md
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 @@ | ||
I choose a more pragmatic approach to sandboxing by using an allow-list of methods that are executed outside of the sandbox. This makes practical assumptions about not changing certain objects to improve the performance for certain queries significantly until the sandboxed code modifies these objects. In some cases, my pre-checks might be too weak, and side effects of the sandboxed code might not be visible to the sandboxed code itself. |
9 changes: 9 additions & 0 deletions
9
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/class/evaluate..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,9 @@ | ||
evaluating | ||
evaluate: aBlock | ||
"Evaluate aBlock in a new sandbox instance and answer the result, isolating it from the rest of the image. | ||
Example: | ||
PragmaticSandbox evaluate: [World extent: 0 @ 0; bounds]. | ||
" | ||
|
||
^ super evaluate: aBlock |
11 changes: 11 additions & 0 deletions
11
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/class/evaluate.ifFailed..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,11 @@ | ||
evaluating | ||
evaluate: aBlock ifFailed: failBlock | ||
"Evaluate aBlock in a new sandbox instance and answer the result, isolating it from the rest of the image. If aBlock signals a failure, evaluate failBlock with that failure. | ||
Example: | ||
PragmaticSandbox evaluate: [1 / 0] ifFailed: [:ex | Transcript showln: ex description]. | ||
" | ||
|
||
^ self new | ||
evaluate: aBlock | ||
ifFailed: failBlock |
15 changes: 15 additions & 0 deletions
15
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/class/evaluate.on.do..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,15 @@ | ||
evaluating | ||
evaluate: aBlock on: exceptionHandler do: exceptionBlock | ||
"Evaluate aBlock in a new sandbox instance and answer the result, isolating it from the rest of the image. If aBlock signals an exception that can handled by the exceptionHandler, evaluate exceptionBlock with it. NOTE: Unhandled errors raised by aBlock will bubble up along the sender stack, but still, all handling is simulated in the sandbox until the exception will have been resumed. Depending on the configuration of the sandbox and your image, this can mean that even the eventual pop-up of the debugger will be simulated and thus invisible to you! Thus make sure to pass all relevant exceptions with this message. | ||
Example: | ||
PragmaticSandbox evaluate: [1 / 0] on: ZeroDivide do: [:ex | Transcript showln: ex description]. | ||
""Use with CAUTION and check your image via the ProcessBrowser afterwards"" | ||
PragmaticSandbox evaluate: [self halt] on: ZeroDivide do: [:ex | Transcript showln: ex description]. | ||
" | ||
|
||
^ self new | ||
evaluate: aBlock | ||
on: exceptionHandler | ||
do: exceptionBlock |
4 changes: 4 additions & 0 deletions
4
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/class/fromMemory..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,4 @@ | ||
instance creation | ||
fromMemory: aSandboxMemory | ||
|
||
^ self new importMemory: aSandboxMemory |
4 changes: 4 additions & 0 deletions
4
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/addObject..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,4 @@ | ||
sandbox | ||
addObject: anObject | ||
|
||
^ self nextSimulator addObject: anObject |
15 changes: 15 additions & 0 deletions
15
...imulationStudio-Sandbox.package/PragmaticSandbox.class/instance/addPragmaticClassesTo..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,15 @@ | ||
initialize-release | ||
addPragmaticClassesTo: pragmaticClasses | ||
|
||
(Pragma allNamed: #pragmaticClass: from: self class to: thisContext methodClass) | ||
do: [:pragma | | ||
| className| | ||
className := pragma argumentAt: 1. | ||
(Smalltalk classNamed: className) | ||
ifNil: [self warn: ('pragmatic class not found: {1}' format: {className})] | ||
ifNotNil: [:class | | ||
pragmaticClasses | ||
at: class | ||
ifPresent: [self warn: ('pragmatic class overridden: {1}' format: {class})]; | ||
at: class | ||
put: pragma selector]]. |
20 changes: 20 additions & 0 deletions
20
...imulationStudio-Sandbox.package/PragmaticSandbox.class/instance/addPragmaticMethodsTo..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,20 @@ | ||
initialize-release | ||
addPragmaticMethodsTo: pragmaticMethods | ||
|
||
(Pragma allNamed: #pragmaticClass:selector: from: self class to: thisContext methodClass) | ||
do: [:pragma | | ||
| className| | ||
className := pragma argumentAt: 1. | ||
(Smalltalk classNamed: className) | ||
ifNil: [self warn: ('pragmatic method class not found: {1}' format: {className})] | ||
ifNotNil: [:class | | ||
| selector | | ||
selector := pragma argumentAt: 2. | ||
class >> selector | ||
ifNil: [self warn: ('pragmatic method not found: {1}>>{2}' format: {class. selector})] | ||
ifNotNil: [:method | | ||
pragmaticMethods | ||
at: method | ||
ifPresent: [self warn: ('pragmatic method overridden: {1}' format: {method})]; | ||
at: method | ||
put: pragma selector]]]. |
21 changes: 21 additions & 0 deletions
21
...tionStudio-Sandbox.package/PragmaticSandbox.class/instance/addPragmaticMultiMethodsTo..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,21 @@ | ||
initialize-release | ||
addPragmaticMultiMethodsTo: pragmaticMethods | ||
|
||
(Pragma allNamed: #pragmaticClass:selectors: from: self class to: thisContext methodClass) | ||
do: [:pragma | | ||
| className| | ||
className := pragma argumentAt: 1. | ||
(Smalltalk classNamed: className) | ||
ifNil: [self warn: ('pragmatic method class not found: {1}' format: {className})] | ||
ifNotNil: [:class | | ||
| selectors | | ||
selectors := pragma argumentAt: 2. | ||
selectors do: [:selector | | ||
class >> selector | ||
ifNil: [self warn: ('pragmatic method not found: {1}>>{2}' format: {class. selector})] | ||
ifNotNil: [:method | | ||
pragmaticMethods | ||
at: method | ||
ifPresent: [self warn: ('pragmatic method overridden: {1}' format: {method})]; | ||
at: method | ||
put: {pragma selector}]]]]. |
4 changes: 4 additions & 0 deletions
4
...mulationStudio-Sandbox.package/PragmaticSandbox.class/instance/assertUnmodifiedObject..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,4 @@ | ||
private | ||
assertUnmodifiedObject: anObject | ||
|
||
self assert: (self nextSimulator hasModifiedObject: anObject) not. |
6 changes: 6 additions & 0 deletions
6
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/basicEvaluate..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,6 @@ | ||
sandbox | ||
basicEvaluate: aBlock | ||
"Evaluate aBlock in a the receiver, isolating it from the rest of the image, and answer the result as it is seen from the global perspective. | ||
PRIVATE! Does not care about any exceptions that are signaled during the simulation, causing them to be handled still inside the sandbox, even if an exception handler has been defined outside of the sandbox stack. Depending on the configuration of the sandbox and your image, this can mean that even the eventual pop-up of the debugger will be simulated and thus invisible to you! Usually, it is a better idea to use the public #evaluate: protocol instead." | ||
|
||
^ super evaluate: aBlock |
29 changes: 29 additions & 0 deletions
29
...x.package/PragmaticSandbox.class/instance/context.activateMethod.withArgs.receiver.do..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,29 @@ | ||
controlling | ||
context: aContext activateMethod: aCompiledMethod withArgs: arguments receiver: receiver do: aBlock | ||
|
||
| args result selector | | ||
selector := pragmaticMethods at: aCompiledMethod ifAbsent: nil. | ||
selector ifNil: | ||
[selector := pragmaticClasses at: aCompiledMethod methodClass ifAbsent: nil. | ||
selector ifNotNil: [selector := {selector}]]. | ||
|
||
selector ifNil: | ||
[^ super context: aContext activateMethod: aCompiledMethod withArgs: arguments receiver: receiver do: aBlock]. | ||
|
||
args := {receiver}. | ||
selector isArray | ||
ifTrue: | ||
[selector := selector first. | ||
args := args copyWith: aCompiledMethod selector. | ||
args size < selector numArgs ifTrue: | ||
[args := args copyWith: arguments]] | ||
ifFalse: | ||
[args := args , arguments]. | ||
args size < selector numArgs ifTrue: | ||
[args := args copyWith: aContext]. | ||
result := | ||
[self assert: ((aContext objectClass: receiver) includesBehavior: aCompiledMethod methodClass). | ||
self perform: selector withArguments: args] | ||
on: Error do: | ||
[^ super context: aContext activateMethod: aCompiledMethod withArgs: arguments receiver: receiver do: aBlock]. | ||
^ aContext push: result |
9 changes: 9 additions & 0 deletions
9
...x.package/PragmaticSandbox.class/instance/context.doPrimitive.method.receiver.args.do..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,9 @@ | ||
controlling | ||
context: aContext doPrimitive: primitiveIndex method: aCompiledMethod receiver: receiver args: arguments do: aBlock | ||
|
||
primitiveIndex | ||
caseOf: | ||
{[101 "primitiveBeCursor"] -> [^ aContext push: receiver "ignore"]} | ||
otherwise: []. | ||
|
||
^ super context: aContext doPrimitive: primitiveIndex method: aCompiledMethod receiver: receiver args: arguments do: aBlock |
8 changes: 8 additions & 0 deletions
8
...lationStudio-Sandbox.package/PragmaticSandbox.class/instance/doCompiledMethodPreamble..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,8 @@ | ||
pragmatic methods - CompiledMethod | ||
doCompiledMethodPreamble: aCompiledMethod | ||
<pragmaticClass: #CompiledMethod selector: #preamble> | ||
|
||
self assertUnmodifiedObject: aCompiledMethod. | ||
self assertUnmodifiedObject: aCompiledMethod trailer. | ||
|
||
^ aCompiledMethod preamble |
7 changes: 7 additions & 0 deletions
7
...nStudio-Sandbox.package/PragmaticSandbox.class/instance/doDateAndTime.perform.context..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,7 @@ | ||
pragmatic methods - DateAndTime | ||
doDateAndTime: aDateAndTime perform: selector context: aContext | ||
<pragmaticClass: #DateAndTime selectors: #(day month year)> | ||
|
||
self assertUnmodifiedObject: aDateAndTime. | ||
|
||
^ aDateAndTime perform: selector |
8 changes: 8 additions & 0 deletions
8
...tudio-Sandbox.package/PragmaticSandbox.class/instance/doEnvironmentAllClasses.context..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,8 @@ | ||
pragmatic methods - Environment | ||
doEnvironmentAllClasses: anEnvironment context: aContext | ||
<pragmaticClass: #Environment selector: #allClasses> | ||
|
||
self assertUnmodifiedObject: anEnvironment. | ||
self assertUnmodifiedObject: (anEnvironment instVarNamed: 'declarations'). | ||
|
||
^ anEnvironment allClasses |
8 changes: 8 additions & 0 deletions
8
...tudio-Sandbox.package/PragmaticSandbox.class/instance/doEnvironmentClassNames.context..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,8 @@ | ||
pragmatic methods - Environment | ||
doEnvironmentClassNames: anEnvironment context: aContext | ||
<pragmaticClass: #Environment selector: #classNames> | ||
|
||
self assertUnmodifiedObject: anEnvironment. | ||
self assertUnmodifiedObject: (anEnvironment instVarNamed: 'declarations'). | ||
|
||
^ anEnvironment classNames |
13 changes: 13 additions & 0 deletions
13
...ulationStudio-Sandbox.package/PragmaticSandbox.class/instance/doFormAsDataUrl.context..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,13 @@ | ||
pragmatic methods - Form | ||
doFormAsDataUrl: aForm context: aContext | ||
<pragmaticClass: #Form selector: #asDataUrl> | ||
|
||
self assertUnmodifiedObject: aForm. | ||
self assert: (aContext objectClass: aForm width) = SmallInteger. | ||
self assert: (aContext objectClass: aForm height) = SmallInteger. | ||
self assert: (aContext objectClass: aForm depth) = SmallInteger. | ||
self assert: ((aContext objectClass: aForm bits) = Bitmap). | ||
self assertUnmodifiedObject: aForm bits. | ||
self assert: ((aContext objectClass: aForm offset) = Point). | ||
|
||
^ aForm asDataUrl |
7 changes: 7 additions & 0 deletions
7
...s/SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/doRemoteStringText..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,7 @@ | ||
pragmatic methods - RemoteString | ||
doRemoteStringText: aRemoteString | ||
<pragmaticClass: #RemoteString selector: #text> | ||
|
||
self assertUnmodifiedObject: aRemoteString. | ||
|
||
^ aRemoteString text |
9 changes: 9 additions & 0 deletions
9
...io-Sandbox.package/PragmaticSandbox.class/instance/doString.includesSubstring.context..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,9 @@ | ||
pragmatic methods - String | ||
doString: aString includesSubstring: anotherString context: aContext | ||
<pragmaticClass: #String selector: #includesSubstring:> | ||
|
||
self assertUnmodifiedObject: aString. | ||
self assert: ((aContext objectClass: anotherString) includesBehavior: String). | ||
self assertUnmodifiedObject: anotherString. | ||
|
||
^ aString includesSubstring: anotherString |
7 changes: 7 additions & 0 deletions
7
.../SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/doStringAsLowercase..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,7 @@ | ||
pragmatic methods - String | ||
doStringAsLowercase: aString | ||
<pragmaticClass: #String selector: #asLowercase> | ||
|
||
self assertUnmodifiedObject: aString. | ||
|
||
^ aString asLowercase |
13 changes: 13 additions & 0 deletions
13
...ndbox.package/PragmaticSandbox.class/instance/doSymbolClass.selectorsMatching.context..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,13 @@ | ||
pragmatic methods - Symbol | ||
doSymbolClass: aSymbolClass selectorsMatching: aStringPattern context: aContext | ||
<pragmaticClass: #'Symbol class' selector: #selectorsMatching:> | ||
|
||
self assertUnmodifiedObject: aSymbolClass. | ||
self assertUnmodifiedObject: (aSymbolClass classPool at: #NewSymbols). | ||
self assertUnmodifiedObject: (aSymbolClass classPool at: #NewSymbols) array. | ||
self assertUnmodifiedObject: (aSymbolClass classPool at: #SymbolTable). | ||
self assertUnmodifiedObject: (aSymbolClass classPool at: #SymbolTable) array. | ||
self assert: ((aContext objectClass: aStringPattern) includesBehavior: String). | ||
self assertUnmodifiedObject: aStringPattern. | ||
|
||
^ Symbol selectorsMatching: aStringPattern |
11 changes: 11 additions & 0 deletions
11
...x.package/PragmaticSandbox.class/instance/doSystemNavigation.perform.withArgs.context..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,11 @@ | ||
pragmatic methods - SystemNavigation | ||
doSystemNavigation: aSystemNavigation perform: selector withArgs: arguments context: aContext | ||
<pragmaticClass: #SystemNavigation selectors: #(allImplementorsOf: allCallsOn:)> | ||
|
||
self assert: aSystemNavigation == SystemNavigation default. | ||
self assertUnmodifiedObject: aSystemNavigation. | ||
self flag: #imprecise. "only works correctly if *no* class changes were made in the system" | ||
self assert: ((aContext objectClass: arguments first) includesBehavior: Symbol). | ||
self assertUnmodifiedObject: arguments first. | ||
|
||
^ aSystemNavigation perform: selector withArguments: arguments |
8 changes: 8 additions & 0 deletions
8
...tionStudio-Sandbox.package/PragmaticSandbox.class/instance/doTalkConversation.perform..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,8 @@ | ||
pragmatic methods - TalkConversation | ||
doTalkConversation: aTalkConversation perform: selector | ||
<pragmaticClass: #TalkConversation selectors: #(latestDate latestMessage messages)> | ||
|
||
self assertUnmodifiedObject: aTalkConversation. | ||
self flag: #imprecise. "only works correctly if talk messages, mail objects, and sqh wrappers are unchanged" | ||
|
||
^ aTalkConversation perform: selector |
8 changes: 8 additions & 0 deletions
8
.../SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/doTalkInbox.perform..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,8 @@ | ||
pragmatic methods - TalkInbox | ||
doTalkInbox: aTalkInbox perform: selector | ||
<pragmaticClass: #TalkInbox selectors: #(conversations contributions messages mostRecentConversations)> | ||
|
||
self assertUnmodifiedObject: aTalkInbox. | ||
self flag: #imprecise. "only works correctly if talk messages, mail objects, and sqh wrappers are unchanged" | ||
|
||
^ aTalkInbox perform: selector |
10 changes: 10 additions & 0 deletions
10
...lationStudio-Sandbox.package/PragmaticSandbox.class/instance/doTalkInboxClass.perform..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,10 @@ | ||
pragmatic methods - TalkInbox | ||
doTalkInboxClass: aTalkInboxClass perform: selector | ||
<pragmaticClass: #'TalkInbox class'> | ||
|
||
self assertUnmodifiedObject: aTalkInboxClass. | ||
self assertUnmodifiedObject: aTalkInboxClass methodDict. | ||
self flag: #imprecise. | ||
self assert: (aTalkInboxClass wellKnownInboxPragmas anySatisfy: [:pragma | pragma selector = selector]). | ||
|
||
^ aTalkInboxClass perform: selector |
8 changes: 8 additions & 0 deletions
8
...SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/doTalkMailObjectDate..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,8 @@ | ||
pragmatic methods - TalkMailObject | ||
doTalkMailObjectDate: aMailObject | ||
<pragmaticClass: #TalkMailObject selector: #date> | ||
|
||
self assertUnmodifiedObject: aMailObject. | ||
self flag: #imprecise. | ||
|
||
^ aMailObject date |
5 changes: 5 additions & 0 deletions
5
...ionStudio-Sandbox.package/PragmaticSandbox.class/instance/doWebClientDefaultUserAgent..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,5 @@ | ||
pragmatic methods - WebClient | ||
doWebClientDefaultUserAgent: aWebClient | ||
<pragmaticClass: #WebClient selector: #defaultUserAgent> | ||
|
||
^ aWebClient defaultUserAgent |
14 changes: 14 additions & 0 deletions
14
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/evaluate..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,14 @@ | ||
sandbox | ||
evaluate: aBlock | ||
"Evaluate aBlock in a the receiver and answer the result, isolating it from the rest of the image. | ||
Example: | ||
PragmaticSandbox evaluate: [World extent: 0 @ 0; bounds]. | ||
" | ||
|
||
^ self | ||
evaluate: aBlock | ||
ifFailed: [:ex | SandboxError new | ||
messageText: 'Exception from simulated code: ' , ex; | ||
tag: ex; | ||
signal] |
12 changes: 12 additions & 0 deletions
12
...es/SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/evaluate.ifFailed..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,12 @@ | ||
sandbox | ||
evaluate: aBlock ifFailed: failBlock | ||
"Evaluate aBlock in a the receiver and answer the result, isolating it from the rest of the image. If aBlock signals a failure, evaluate failBlock with that failure. | ||
Example: | ||
PragmaticSandbox evaluate: [1 / 0] ifFailed: [:ex | Transcript showln: ex description]. | ||
" | ||
|
||
^ self | ||
evaluate: aBlock | ||
on: Error, Warning, Halt | ||
do: failBlock |
19 changes: 19 additions & 0 deletions
19
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/evaluate.on.do..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,19 @@ | ||
sandbox | ||
evaluate: aBlock on: exceptionHandler do: exceptionBlock | ||
"Evaluate aBlock in the receiver, isolating it from the rest of the image. If aBlock signals an exception that can handled by the exceptionHandler, evaluate exceptionBlock with it. NOTE: Unhandled errors raised by aBlock will bubble up along the sender stack, but still, all handling is simulated in the sandbox until the exception will have been resumed. Depending on the configuration of the sandbox and your image, this can mean that even the pop-up of the eventual debugger will be simulated and thus invisible to you! Thus make sure to pass all relevant exceptions with this message. | ||
Example: | ||
PragmaticSandbox evaluate: [1 / 0] on: ZeroDivide do: [:ex | Transcript showln: ex description]. | ||
""Use with CAUTION and check your image via the ProcessBrowser afterwards"" | ||
PragmaticSandbox evaluate: [self halt] on: ZeroDivide do: [:ex | Transcript showln: ex description]. | ||
" | ||
|
||
| result exception | | ||
self basicEvaluate: [[result := aBlock value] | ||
on: exceptionHandler | ||
do: [:ex | exception := ex]]. | ||
|
||
(self basicEvaluate: [exception]) ifNotNil: [:ex | ^ exceptionBlock cull: ex]. | ||
|
||
^ self readableObjectFor: (self basicEvaluate: [result]) |
4 changes: 4 additions & 0 deletions
4
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/exportMemory.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,4 @@ | ||
sandbox | ||
exportMemory | ||
|
||
^ self nextSimulator exportMemory |
4 changes: 4 additions & 0 deletions
4
packages/SimulationStudio-Sandbox.package/PragmaticSandbox.class/instance/importMemory..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,4 @@ | ||
sandbox | ||
importMemory: memory | ||
|
||
self nextSimulator importMemory: memory. |
Oops, something went wrong.