Skip to content

Commit c426dfd

Browse files
committed
Manage call function
1 parent 0b59bba commit c426dfd

11 files changed

+333
-48
lines changed

src/FAST-Python-Model-Generator/FASTPythonMetamodelGenerator.class.st

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ Class {
151151
'splat',
152152
'splatParameter',
153153
'comprehension',
154-
'tSuperclass'
154+
'tSuperclass',
155+
'tCallable'
155156
],
156157
#category : 'FAST-Python-Model-Generator',
157158
#package : 'FAST-Python-Model-Generator'
@@ -364,6 +365,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
364365
conditionalExpression --|> expression.
365366
conditionalExpression --|> tWithCondition.
366367
conditionalExpression --|> tSuperclass.
368+
conditionalExpression --|> tCallable.
367369

368370
continueStatement --|> statement.
369371

@@ -450,6 +452,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
450452
lambda --|> expression.
451453
lambda --|> tWithParameters.
452454
lambda --|> tDecoratorExpression.
455+
lambda --|> tCallable.
453456

454457
list --|> collectionInitializer.
455458
list --|> tAsPatternTarget.
@@ -536,6 +539,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
536539
tReturnReferenceable --|> tDecoratorExpression.
537540
tReturnReferenceable --|> tDeletable.
538541
tReturnReferenceable --|> tSuperclass.
542+
tReturnReferenceable --|> tCallable.
539543

540544
thenClause --|> tStatementBlock.
541545

@@ -636,7 +640,7 @@ FASTPythonMetamodelGenerator >> defineRelations [
636640

637641
((call property: #callee) comment:
638642
'I represent what is called. Can be a class for an instantiation. A function invocation. A method invocation. The call of the return of a call. The call of something invoked from an array access...')
639-
<>- ((expression property: #caller) comment: 'The call entity calling me (if it''s the case)').
643+
<>- ((tCallable property: #caller) comment: 'The call entity calling me (if it''s the case)').
640644

641645
(caseClause property: #pattern) <>-(tPattern property: #parentCaseClause).
642646

@@ -782,37 +786,39 @@ FASTPythonMetamodelGenerator >> defineTraits [
782786

783787
tAsPatternSource := (builder newTraitNamed: #TAsPatternSource) comment: 'I represent an entity that could be aliased in an as pattern.'.
784788

785-
(tAssignable := builder newTraitNamed: #TAssignable) comment: 'I represent something that can be assigned in an assignment'.
789+
tAssignable := (builder newTraitNamed: #TAssignable) comment: 'I represent something that can be assigned in an assignment'.
786790

787-
(tClassPatternElement := builder newTraitNamed: #TClassPatternElement) comment: 'I represent the elements of a class pattern in python pattern matcher. The first element is the class name, the others the arguments.'.
791+
tCallable := (builder newTraitNamed: #TCallable) comment: 'I represent something that can be the receiver of a call'.
792+
793+
tClassPatternElement := (builder newTraitNamed: #TClassPatternElement) comment: 'I represent the elements of a class pattern in python pattern matcher. The first element is the class name, the others the arguments.'.
788794

789-
(tDecoratorExpression := builder newTraitNamed: #TDecoratorExpression) comment: 'I represent an entity that *can* be the expression of a decorator.'.
795+
tDecoratorExpression := (builder newTraitNamed: #TDecoratorExpression) comment: 'I represent an entity that *can* be the expression of a decorator.'.
790796

791797
tDefinition := builder newTraitNamed: #TDefinition.
792798

793-
(tDeletable := builder newTraitNamed: #TDeletable) comment: 'I represent an expression that can be in a delete statement.'.
799+
tDeletable := (builder newTraitNamed: #TDeletable) comment: 'I represent an expression that can be in a delete statement.'.
794800

795-
(tPattern := builder newTraitNamed: #TPattern) comment: 'I represent an entity that can be the pattern of a case clause in a match statement..'.
801+
tPattern := (builder newTraitNamed: #TPattern) comment: 'I represent an entity that can be the pattern of a case clause in a match statement..'.
796802

797-
(tRaised := builder newTraitNamed: #TRaised) comment: 'I represent an expression that can give an exception to raise in a raise statement.'.
803+
tRaised := (builder newTraitNamed: #TRaised) comment: 'I represent an expression that can give an exception to raise in a raise statement.'.
798804

799-
((tReturnReferenceable := builder newTraitNamed: #TReturnReferenceable) comment: 'Lot of relations in python points to references. And some nodes can return lot of those references such as call, subscript, tuple, attribute. I am here to group those dependences.').
805+
tReturnReferenceable := (builder newTraitNamed: #TReturnReferenceable) comment: 'Lot of relations in python points to references. And some nodes can return lot of those references such as call, subscript, tuple, attribute. I am here to group those dependences.'.
800806

801807
tSplatExpression := (builder newTraitNamed: #TSplatExpression) comment: 'My users are expressions that can be in a collection splat. For example in `[ *getList(), 3 ]`, we have a list splat on the call `getList()`. Get list, is the expression of the splat.'.
802808

803809
tSplatParameterTarget := (builder newTraitNamed: #TSplatParameterTarget) comment: 'My users are parameter target in a splat. For example in `def f(*list): pass`, we have a list splat parameter named list.'.
804810

805811
tSuperclass := (builder newTraitNamed: #TSuperclass) comment: 'My users are expressions that can define a superclass in a class declaration.'.
806812

807-
(tTypeContent := builder newTraitNamed: #TTypeContent) comment: 'My user can be used as a type declaration'.
813+
tTypeContent := (builder newTraitNamed: #TTypeContent) comment: 'My user can be used as a type declaration'.
808814

809815
tUnaryOperator := builder newTraitNamed: #TUnaryOperator.
810816

811817
tWithElseClause := builder newTraitNamed: #TWithElseClause.
812818

813819
tWithStatementItem := (builder newTraitNamed: #TWithStatementItem) comment: 'I represent an entity that can be the item of a with_statement.'.
814820

815-
(tWithTypeParameters := builder newTraitNamed: #TWithTypeParameters) comment: 'I represent an entity with type parameters such as generic types, function/method definition or class definition'.
821+
tWithTypeParameters := (builder newTraitNamed: #TWithTypeParameters) comment: 'I represent an entity with type parameters such as generic types, function/method definition or class definition'.
816822

817823
"Remotes"
818824
tAssignment := self remoteTrait: #TAssignment withPrefix: #FAST.

src/FAST-Python-Model/FASTPyAttributeAccess.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Parents
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
8+
| `caller` | `FASTPyTCallable` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
89
| `invokedIn` | `FASTTNamedEntity` | `invoked` | `FASTTInvocation` | Optional invocation where this name is used|
910
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
1011
| `parentAsPatternTarget` | `FASTPyTAsPatternTarget` | `target` | `FASTPyAsPattern` | |

src/FAST-Python-Model/FASTPyCall.class.st

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
99
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
10+
| `caller` | `FASTPyTCallable` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
1011
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|
1112
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
1213
| `parentAssignmentLeft` | `FASTPyTAssignable` | `left` | `FASTPyAssignment` | |
@@ -26,7 +27,7 @@
2627
| Relation | Origin | Opposite | Type | Comment |
2728
|---|
2829
| `arguments` | `FASTTWithArguments` | `argumentOwner` | `FASTTExpression` | My arguments|
29-
| `callee` | `FASTPyCall` | `caller` | `FASTPyExpression` | I represent what is called. Can be a class for an instantiation. A function invocation. A method invocation. The call of the return of a call. The call of something invoked from an array access...|
30+
| `callee` | `FASTPyCall` | `caller` | `FASTPyTCallable` | I represent what is called. Can be a class for an instantiation. A function invocation. A method invocation. The call of the return of a call. The call of something invoked from an array access...|
3031
| `invoked` | `FASTTInvocation` | `invokedIn` | `FASTTNamedEntity` | The name of the behavioural invoked|
3132
3233
@@ -45,7 +46,7 @@ Class {
4546
#traits : 'FASTPyTReturnReferenceable + FASTPyTWithStatementItem + FASTTInvocation',
4647
#classTraits : 'FASTPyTReturnReferenceable classTrait + FASTPyTWithStatementItem classTrait + FASTTInvocation classTrait',
4748
#instVars : [
48-
'#callee => FMOne type: #FASTPyExpression opposite: #caller'
49+
'#callee => FMOne type: #FASTPyTCallable opposite: #caller'
4950
],
5051
#category : 'FAST-Python-Model-Entities',
5152
#package : 'FAST-Python-Model',
@@ -63,7 +64,7 @@ FASTPyCall class >> annotation [
6364

6465
{ #category : 'accessing' }
6566
FASTPyCall >> callee [
66-
"Relation named: #callee type: #FASTPyExpression opposite: #caller"
67+
"Relation named: #callee type: #FASTPyTCallable opposite: #caller"
6768

6869
<generated>
6970
<FMComment: 'I represent what is called. Can be a class for an instantiation. A function invocation. A method invocation. The call of the return of a call. The call of something invoked from an array access...'>

src/FAST-Python-Model/FASTPyConditionalExpression.class.st

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Parents
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
8+
| `caller` | `FASTPyTCallable` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
89
| `parentClassDefinition` | `FASTPyTSuperclass` | `superclasses` | `FASTPyClassDefinition` | |
910
1011
### Children
@@ -20,8 +21,8 @@
2021
Class {
2122
#name : 'FASTPyConditionalExpression',
2223
#superclass : 'FASTPyExpression',
23-
#traits : 'FASTPyTSuperclass + FASTTWithCondition',
24-
#classTraits : 'FASTPyTSuperclass classTrait + FASTTWithCondition classTrait',
24+
#traits : 'FASTPyTCallable + FASTPyTSuperclass + FASTTWithCondition',
25+
#classTraits : 'FASTPyTCallable classTrait + FASTPyTSuperclass classTrait + FASTTWithCondition classTrait',
2526
#instVars : [
2627
'#elseExpression => FMOne type: #FASTPyExpression opposite: #conditionalExpressionElseOwner',
2728
'#thenExpression => FMOne type: #FASTPyExpression opposite: #conditionalExpressionThenOwner'

src/FAST-Python-Model/FASTPyExpression.class.st

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
99
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
1010
| `attributeObjectOwner` | `FASTPyExpression` | `value` | `FASTPyAttributeAccess` | My parent if I define the object of an attribute access (if it's the case).|
11-
| `caller` | `FASTPyExpression` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
1211
| `collectionInitializer` | `FASTPyExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1312
| `conditionalExpressionElseOwner` | `FASTPyExpression` | `elseExpression` | `FASTPyConditionalExpression` | |
1413
| `conditionalExpressionThenOwner` | `FASTPyExpression` | `thenExpression` | `FASTPyConditionalExpression` | |
@@ -64,7 +63,6 @@ Class {
6463
#classTraits : 'FASTPyTTypeContent classTrait + FASTTExpression classTrait',
6564
#instVars : [
6665
'#attributeObjectOwner => FMOne type: #FASTPyAttributeAccess opposite: #value',
67-
'#caller => FMOne type: #FASTPyCall opposite: #callee',
6866
'#collectionInitializer => FMOne type: #FASTPyCollectionInitializer opposite: #initializers',
6967
'#conditionalExpressionElseOwner => FMOne type: #FASTPyConditionalExpression opposite: #elseExpression',
7068
'#conditionalExpressionThenOwner => FMOne type: #FASTPyConditionalExpression opposite: #thenExpression',
@@ -135,31 +133,6 @@ FASTPyExpression >> attributeObjectOwnerGroup [
135133
^ MooseSpecializedGroup with: self attributeObjectOwner
136134
]
137135

138-
{ #category : 'accessing' }
139-
FASTPyExpression >> caller [
140-
"Relation named: #caller type: #FASTPyCall opposite: #callee"
141-
142-
<generated>
143-
<FMComment: 'The call entity calling me (if it''s the case)'>
144-
<container>
145-
<derived>
146-
^ caller
147-
]
148-
149-
{ #category : 'accessing' }
150-
FASTPyExpression >> caller: anObject [
151-
152-
<generated>
153-
caller := anObject
154-
]
155-
156-
{ #category : 'navigation' }
157-
FASTPyExpression >> callerGroup [
158-
<generated>
159-
<navigation: 'Caller'>
160-
^ MooseSpecializedGroup with: self caller
161-
]
162-
163136
{ #category : 'accessing' }
164137
FASTPyExpression >> collectionInitializer [
165138
"Relation named: #collectionInitializer type: #FASTPyCollectionInitializer opposite: #initializers"

src/FAST-Python-Model/FASTPyIdentifier.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Parents
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
8+
| `caller` | `FASTPyTCallable` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
89
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
910
| `parentAsPatternTarget` | `FASTPyTAsPatternTarget` | `target` | `FASTPyAsPattern` | |
1011
| `parentAssignmentLeft` | `FASTPyTAssignable` | `left` | `FASTPyAssignment` | |

src/FAST-Python-Model/FASTPyLambda.class.st

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Parents
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
8+
| `caller` | `FASTPyTCallable` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
89
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
910
1011
### Children
@@ -19,8 +20,8 @@
1920
Class {
2021
#name : 'FASTPyLambda',
2122
#superclass : 'FASTPyExpression',
22-
#traits : 'FASTPyTDecoratorExpression + FASTTWithParameters',
23-
#classTraits : 'FASTPyTDecoratorExpression classTrait + FASTTWithParameters classTrait',
23+
#traits : 'FASTPyTCallable + FASTPyTDecoratorExpression + FASTTWithParameters',
24+
#classTraits : 'FASTPyTCallable classTrait + FASTPyTDecoratorExpression classTrait + FASTTWithParameters classTrait',
2425
#instVars : [
2526
'#expression => FMOne type: #FASTPyExpression opposite: #lambdaOwner'
2627
],

src/FAST-Python-Model/FASTPySubscript.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Parents
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
8+
| `caller` | `FASTPyTCallable` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
89
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
910
| `parentAsPatternTarget` | `FASTPyTAsPatternTarget` | `target` | `FASTPyAsPattern` | |
1011
| `parentAssignmentLeft` | `FASTPyTAssignable` | `left` | `FASTPyAssignment` | |
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"
2+
I represent something that can be the receiver of a call
3+
4+
## Relations
5+
======================
6+
7+
### Parents
8+
| Relation | Origin | Opposite | Type | Comment |
9+
|---|
10+
| `caller` | `FASTPyTCallable` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
11+
12+
13+
14+
"
15+
Trait {
16+
#name : 'FASTPyTCallable',
17+
#instVars : [
18+
'#caller => FMOne type: #FASTPyCall opposite: #callee'
19+
],
20+
#category : 'FAST-Python-Model-Traits',
21+
#package : 'FAST-Python-Model',
22+
#tag : 'Traits'
23+
}
24+
25+
{ #category : 'meta' }
26+
FASTPyTCallable classSide >> annotation [
27+
28+
<FMClass: #TCallable super: #Object>
29+
<package: #'FAST-Python-Model'>
30+
<generated>
31+
^ self
32+
]
33+
34+
{ #category : 'accessing' }
35+
FASTPyTCallable >> caller [
36+
"Relation named: #caller type: #FASTPyCall opposite: #callee"
37+
38+
<generated>
39+
<FMComment: 'The call entity calling me (if it''s the case)'>
40+
<container>
41+
<derived>
42+
^ caller
43+
]
44+
45+
{ #category : 'accessing' }
46+
FASTPyTCallable >> caller: anObject [
47+
48+
<generated>
49+
caller := anObject
50+
]
51+
52+
{ #category : 'navigation' }
53+
FASTPyTCallable >> callerGroup [
54+
<generated>
55+
<navigation: 'Caller'>
56+
^ MooseSpecializedGroup with: self caller
57+
]

src/FAST-Python-Model/FASTPyTReturnReferenceable.trait.st

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Lot of relations in python points to references. And some nodes can return lot o
77
### Parents
88
| Relation | Origin | Opposite | Type | Comment |
99
|---|
10+
| `caller` | `FASTPyTCallable` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
1011
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
1112
| `parentAssignmentLeft` | `FASTPyTAssignable` | `left` | `FASTPyAssignment` | |
1213
| `parentClassDefinition` | `FASTPyTSuperclass` | `superclasses` | `FASTPyClassDefinition` | |
@@ -20,8 +21,8 @@ Lot of relations in python points to references. And some nodes can return lot o
2021
"
2122
Trait {
2223
#name : 'FASTPyTReturnReferenceable',
23-
#traits : 'FASTPyTAsPatternSource + FASTPyTAssignable + FASTPyTDecoratorExpression + FASTPyTDeletable + FASTPyTRaised + FASTPyTSplatExpression + FASTPyTSuperclass',
24-
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTAssignable classTrait + FASTPyTDecoratorExpression classTrait + FASTPyTDeletable classTrait + FASTPyTRaised classTrait + FASTPyTSplatExpression classTrait + FASTPyTSuperclass classTrait',
24+
#traits : 'FASTPyTAsPatternSource + FASTPyTAssignable + FASTPyTCallable + FASTPyTDecoratorExpression + FASTPyTDeletable + FASTPyTRaised + FASTPyTSplatExpression + FASTPyTSuperclass',
25+
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTAssignable classTrait + FASTPyTCallable classTrait + FASTPyTDecoratorExpression classTrait + FASTPyTDeletable classTrait + FASTPyTRaised classTrait + FASTPyTSplatExpression classTrait + FASTPyTSuperclass classTrait',
2526
#category : 'FAST-Python-Model-Traits',
2627
#package : 'FAST-Python-Model',
2728
#tag : 'Traits'

0 commit comments

Comments
 (0)