Skip to content

Commit

Permalink
- add a test case for the pronlem: #testToDo
Browse files Browse the repository at this point in the history
- check what would happen in this case if #to:do: would not be optmized and makes sure we do the same

fixes pharo-project#6812
  • Loading branch information
MarcusDenker committed Feb 9, 2021
1 parent 391cb13 commit 0679aa7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/OpalCompiler-Core/IRJump.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ IRJump >> isJump [
^ true
]

{ #category : #acessing }
IRJump >> nextBytecodeOffsetAfterJump [
^ destination last destination first bytecodeOffset
]

{ #category : #accessing }
IRJump >> successor [
^successor
Expand Down
6 changes: 6 additions & 0 deletions src/OpalCompiler-Core/IRPopIntoTemp.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ Class {
IRPopIntoTemp >> accept: aVisitor [
^ aVisitor visitPopIntoTemp: self
]

{ #category : #acessing }
IRPopIntoTemp >> nextBytecodeOffsetAfterJump [
"if we are in to:do: answers the next byte code offset"
^ self sequence last destination last destination first bytecodeOffset
]
2 changes: 1 addition & 1 deletion src/OpalCompiler-Core/ProtoObject.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ProtoObject >> mustBeBooleanCompileExpression: context andCache: cache [
"Keep same compilation context as the sender node's"
methodNode compilationContext: sendNode methodNode compilationContext copy.
"Disable inlining so the message send will be unoptimized"
methodNode compilationContext compilerOptions: #(- optionInlineIf optionInlineAndOr optionInlineWhile).
methodNode compilationContext compilerOptions: #(- optionInlineIf optionInlineAndOr optionInlineWhile optionInlineToDo).
"Generate the method"
OCASTSemanticCleaner clean: methodNode.
method := methodNode generate.
Expand Down
9 changes: 9 additions & 0 deletions src/OpalCompiler-Tests/MustBeBooleanTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ MustBeBooleanTest >> testSemanticAnalysisCleaned [
[ path]]]] raise: KeyNotFound ] raise: MessageNotUnderstood.
]

{ #category : #tests }
MustBeBooleanTest >> testToDo [
| variable |

variable := #(1 2 3).
"in this case, we end up sending #ifTrue: to the Array"
self should: [(1 to: variable do: [:index |])] raise: MessageNotUnderstood
]

{ #category : #tests }
MustBeBooleanTest >> testWhile [
| myFlag |
Expand Down

0 comments on commit 0679aa7

Please sign in to comment.