Skip to content

Commit

Permalink
Update importer
Browse files Browse the repository at this point in the history
avoid using exceptions for handling object identities
  • Loading branch information
Gabriel-Darbord committed Feb 14, 2024
1 parent 36dfc93 commit 55db52c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/Famix-Value-Importer/FamixValueAbstractImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ FamixValueAbstractImporter >> getDefaultUnknownType [
]

{ #category : #enumerating }
FamixValueAbstractImporter >> getObjectFromIdentity: id [
FamixValueAbstractImporter >> getObjectFromIdentity: id ifAbsent: aBlock [

^ objectDict at: id
^ objectDict at: id ifAbsent: aBlock
]

{ #category : #enumerating }
Expand Down Expand Up @@ -142,8 +142,7 @@ FamixValueAbstractImporter >> importValue: rawValue [
{ #category : #initialization }
FamixValueAbstractImporter >> initialize [

typeInferences := Stack new.
objectDict := Dictionary new
self reset
]

{ #category : #enumerating }
Expand Down Expand Up @@ -197,8 +196,9 @@ FamixValueAbstractImporter >> parseValue: serializedValue [

{ #category : #initialization }
FamixValueAbstractImporter >> reset [
"Forget previous object identities."
"Forget type inferences and previous object identities."

typeInferences := Stack new.
objectDict := Dictionary new
]

Expand All @@ -212,7 +212,7 @@ FamixValueAbstractImporter >> typeInference [
FamixValueAbstractImporter >> withTypeInference: type do: block [

| result |
type = self typeInference ifTrue: [ ^ block value ].
type == self typeInference ifTrue: [ ^ block value ].
typeInferences push: type.
result := block value.
typeInferences pop.
Expand Down
6 changes: 3 additions & 3 deletions src/Famix-Value-Importer/Integer.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Integer >> asJavaJacksonValueOn: importer [
^ (typeInference isNotNil and: [
(importer isPrimitiveType: typeInference) not ])
ifTrue: [ "object reference, solved by the importer"
[ importer getObjectFromIdentity: self ]
on: KeyNotFound
do: [ "might be a special object with missing runtime type information"
importer
getObjectFromIdentity: self
ifAbsent: [ "might be a special object with missing runtime type information"
importer importSpecialObject: self of: typeInference ] ]
ifFalse: [ importer importPrimitive: self of: 'int' ]
]

0 comments on commit 55db52c

Please sign in to comment.