Skip to content

Commit

Permalink
Merge pull request #852 from jecisc/TLambda
Browse files Browse the repository at this point in the history
Introduce the concept of lambda expressions
  • Loading branch information
jecisc authored Nov 7, 2024
2 parents cf40294 + be490c3 commit cdc1dde
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Famix-MetamodelGeneration/FamixGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Class {
'tInvocable',
'tInvocation',
'tInvocationsReceiver',
'tLambda',
'tLocalVariable',
'tMethod',
'tModule',
Expand Down Expand Up @@ -70,6 +71,7 @@ Class {
'tWithImplicitVariables',
'tWithInheritances',
'tWithInvocations',
'tWithLambdas',
'tWithLocalVariables',
'tWithMethods',
'tDefinedInModule',
Expand Down Expand Up @@ -498,6 +500,12 @@ FamixGenerator >> commentForTInvocationsReceiver [
^ ''
]

{ #category : #comments }
FamixGenerator >> commentForTLambda [

^ 'FamixTLabmda represents a behavioural entity that does not have a name. It can be used to represent lambdas, closures, blocks...'
]

{ #category : #comments }
FamixGenerator >> commentForTLocalVariable [

Expand Down Expand Up @@ -941,6 +949,12 @@ FamixGenerator >> commentForTWithInvocations [
^ ''
]

{ #category : #comments }
FamixGenerator >> commentForTWithLambdas [

^ 'I represent an entity that can owned lambda expressions.'
]

{ #category : #comments }
FamixGenerator >> commentForTWithLocalVariables [

Expand Down Expand Up @@ -1091,6 +1105,13 @@ FamixGenerator >> defineHierarchy [
tInvocation --|> tHasSignature.

tImplicitVariable --|> tStructuralEntity.

tLambda --|> tWithParameters.
tLambda --|> tHasSignature.
tLambda --|> tWithStatements.
tLambda --|> tWithLocalVariables.
tLambda --|> tInvocable.
tLambda --|> #TEntityMetaLevelDependency.

tLocalVariable --|> tStructuralEntity.

Expand Down Expand Up @@ -1371,6 +1392,13 @@ FamixGenerator >> defineRelations [
((tWithFunctions property: #functions)
comment: 'Functions defined in the container, if any.').

((tLambda property: #lambdaContainer)
comment: 'The container defining the lambda expression. The lambda is placed in a container, because certain languages can nest lambdas in lambdas.';
container)
*-
((tWithLambdas property: #lambdas)
comment: 'Lambdas defined in the container, if any.').

((tGlobalVariable property: #parentScope)
comment: 'Scope declaring the global variable. belongsTo implementation';
container)
Expand Down Expand Up @@ -1736,6 +1764,9 @@ FamixGenerator >> defineTraits [

tInvocationsReceiver := builder newTraitNamed: #TInvocationsReceiver.
tInvocationsReceiver comment: self commentForTInvocationsReceiver.

tLambda := builder newTraitNamed: #TLambda.
tLambda comment: self commentForTLambda.

tLocalVariable := builder newTraitNamed: #TLocalVariable.
tLocalVariable comment: self commentForTLocalVariable.
Expand Down Expand Up @@ -1891,6 +1922,9 @@ FamixGenerator >> defineTraits [

tWithInvocations := builder newTraitNamed: #TWithInvocations.
tWithInvocations comment: self commentForTWithInvocations.

tWithLambdas := builder newTraitNamed: #TWithLambdas.
tWithLambdas comment: self commentForTWithLambdas.

tWithLocalVariables := builder newTraitNamed: #TWithLocalVariables.
tWithLocalVariables comment: self commentForTWithLocalVariables.
Expand Down
86 changes: 86 additions & 0 deletions src/Famix-Traits/FamixTLambda.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"
FamixTLabmda represents a behavioural entity that does not have a name. It can be used to represent lambdas, closures, blocks...
## Relations
======================
### Parents
| Relation | Origin | Opposite | Type | Comment |
|---|
| `lambdaContainer` | `FamixTLambda` | `lambdas` | `FamixTWithLambdas` | The container defining the lambda expression. The lambda is placed in a container, because certain languages can nest lambdas in lambdas.|
### Children
| Relation | Origin | Opposite | Type | Comment |
|---|
| `localVariables` | `FamixTWithLocalVariables` | `parentBehaviouralEntity` | `FamixTLocalVariable` | Variables locally defined by this behaviour.|
| `parameters` | `FamixTWithParameters` | `parentBehaviouralEntity` | `FamixTParameter` | List of formal parameters declared by this behaviour.|
### Outgoing dependencies
| Relation | Origin | Opposite | Type | Comment |
|---|
| `accesses` | `FamixTWithAccesses` | `accessor` | `FamixTAccess` | Accesses to variables made by this behaviour.|
| `outgoingInvocations` | `FamixTWithInvocations` | `sender` | `FamixTInvocation` | Outgoing invocations sent by this behaviour.|
| `outgoingReferences` | `FamixTWithReferences` | `referencer` | `FamixTReference` | References from this entity to other entities.|
### Incoming dependencies
| Relation | Origin | Opposite | Type | Comment |
|---|
| `incomingInvocations` | `FamixTInvocable` | `candidates` | `FamixTInvocation` | Incoming invocations from other behaviours computed by the candidate operator.|
### Other
| Relation | Origin | Opposite | Type | Comment |
|---|
| `sourceAnchor` | `FamixTSourceEntity` | `element` | `FamixTSourceAnchor` | SourceAnchor entity linking to the original source code for this entity|
## Properties
======================
| Name | Type | Default value | Comment |
|---|
| `isStub` | `Boolean` | false | Flag true if the entity attributes are incomplete, either because the entity is missing or not imported.|
| `signature` | `String` | nil | Signature of the message being sent|
"
Trait {
#name : #FamixTLambda,
#instVars : [
'#lambdaContainer => FMOne type: #FamixTWithLambdas opposite: #lambdas'
],
#traits : 'FamixTHasSignature + FamixTInvocable + FamixTWithLocalVariables + FamixTWithParameters + FamixTWithStatements + TEntityMetaLevelDependency',
#classTraits : 'FamixTHasSignature classTrait + FamixTInvocable classTrait + FamixTWithLocalVariables classTrait + FamixTWithParameters classTrait + FamixTWithStatements classTrait + TEntityMetaLevelDependency classTrait',
#category : #'Famix-Traits-Traits'
}

{ #category : #meta }
FamixTLambda classSide >> annotation [

<FMClass: #TLambda super: #Object>
<package: #'Famix-Traits'>
<generated>
^ self
]

{ #category : #accessing }
FamixTLambda >> lambdaContainer [
"Relation named: #lambdaContainer type: #FamixTWithLambdas opposite: #lambdas"

<generated>
<FMComment: 'The container defining the lambda expression. The lambda is placed in a container, because certain languages can nest lambdas in lambdas.'>
<container>
^ lambdaContainer
]

{ #category : #accessing }
FamixTLambda >> lambdaContainer: anObject [

<generated>
lambdaContainer := anObject
]

{ #category : #navigation }
FamixTLambda >> lambdaContainerGroup [
<generated>
<navigation: 'LambdaContainer'>
^ MooseSpecializedGroup with: self lambdaContainer
]
53 changes: 53 additions & 0 deletions src/Famix-Traits/FamixTWithLambdas.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"
I represent an entity that can owned lambda expressions.
## Relations
======================
### Children
| Relation | Origin | Opposite | Type | Comment |
|---|
| `lambdas` | `FamixTWithLambdas` | `lambdaContainer` | `FamixTLambda` | Lambdas defined in the container, if any.|
"
Trait {
#name : #FamixTWithLambdas,
#instVars : [
'#lambdas => FMMany type: #FamixTLambda opposite: #lambdaContainer'
],
#category : #'Famix-Traits-Traits'
}

{ #category : #meta }
FamixTWithLambdas classSide >> annotation [

<FMClass: #TWithLambdas super: #Object>
<package: #'Famix-Traits'>
<generated>
^ self
]

{ #category : #adding }
FamixTWithLambdas >> addLambda: anObject [
<generated>
^ self lambdas add: anObject
]

{ #category : #accessing }
FamixTWithLambdas >> lambdas [
"Relation named: #lambdas type: #FamixTLambda opposite: #lambdaContainer"

<generated>
<FMComment: 'Lambdas defined in the container, if any.'>
<derived>
^ lambdas
]

{ #category : #accessing }
FamixTWithLambdas >> lambdas: anObject [

<generated>
lambdas value: anObject
]
14 changes: 14 additions & 0 deletions src/Famix-Traits/MooseAbstractGroup.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ MooseAbstractGroup >> allInvocations [
^self allUsing: FamixTInvocation
]

{ #category : #'*Famix-Traits' }
MooseAbstractGroup >> allLambdas [

<navigation: 'All lambdas'>
^ self allUsing: FamixTLambda
]

{ #category : #'*Famix-Traits' }
MooseAbstractGroup >> allLocalVariables [

Expand Down Expand Up @@ -147,6 +154,13 @@ MooseAbstractGroup >> allModelImports [
^ self cacheAt: 'All model imports' ifAbsentPut: [ MooseGroup withAll: (self allImports reject: [ :each | each isStub ]) withDescription: 'All model imports' ]
]

{ #category : #'*Famix-Traits' }
MooseAbstractGroup >> allModelLambdas [

<navigation: 'All model lambdas'>
^ self cacheAt: 'All model lambdas' ifAbsentPut: [ MooseGroup withAll: (self allLambdas reject: [ :each | each isStub ]) withDescription: 'All model lambdas' ]
]

{ #category : #'*Famix-Traits' }
MooseAbstractGroup >> allModelMethods [
<navigation: 'All model methods'>
Expand Down

0 comments on commit cdc1dde

Please sign in to comment.