Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visitor #31

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 103 additions & 4 deletions src/FAST-Fortran-Tests/FASTFortranExporterVisitorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ FASTFortranExporterVisitorTest >> assertExport: anEntity equals: expectedString
self assert: generated equals: expectedString
]

{ #category : #'entity creation' }
FASTFortranExporterVisitorTest >> characterType: dimension [
^FASTFortranCharacterType new
]

{ #category : #'entity creation' }
FASTFortranExporterVisitorTest >> declarationStatement: type variables: aCollection [
^FASTFortranDeclarationStatement new
Expand All @@ -42,16 +47,33 @@ FASTFortranExporterVisitorTest >> entity: owner statementBlock: aCollection [
yourself
]

{ #category : #'entity creation' }
FASTFortranExporterVisitorTest >> externalStatement: aName [
^FASTFortranExternalStatement new
name: aName ;
yourself
]

{ #category : #'entity creation' }
FASTFortranExporterVisitorTest >> implicitStatement [
^FASTFortranImplicitStatement new
]

{ #category : #'entity creation' }
FASTFortranExporterVisitorTest >> integerType [
FASTFortranExporterVisitorTest >> integerType: dimension [
^FASTFortranIntegerType new
]

{ #category : #'entity creation' }
FASTFortranExporterVisitorTest >> logicalType: dimension [
^FASTFortranLogicalType new
]

{ #category : #'entity creation' }
FASTFortranExporterVisitorTest >> realType: dimension [
^FASTFortranRealType new
]

{ #category : #'entity creation' }
FASTFortranExporterVisitorTest >> scalarVariable: aName [
^FASTFortranScalarVariable new
Expand Down Expand Up @@ -115,6 +137,23 @@ FASTFortranExporterVisitorTest >> testEmptySubroutineTwoParameters [
'
]

{ #category : #tests }
FASTFortranExporterVisitorTest >> testExternalStatement [
| sub |
sub := self subroutine: 'blah'.
self
entity: sub
statementBlock: { self externalStatement: 'aVar' }.

self
assertExport: sub
equals:
' subroutine blah()
external aVar
end
'
]

{ #category : #tests }
FASTFortranExporterVisitorTest >> testImplicitStatement [
| sub |
Expand All @@ -132,6 +171,66 @@ FASTFortranExporterVisitorTest >> testImplicitStatement [
'
]

{ #category : #tests }
FASTFortranExporterVisitorTest >> testOneDeclarationCharcaterType [
| sub |
sub := self subroutine: 'blah'.
self
entity: sub
statementBlock: {
self
declarationStatement: (self characterType: nil)
variables: #(r) }.

self
assertExport: sub
equals:
' subroutine blah()
character r
end
'
]

{ #category : #tests }
FASTFortranExporterVisitorTest >> testOneDeclarationLogicalType [
| sub |
sub := self subroutine: 'blah'.
self
entity: sub
statementBlock: {
self
declarationStatement: (self logicalType: nil)
variables: #(r) }.

self
assertExport: sub
equals:
' subroutine blah()
logical r
end
'
]

{ #category : #tests }
FASTFortranExporterVisitorTest >> testOneDeclarationRealType [
| sub |
sub := self subroutine: 'blah'.
self
entity: sub
statementBlock: {
self
declarationStatement: (self realType: nil)
variables: #(r) }.

self
assertExport: sub
equals:
' subroutine blah()
real r
end
'
]

{ #category : #tests }
FASTFortranExporterVisitorTest >> testOneDeclarationTwoVariables [
| sub |
Expand All @@ -140,7 +239,7 @@ FASTFortranExporterVisitorTest >> testOneDeclarationTwoVariables [
entity: sub
statementBlock: {
self
declarationStatement: self integerType
declarationStatement: (self integerType: nil)
variables: #(i j) }.

self
Expand All @@ -160,10 +259,10 @@ FASTFortranExporterVisitorTest >> testTwoDeclarationsTwoVariables [
entity: sub
statementBlock: {
self
declarationStatement: self integerType
declarationStatement: (self integerType: nil)
variables: #(i) .
self
declarationStatement: self integerType
declarationStatement: (self integerType: nil)
variables: #(j) }.

self
Expand Down
24 changes: 24 additions & 0 deletions src/FAST-Fortran/FASTFortranExporterVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ FASTFortranExporterVisitor >> stream [
^stream ifNil: [ stream := WriteStream on: '' ]
]

{ #category : #'visiting - expressions' }
FASTFortranExporterVisitor >> visitFASTFortranCharacterType: aFASTFortranType [
self << 'character'
]

{ #category : #'visiting - statements' }
FASTFortranExporterVisitor >> visitFASTFortranDeclarationStatement: aFASTFortranDeclarationStatement [
self sixSpaces.
Expand All @@ -51,6 +56,15 @@ FASTFortranExporterVisitor >> visitFASTFortranDeclarationStatement: aFASTFortran

]

{ #category : #'visiting - statements' }
FASTFortranExporterVisitor >> visitFASTFortranExternalStatement: aFASTFortranExternalStatement [
self
sixSpaces ;
<< 'external ' ;
<< aFASTFortranExternalStatement name ;
newLine
]

{ #category : #'visiting - programUnits' }
FASTFortranExporterVisitor >> visitFASTFortranFunction: aFASTFortranFunction [
<generated>
Expand All @@ -71,6 +85,11 @@ FASTFortranExporterVisitor >> visitFASTFortranIntegerType: aFASTFortranIntegerTy
self << 'integer'
]

{ #category : #'visiting - expressions' }
FASTFortranExporterVisitor >> visitFASTFortranLogicalType: aFASTFortranType [
self << 'logical'
]

{ #category : #visiting }
FASTFortranExporterVisitor >> visitFASTFortranModel: aFASTFortranModel [
(self rootEntitiesIn: aFASTFortranModel) do: [ :rootEntity |
Expand All @@ -89,6 +108,11 @@ FASTFortranExporterVisitor >> visitFASTFortranProcedure: aFASTFortranProcedure [

]

{ #category : #'visiting - expressions' }
FASTFortranExporterVisitor >> visitFASTFortranRealType: aFASTFortranType [
self << 'real'
]

{ #category : #'visiting - programUnits' }
FASTFortranExporterVisitor >> visitFASTFortranSubroutine: aFASTFortranSubroutine [
self
Expand Down