Skip to content

Commit

Permalink
use structClasses accessor, use select:thenDo: and add comment when r…
Browse files Browse the repository at this point in the history
…esetting cache
  • Loading branch information
ivojawer committed Jul 3, 2023
1 parent db42fb8 commit a240dbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
21 changes: 11 additions & 10 deletions smalltalksrc/Slang/CCodeGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4423,9 +4423,11 @@ CCodeGenerator >> renameKeywordsConflicts [
"rename locals"
localRewording := Dictionary new.
(method allLocals select: [ :local |
self reservedWords includes: local ]) do: [ :local |
localRewording at: local put: (self sanitizeKeyword: local) ].
method allLocals
select: [ :local | self reservedWords includes: local ]
thenDo: [ :local | localRewording at: local put: (self sanitizeKeyword: local) ].
localRewording ifNotEmpty: [
method renameVariablesUsing: localRewording ].
Expand All @@ -4438,13 +4440,12 @@ CCodeGenerator >> renameKeywordsConflicts [
to: (self sanitizeKeyword: cSelector) ] ].
"translate structs instance variables"
structClasses ifNotNil: [ :classes |
classes do: [ :struct |
struct instVarTypeDeclarationsDo: [ :ivn :type |
(self reservedWords includes: ivn) ifTrue: [
self
addStructInstanceVariableTranslation: ivn
to: (self sanitizeKeyword: ivn) ] ] ] ]
self structClasses do: [ :struct |
struct instVarTypeDeclarationsDo: [ :ivn :type |
(self reservedWords includes: ivn) ifTrue: [
self
addStructInstanceVariableTranslation: ivn
to: (self sanitizeKeyword: ivn) ] ] ]
]
{ #category : #'C translation support' }
Expand Down
1 change: 1 addition & 0 deletions smalltalksrc/Slang/TMethod.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,7 @@ TMethod >> recordDeclarationsIn: aCCodeGen [
pragma selector = #returnTypeC: ifTrue: [
self returnType: pragma arguments last ] ].

"reset cache since declarations changed"
cachedLocals := nil
]

Expand Down

0 comments on commit a240dbd

Please sign in to comment.