Skip to content

Commit

Permalink
Introduce isPolyglotEvalAllowed:
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Oct 20, 2024
1 parent 0a16946 commit 2747e4e
Show file tree
Hide file tree
Showing 19 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
polyglot-api
isPolyglotEvalAllowed: aLanguageID
^ self primitiveIsPolyglotEvalAllowed: aLanguageID

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
primitives
primitiveIsPolyglotEvalAllowed
primitiveIsPolyglotEvalAllowed: aLanguageID
<primitive: 'primitiveIsPolyglotEvalAllowed' module: 'PolyglotPlugin'>
^ false
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
primitives
primitiveLastError
<primitive: 'primitiveGetLastError' module: 'PolyglotPlugin'>
self primitiveIsPolyglotEvalAllowed
(self primitiveIsPolyglotEvalAllowed: Polyglot languageIdSmalltalk)
ifTrue: [ self primitiveFailed ]
ifFalse: [ self error: 'Polyglot API is not available' ]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
system startup
setUpPolyglotEnvironment
self primitiveIsPolyglotEvalAllowed
(self primitiveIsPolyglotEvalAllowed: Polyglot languageIdSmalltalk)
ifTrue: [ ForeignObject register ].
self primitiveIsPolyglotBindingsAccessAllowed
ifTrue: [ self export: 'bindings' value: Polyglot bindings ]
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"installLanguage" : "fn 2/17/2024 17:05",
"installLanguage:version:path:" : "fn 2/17/2024 17:06",
"isPermitted:" : "fn 1/26/2021 17:27",
"isPolyglotEvalAllowed" : "fn 5/13/2020 17:37",
"isPolyglotEvalAllowed:" : "fn 10/20/2024 19:38",
"languageIdHost" : "fn 6/25/2021 13:43",
"languageIdJS" : "fn 6/25/2021 13:43",
"languageIdJava" : "fn 6/25/2021 13:44",
Expand Down Expand Up @@ -64,9 +64,9 @@
"primitiveGetScope:" : "fn 3/9/2021 16:38",
"primitiveImport:" : "fn 6/26/2021 14:36",
"primitiveIsPolyglotBindingsAccessAllowed" : "fn 1/5/2020 16:58",
"primitiveIsPolyglotEvalAllowed" : "fn 1/5/2020 16:58",
"primitiveLastError" : "fn 10/2/2019 09:09",
"setUpPolyglotEnvironment" : "fn 1/24/2020 14:41",
"primitiveIsPolyglotEvalAllowed:" : "fn 10/20/2024 19:36",
"primitiveLastError" : "fn 10/20/2024 19:37",
"setUpPolyglotEnvironment" : "fn 10/20/2024 19:37",
"startUp:" : "fn 1/24/2020 14:41",
"toggleEmphasizeInterop" : "fn 6/25/2021 11:27",
"useAdaptiveLanguageSelection" : "fn 6/25/2021 13:39",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
testing
testPolyglotEval
(Polyglot isPermitted: Polyglot languageIdJS) ifFalse: [ ^self ].
self assert: Polyglot primitiveIsPolyglotEvalAllowed.
self assert: (Polyglot primitiveIsPolyglotEvalAllowed: Polyglot languageIdJS).
self assert: 7 equals: (Polyglot eval: Polyglot languageIdJS string: '1 + 2 * 3').
self assert: (42 min: 21) equals: (Polyglot eval: Polyglot languageIdJS string: 'Math.min(42, 21)').

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"testInstallLanguage" : "fn 3/20/2024 08:53",
"testLanguageInfo" : "fn 2/11/2021 10:54",
"testPolyglotBindings" : "fn 11/28/2019 14:53",
"testPolyglotEval" : "fn 6/27/2021 12:15" } }
"testPolyglotEval" : "fn 10/20/2024 19:36" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testing
testArrayStatistics
Polyglot isPolyglotEvalAllowed ifFalse: [ ^self ].
(Polyglot isPolyglotEvalAllowed: Polyglot languageIdSmalltalk) ifFalse: [ ^self ].
[ TruffleSqueakUtilities arrayStatistics ] on: Error do: [ :e | self fail: e ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testing
testLayoutStatistics
Polyglot isPolyglotEvalAllowed ifFalse: [ ^self ].
(Polyglot isPolyglotEvalAllowed: Polyglot languageIdSmalltalk) ifFalse: [ ^self ].
[ TruffleSqueakUtilities layoutStatistics ] on: Error do: [ :e | self fail: e ]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
testing
testTestMapConsistency
| testNames booleanResult |
Polyglot isPolyglotEvalAllowed ifFalse: [ ^self ].
(Polyglot isPolyglotEvalAllowed: Polyglot languageIdSmalltalk) ifFalse: [ ^self ].

testNames := TestCase buildSuite tests collect: [:test |
test class asString, '>>', test selector].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
testing
testVMIntrospection
| testObject metaObject squeakHashAndBits |
Polyglot isPolyglotEvalAllowed ifFalse: [ ^self ].
(Polyglot isPolyglotEvalAllowed: Polyglot languageIdSmalltalk) ifFalse: [ ^self ].

testObject := SmalltalkImage vmObject.
"Every Java object understands hashCode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"instance" : {
"assertSorted:name:" : "fn 1/25/2020 15:24",
"testAdoptInstanceArrays" : "fn 1/31/2020 10:20",
"testArrayStatistics" : "fn 5/13/2020 17:37",
"testArrayStatistics" : "fn 10/20/2024 19:39",
"testCallTarget" : "fn 10/26/2021 21:10",
"testLayoutStatistics" : "fn 5/13/2020 17:37",
"testTestMapConsistency" : "fn 3/9/2021 15:59",
"testVMIntrospection" : "fn 10/19/2024 14:00" } }
"testLayoutStatistics" : "fn 10/20/2024 19:39",
"testTestMapConsistency" : "fn 10/20/2024 19:39",
"testVMIntrospection" : "fn 10/20/2024 19:39" } }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
evaluation
evaluateExpression: selection
^ Polyglot isPolyglotEvalAllowed
^ (Polyglot isPolyglotEvalAllowed: self languageInfo getId)
ifTrue: [ Polyglot
evalWithBindings: self languageInfo getId asString
string: selection asString ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"addCustomCodePaneMenuItems:shifted:" : "fn 6/25/2021 22:29",
"addModelItemsToWindowMenu:" : "fn 2/17/2024 13:12",
"buildCodePaneWith:" : "fn 6/10/2021 09:52",
"evaluateExpression:" : "fn 6/27/2021 12:38",
"evaluateExpression:" : "fn 10/20/2024 19:39",
"helpText" : "fn 6/25/2021 17:55",
"initialize" : "fn 6/25/2021 22:50",
"initializeBindings" : "fn 6/28/2021 12:38",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ evaluateExpression: selection

| polyglot |
polyglot := Smalltalk classNamed: #Polyglot.
^ (polyglot notNil and: [polyglot isPolyglotEvalAllowed])
^ (polyglot notNil and: [polyglot isPolyglotEvalAllowed: self languageInfo polyglotId])
ifTrue: [
[PolyglotEditor evaluateInInnerContext
ifTrue: [ polyglot evalInInnerContext: self languageInfo polyglotId string: selection asString ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"codeMorph" : "fn 5/13/2020 11:54",
"convertLineEndings:" : "fn 5/13/2020 11:52",
"ensurePolyglotIsImported" : "cmfcmf 7/22/2019 20:47",
"evaluateExpression:" : "fn 7/6/2021 15:00",
"evaluateExpression:" : "fn 10/20/2024 19:38",
"extractLineEndings" : "fn 5/13/2020 11:52",
"initialize" : "fn 5/13/2020 11:59",
"isCodeEntry" : "ek 7/25/2019 17:12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ hasPolyglotSupport
"true when we are not in TruffleSqueak, otherwise only true if the language is installed"
| polyglot |
polyglot := Smalltalk classNamed: #Polyglot.
^ polyglot isNil or: [polyglot isPolyglotEvalAllowed not] or: [polyglot isPermitted: self polyglotId]
^ polyglot isNil or: [(polyglot isPolyglotEvalAllowed: self polyglotId) not] or: [polyglot isPermitted: self polyglotId]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"customCodeAfterCodeBoxExports" : "cmfcmf 8/4/2019 17:45",
"customCodeBeforeCodeBoxContent" : "cmfcmf 8/4/2019 17:44",
"generateOneLineCommentsFor:startingWith:" : "cmfcmf 8/4/2019 15:30",
"hasPolyglotSupport" : "fn 7/4/2021 19:36",
"hasPolyglotSupport" : "fn 10/20/2024 19:38",
"polyglotId" : "cmfcmf 7/22/2019 19:21",
"unescapedCommentContent:" : "cmfcmf 8/4/2019 16:11",
"unescapedCommentContent:eachCommentLineStartingWith:" : "cmfcmf 8/4/2019 16:17" },
Expand Down

0 comments on commit 2747e4e

Please sign in to comment.