Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
What's new
2
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
lfortran
lfortran
Commits
35f9ff82
Commit
35f9ff82
authored
Aug 31, 2020
by
Ondřej Čertík
Browse files
Merge branch 'fmt6' into 'master'
Generate code for dimension properly See merge request
!566
parents
7f88301a
6f71dc8a
Pipeline
#184048429
passed with stages
in 4 minutes and 39 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lfortran/ast_to_src.cpp
View file @
35f9ff82
...
...
@@ -10,6 +10,14 @@ using LFortran::AST::BaseVisitor;
namespace
LFortran
{
static
inline
AST
::
Num_t
*
EXPR_NUM
(
const
AST
::
ast_t
*
f
)
{
LFORTRAN_ASSERT
(
f
->
type
==
AST
::
astType
::
expr
);
AST
::
expr_t
*
t
=
(
AST
::
expr_t
*
)
f
;
LFORTRAN_ASSERT
(
t
->
type
==
AST
::
exprType
::
Num
);
return
(
AST
::
Num_t
*
)
t
;
}
namespace
{
std
::
string
op2str
(
const
operatorType
type
)
...
...
@@ -837,21 +845,25 @@ public:
}
void
visit_dimension
(
const
dimension_t
&
x
)
{
std
::
string
r
;
std
::
string
left
;
bool
left_is_one
=
false
;
if
(
x
.
m_start
)
{
this
->
visit_expr
(
*
x
.
m_start
);
r
.
append
(
s
);
}
else
{
r
.
append
(
""
);
left
=
s
;
if
(
x
.
m_start
->
type
==
AST
::
exprType
::
Num
)
{
left_is_one
=
(
EXPR_NUM
((
AST
::
ast_t
*
)
x
.
m_start
)
->
m_n
==
1
);
};
}
r
.
append
(
":"
)
;
std
::
string
right
;
if
(
x
.
m_end
)
{
this
->
visit_expr
(
*
x
.
m_end
);
r
.
append
(
s
);
right
=
s
;
}
if
(
left_is_one
&&
right
!=
""
)
{
s
=
right
;
}
else
{
r
.
append
(
""
)
;
s
=
left
+
":"
+
right
;
}
s
=
r
;
}
void
visit_Attribute
(
const
Attribute_t
&
x
)
{
...
...
tests/reference/ast_f90-program_01-133d597.json
View file @
35f9ff82
...
...
@@ -6,7 +6,7 @@
"outfile"
:
null
,
"outfile_hash"
:
null
,
"stdout"
:
"ast_f90-program_01-133d597.stdout"
,
"stdout_hash"
:
"
2f6c59567c1770bf7c1faac760132bf891f684a129757909a8aa9c6f
"
,
"stdout_hash"
:
"
6e36132b4241096b3d2ea3ad10be36fa4cd98b95e439d3b8d954dbb9
"
,
"stderr"
:
null
,
"stderr_hash"
:
null
,
"returncode"
:
0
...
...
tests/reference/ast_f90-program_01-133d597.stdout
View file @
35f9ff82
...
...
@@ -13,7 +13,7 @@ contains
subroutine rand(x)
real, intent(out) :: x
logical, save :: first=.true.
real, save :: u(
1:
2)
real, save :: u(2)
real :: r2
if (first) then
do
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment