Skip to content

Commit

Permalink
Closure entity with bound variable association
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Darbord committed Jul 5, 2024
1 parent 0b82586 commit cad0de6
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Extension { #name : #FamixValueUnknownType }

{ #category : #'*Famix-Value-Entities-Extensions' }
FamixValueUnknownType >> acceptValueVisitor: visitor forObject: object [

self error: 'Exporting an unknown type is not (yet?) supported.'
]

{ #category : #'*Famix-Value-Entities-Extensions' }
FamixValueUnknownType >> baseName [

Expand Down
41 changes: 31 additions & 10 deletions src/Famix-Value-Entities/FamixValueOfClosure.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@ A lexical closure.
### Other
| Relation | Origin | Opposite | Type | Comment |
|---|
| `value` | `FamixValueOfClosure` | `closure` | `FamixValueOfType` | |
| `variables` | `FamixValueOfClosure` | `closure` | `FamixValueOfClosureVariable` | |
## Properties
======================
| Name | Type | Default value | Comment |
|---|
| `value` | `Object` | nil | Value data represented as a native Smalltalk object.|
| `sourceCode` | `String` | nil | The source code of the lexical closure.|
"
Class {
#name : #FamixValueOfClosure,
#superclass : #FamixValueOfType,
#traits : 'FamixValueTWithValueProperty',
#classTraits : 'FamixValueTWithValueProperty classTrait',
#instVars : [
'#value => FMOne type: #FamixValueOfType opposite: #closure'
'#sourceCode => FMProperty',
'#variables => FMMany type: #FamixValueOfClosureVariable opposite: #closure'
],
#category : #'Famix-Value-Entities-Entities'
}
Expand All @@ -38,17 +37,39 @@ FamixValueOfClosure class >> annotation [
^ self
]

{ #category : #adding }
FamixValueOfClosure >> addVariable: anObject [
<generated>
^ self variables add: anObject
]

{ #category : #accessing }
FamixValueOfClosure >> sourceCode [

<FMProperty: #sourceCode type: #String>
<generated>
<FMComment: 'The source code of the lexical closure.'>
^ sourceCode
]

{ #category : #accessing }
FamixValueOfClosure >> sourceCode: anObject [
<generated>
sourceCode := anObject
]

{ #category : #accessing }
FamixValueOfClosure >> value [
"Relation named: #value type: #FamixValueOfType opposite: #closure"
FamixValueOfClosure >> variables [
"Relation named: #variables type: #FamixValueOfClosureVariable opposite: #closure"

<generated>
^ value
<derived>
^ variables
]

{ #category : #accessing }
FamixValueOfClosure >> value: anObject [
FamixValueOfClosure >> variables: anObject [

<generated>
value := anObject
variables value: anObject
]
85 changes: 85 additions & 0 deletions src/Famix-Value-Entities/FamixValueOfClosureVariable.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"
A variable binding in a lexical closure.
## Relations
======================
### Other
| Relation | Origin | Opposite | Type | Comment |
|---|
| `closure` | `FamixValueOfClosureVariable` | `variables` | `FamixValueOfClosure` | |
| `value` | `FamixValueOfClosureVariable` | `variableInClosures` | `FamixValueOfType` | |
## Properties
======================
| Name | Type | Default value | Comment |
|---|
| `name` | `String` | nil | Name of the variable bound to the closure.|
"
Class {
#name : #FamixValueOfClosureVariable,
#superclass : #FamixValueEntity,
#instVars : [
'#name => FMProperty',
'#closure => FMOne type: #FamixValueOfClosure opposite: #variables',
'#value => FMOne type: #FamixValueOfType opposite: #variableInClosures'
],
#category : #'Famix-Value-Entities-Entities'
}

{ #category : #meta }
FamixValueOfClosureVariable class >> annotation [

<FMClass: #OfClosureVariable super: #FamixValueEntity>
<package: #'Famix-Value-Entities'>
<generated>
^ self
]

{ #category : #accessing }
FamixValueOfClosureVariable >> closure [
"Relation named: #closure type: #FamixValueOfClosure opposite: #variables"

<generated>
^ closure
]

{ #category : #accessing }
FamixValueOfClosureVariable >> closure: anObject [

<generated>
closure := anObject
]

{ #category : #accessing }
FamixValueOfClosureVariable >> name [

<FMProperty: #name type: #String>
<generated>
<FMComment: 'Name of the variable bound to the closure.'>
^ name
]

{ #category : #accessing }
FamixValueOfClosureVariable >> name: anObject [
<generated>
name := anObject
]

{ #category : #accessing }
FamixValueOfClosureVariable >> value [
"Relation named: #value type: #FamixValueOfType opposite: #variableInClosures"

<generated>
^ value
]

{ #category : #accessing }
FamixValueOfClosureVariable >> value: anObject [

<generated>
value := anObject
]
50 changes: 25 additions & 25 deletions src/Famix-Value-Entities/FamixValueOfType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Abstract superclass of all ValueOf_Type_ entities.
| Relation | Origin | Opposite | Type | Comment |
|---|
| `attributeInObjects` | `FamixValueOfType` | `value` | `FamixValueOfObjectAttribute` | |
| `closure` | `FamixValueOfType` | `value` | `FamixValueOfClosure` | |
| `elementInCollections` | `FamixValueOfType` | `value` | `FamixValueOfCollectionElement` | |
| `keyInDictionaries` | `FamixValueOfType` | `key` | `FamixValueOfDictionaryAssociation` | |
| `type` | `FamixValueOfType` | `values` | `FamixTType` | |
| `typedEntity` | `FamixValueOfType` | `values` | `FamixTTypedEntity` | |
| `valueInDictionaries` | `FamixValueOfType` | `value` | `FamixValueOfDictionaryAssociation` | |
| `variableInClosures` | `FamixValueOfType` | `value` | `FamixValueOfClosureVariable` | |
Expand All @@ -23,10 +23,10 @@ Class {
#superclass : #FamixValueEntity,
#instVars : [
'#attributeInObjects => FMMany type: #FamixValueOfObjectAttribute opposite: #value',
'#closure => FMMany type: #FamixValueOfClosure opposite: #value',
'#elementInCollections => FMMany type: #FamixValueOfCollectionElement opposite: #value',
'#keyInDictionaries => FMMany type: #FamixValueOfDictionaryAssociation opposite: #key',
'#valueInDictionaries => FMMany type: #FamixValueOfDictionaryAssociation opposite: #value'
'#valueInDictionaries => FMMany type: #FamixValueOfDictionaryAssociation opposite: #value',
'#variableInClosures => FMMany type: #FamixValueOfClosureVariable opposite: #value'
],
#category : #'Famix-Value-Entities-Entities'
}
Expand Down Expand Up @@ -54,12 +54,6 @@ FamixValueOfType >> addAttributeInObject: anObject [
^ self attributeInObjects add: anObject
]

{ #category : #adding }
FamixValueOfType >> addClosure: anObject [
<generated>
^ self closure add: anObject
]

{ #category : #adding }
FamixValueOfType >> addElementInCollection: anObject [
<generated>
Expand All @@ -78,6 +72,12 @@ FamixValueOfType >> addValueInDictionary: anObject [
^ self valueInDictionaries add: anObject
]

{ #category : #adding }
FamixValueOfType >> addVariableInClosure: anObject [
<generated>
^ self variableInClosures add: anObject
]

{ #category : #accessing }
FamixValueOfType >> attributeInObjects [
"Relation named: #attributeInObjects type: #FamixValueOfObjectAttribute opposite: #value"
Expand All @@ -94,22 +94,6 @@ FamixValueOfType >> attributeInObjects: anObject [
attributeInObjects value: anObject
]

{ #category : #accessing }
FamixValueOfType >> closure [
"Relation named: #closure type: #FamixValueOfClosure opposite: #value"

<generated>
<derived>
^ closure
]

{ #category : #accessing }
FamixValueOfType >> closure: anObject [

<generated>
closure value: anObject
]

{ #category : #accessing }
FamixValueOfType >> elementInCollections [
"Relation named: #elementInCollections type: #FamixValueOfCollectionElement opposite: #value"
Expand Down Expand Up @@ -196,3 +180,19 @@ FamixValueOfType >> valueInDictionaries: anObject [
<generated>
valueInDictionaries value: anObject
]

{ #category : #accessing }
FamixValueOfType >> variableInClosures [
"Relation named: #variableInClosures type: #FamixValueOfClosureVariable opposite: #value"

<generated>
<derived>
^ variableInClosures
]

{ #category : #accessing }
FamixValueOfType >> variableInClosures: anObject [

<generated>
variableInClosures value: anObject
]
7 changes: 7 additions & 0 deletions src/Famix-Value-Entities/FamixValueTEntityCreator.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ FamixValueTEntityCreator >> newOfClosure [
^ self add: FamixValueOfClosure new
]

{ #category : #'entity creation' }
FamixValueTEntityCreator >> newOfClosureVariable [

<generated>
^ self add: FamixValueOfClosureVariable new
]

{ #category : #'entity creation' }
FamixValueTEntityCreator >> newOfCollection [

Expand Down
6 changes: 0 additions & 6 deletions src/Famix-Value-Entities/FamixValueUnknownType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ FamixValueUnknownType class >> annotation [
^ self
]

{ #category : #visiting }
FamixValueUnknownType >> acceptValueVisitor: visitor forObject: object [

self error: 'Exporting an unknown type is not (yet?) supported.'
]

{ #category : #testing }
FamixValueUnknownType >> isUnknownType [

Expand Down
20 changes: 16 additions & 4 deletions src/Famix-Value-Generator/FamixValueGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Class {
'collectionElement',
'objectAttribute',
'classReference',
'closure'
'closure',
'closureVariable'
],
#category : #'Famix-Value-Generator'
}
Expand Down Expand Up @@ -90,6 +91,10 @@ FamixValueGenerator >> defineClasses [
closure := builder
newClassNamed: #OfClosure
comment: 'A lexical closure.'.
closureVariable := builder
newClassNamed: #OfClosureVariable
comment:
'A variable binding in a lexical closure.'.
ofUnknownType := (builder
newClassNamed: #OfUnknownType
comment: 'A value of an unknwon type.')
Expand All @@ -112,7 +117,6 @@ FamixValueGenerator >> defineHierarchy [
classReference --|> value.
dictionaryAssociation --|> value.

closure --|> tWithValueProperty. "for the code"
primitive --|> tWithValueProperty.
ofUnknownType --|> tWithValueProperty.

Expand All @@ -123,7 +127,12 @@ FamixValueGenerator >> defineHierarchy [
FamixValueGenerator >> defineProperties [

(tWithValueProperty property: #value type: #Object) comment:
'Value data represented as a native Smalltalk object.'
'Value data represented as a native Smalltalk object.'.

(closure property: #sourceCode type: #String) comment:
'The source code of the lexical closure.'.
(closureVariable property: #name type: #String) comment:
'Name of the variable bound to the closure.'
]

{ #category : #definition }
Expand Down Expand Up @@ -161,7 +170,10 @@ FamixValueGenerator >> defineRelations [
*- ((self remoteTrait: #TClass withPrefix: #Famix) property:
#valueReferences).

(closure property: #value) *- (value property: #closure)
(closure property: #variables)
-* (closureVariable property: #closure).
(closureVariable property: #value)
*- (value property: #variableInClosures)
]

{ #category : #definition }
Expand Down

0 comments on commit cad0de6

Please sign in to comment.