Skip to content

Commit d79e5c0

Browse files
committed
Manage assignment type
1 parent 1bb2d3e commit d79e5c0

4 files changed

Lines changed: 105 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ FASTPythonMetamodelGenerator >> defineRelations [
605605

606606
(assignment property: #left) <>- (tAssignable property: #parentAssignmentLeft).
607607
(assignment property: #right) <>- (expression property: #parentAssignmentRight).
608+
(assignment property: #type) <>- (type property: #parentAssignment).
608609

609610
(asPattern property: #target) <>- (tAsPatternTarget property: #parentAsPatternTarget).
610611

‎src/FAST-Python-Model/FASTPyAssignment.class.st‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
|---|
88
| `left` | `FASTPyAssignment` | `parentAssignmentLeft` | `FASTPyTAssignable` | |
99
| `right` | `FASTPyAssignment` | `parentAssignmentRight` | `FASTPyExpression` | |
10+
| `type` | `FASTPyAssignment` | `parentAssignment` | `FASTPyType` | |
1011
1112
1213
@@ -16,7 +17,8 @@ Class {
1617
#superclass : 'FASTPyStatement',
1718
#instVars : [
1819
'#left => FMOne type: #FASTPyTAssignable opposite: #parentAssignmentLeft',
19-
'#right => FMOne type: #FASTPyExpression opposite: #parentAssignmentRight'
20+
'#right => FMOne type: #FASTPyExpression opposite: #parentAssignmentRight',
21+
'#type => FMOne type: #FASTPyType opposite: #parentAssignment'
2022
],
2123
#category : 'FAST-Python-Model-Entities',
2224
#package : 'FAST-Python-Model',
@@ -75,3 +77,25 @@ FASTPyAssignment >> rightGroup [
7577
<navigation: 'Right'>
7678
^ MooseSpecializedGroup with: self right
7779
]
80+
81+
{ #category : 'accessing' }
82+
FASTPyAssignment >> type [
83+
"Relation named: #type type: #FASTPyType opposite: #parentAssignment"
84+
85+
<generated>
86+
^ type
87+
]
88+
89+
{ #category : 'accessing' }
90+
FASTPyAssignment >> type: anObject [
91+
92+
<generated>
93+
type := anObject
94+
]
95+
96+
{ #category : 'navigation' }
97+
FASTPyAssignment >> typeGroup [
98+
<generated>
99+
<navigation: 'Type'>
100+
^ MooseSpecializedGroup with: self type
101+
]

‎src/FAST-Python-Model/FASTPyType.class.st‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Parents
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
8+
| `parentAssignment` | `FASTPyType` | `type` | `FASTPyAssignment` | |
89
| `parentFunctionDefinition` | `FASTPyType` | `returnType` | `FASTPyFunctionDefinition` | |
910
| `parentParameter` | `FASTPyType` | `type` | `FASTPyParameter` | |
1011
| `parentyTypeAliasStatementAlias` | `FASTPyType` | `left` | `FASTPyTypeAliasStatement` | |
@@ -23,6 +24,7 @@ Class {
2324
#superclass : 'FASTPyEntity',
2425
#instVars : [
2526
'#expression => FMOne type: #FASTPyExpression opposite: #parentType',
27+
'#parentAssignment => FMOne type: #FASTPyAssignment opposite: #type',
2628
'#parentFunctionDefinition => FMOne type: #FASTPyFunctionDefinition opposite: #returnType',
2729
'#parentParameter => FMOne type: #FASTPyParameter opposite: #type',
2830
'#parentyTypeAliasStatementAlias => FMOne type: #FASTPyTypeAliasStatement opposite: #left',
@@ -64,6 +66,30 @@ FASTPyType >> expressionGroup [
6466
^ MooseSpecializedGroup with: self expression
6567
]
6668

69+
{ #category : 'accessing' }
70+
FASTPyType >> parentAssignment [
71+
"Relation named: #parentAssignment type: #FASTPyAssignment opposite: #type"
72+
73+
<generated>
74+
<container>
75+
<derived>
76+
^ parentAssignment
77+
]
78+
79+
{ #category : 'accessing' }
80+
FASTPyType >> parentAssignment: anObject [
81+
82+
<generated>
83+
parentAssignment := anObject
84+
]
85+
86+
{ #category : 'navigation' }
87+
FASTPyType >> parentAssignmentGroup [
88+
<generated>
89+
<navigation: 'ParentAssignment'>
90+
^ MooseSpecializedGroup with: self parentAssignment
91+
]
92+
6793
{ #category : 'accessing' }
6894
FASTPyType >> parentFunctionDefinition [
6995
"Relation named: #parentFunctionDefinition type: #FASTPyFunctionDefinition opposite: #returnType"

‎src/FAST-Python-Tools-Tests/FASTPythonImporterTest.class.st‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,59 @@ FASTPythonImporterTest >> testAssignmentToUnaryOperator [
24472447
self assert: self topEntity operator equals: '-'
24482448
]
24492449

2450+
{ #category : 'tests - assignments' }
2451+
FASTPythonImporterTest >> testAssignmentType [
2452+
<generated>
2453+
"Generated as regression test by FASTPyImporterTestGenerator>>#generateTestNamed:fromCode:protocol:
2454+
Regenerate executing: self regenerateTest: #testAssignmentType "
2455+
2456+
self parse: 'int: x = 1'.
2457+
2458+
self assert: (fast allWithType: FASTPyAssignment) size equals: 1.
2459+
self assert: (fast allWithType: FASTPyIdentifier) size equals: 1.
2460+
self assert: (fast allWithType: FASTPyInteger) size equals: 1.
2461+
self assert: (fast allWithType: FASTPyModule) size equals: 1.
2462+
self assert: (fast allWithType: FASTPyType) size equals: 1.
2463+
self assert: (fast allWithType: FASTPyVariable) size equals: 1.
2464+
2465+
stack push: fast rootEntities anyOne containedEntities first.
2466+
self assert: self topEntity sourceCode equals: 'int: x = 1'.
2467+
self assert: (self topEntity isOfType: FASTPyAssignment).
2468+
2469+
"Testing value of monovalue relation left"
2470+
self assert: self topEntity left isNotNil.
2471+
2472+
stack push: self topEntity left.
2473+
self assert: self topEntity sourceCode equals: 'int'.
2474+
self assert: (self topEntity isOfType: FASTPyVariable).
2475+
self assert: (self topEntity isOfType: FASTTVariableEntity).
2476+
stack pop.
2477+
2478+
"Testing value of monovalue relation right"
2479+
self assert: self topEntity right isNotNil.
2480+
2481+
stack push: self topEntity right.
2482+
self assert: self topEntity sourceCode equals: '1'.
2483+
self assert: (self topEntity isOfType: FASTPyInteger).
2484+
self assert: (self topEntity isOfType: FASTTLiteral).
2485+
self assert: (self topEntity isOfType: FASTTNumericalLiteral).
2486+
stack pop.
2487+
2488+
"Testing value of monovalue relation type"
2489+
self assert: self topEntity type isNotNil.
2490+
2491+
stack push: self topEntity type.
2492+
self assert: self topEntity sourceCode equals: 'x'.
2493+
self assert: (self topEntity isOfType: FASTPyType).
2494+
2495+
"Testing value of monovalue relation expression"
2496+
self assert: self topEntity expression isNotNil.
2497+
2498+
stack push: self topEntity expression.
2499+
self assert: self topEntity sourceCode equals: 'x'.
2500+
self assert: (self topEntity isOfType: FASTPyIdentifier)
2501+
]
2502+
24502503
{ #category : 'tests - accesses' }
24512504
FASTPythonImporterTest >> testAttributeAccess [
24522505
<generated>

0 commit comments

Comments
 (0)