Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
2
2022fall-Compiler_CMinus
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李晓奇
2022fall-Compiler_CMinus
Commits
5bb2a40e
Commit
5bb2a40e
authored
Oct 26, 2022
by
李晓奇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
24 points, emmmmm
parent
1851e507
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
src/cminusfc/cminusf_builder.cpp
src/cminusfc/cminusf_builder.cpp
+13
-10
No files found.
src/cminusfc/cminusf_builder.cpp
View file @
5bb2a40e
...
...
@@ -373,14 +373,14 @@ void CminusfBuilder::visit(ASTSimpleExpression &node) {
//!TODO: This function is empty now.
// Add some code here.
//
node
.
additive_expression_l
->
accept
(
*
this
);
if
(
node
.
additive_expression_r
)
{
node
.
additive_expression_l
->
accept
(
*
this
);
auto
lvalue
=
cur_value
;
node
.
additive_expression_r
->
accept
(
*
this
);
auto
rvalue
=
cur_value
;
// type cast
if
(
not
Type
::
is_eq_type
(
lvalue
->
get_type
(),
rvalue
->
get_type
()))
type_cast
(
lvalue
,
rvalue
,
"
addo
p"
);
type_cast
(
lvalue
,
rvalue
,
"
cm
p"
);
bool
float_cmp
=
lvalue
->
get_type
()
->
is_float_type
();
switch
(
node
.
op
)
{
case
OP_LE
:
{
...
...
@@ -426,7 +426,8 @@ void CminusfBuilder::visit(ASTSimpleExpression &node) {
break
;
}
}
}
}
else
node
.
additive_expression_l
->
accept
(
*
this
);
}
// Done
...
...
@@ -434,10 +435,10 @@ void CminusfBuilder::visit(ASTAdditiveExpression &node) {
//!TODO: This function is empty now.
// Add some code here.
//
node
.
term
->
accept
(
*
this
);
if
(
node
.
additive_expression
)
{
auto
lvalue
=
cur_value
;
node
.
additive_expression
->
accept
(
*
this
);
auto
lvalue
=
cur_value
;
node
.
term
->
accept
(
*
this
);
auto
rvalue
=
cur_value
;
// type cast
if
(
not
Type
::
is_eq_type
(
lvalue
->
get_type
(),
rvalue
->
get_type
()))
...
...
@@ -460,21 +461,22 @@ void CminusfBuilder::visit(ASTAdditiveExpression &node) {
break
;
}
}
}
}
else
node
.
term
->
accept
(
*
this
);
}
// Done
void
CminusfBuilder
::
visit
(
ASTTerm
&
node
)
{
//!TODO: This function is empty now.
// Add some code here.
node
.
factor
->
accept
(
*
this
);
if
(
node
.
term
)
{
auto
lvalue
=
cur_value
;
node
.
term
->
accept
(
*
this
);
auto
lvalue
=
cur_value
;
node
.
factor
->
accept
(
*
this
);
auto
rvalue
=
cur_value
;
// type cast
if
(
not
Type
::
is_eq_type
(
lvalue
->
get_type
(),
rvalue
->
get_type
()))
type_cast
(
lvalue
,
rvalue
,
"
addop
"
);
type_cast
(
lvalue
,
rvalue
,
"
mul
"
);
bool
float_type
=
lvalue
->
get_type
()
->
is_float_type
();
// now left and right is the same type
switch
(
node
.
op
)
{
...
...
@@ -493,7 +495,8 @@ void CminusfBuilder::visit(ASTTerm &node) {
break
;
}
}
}
}
else
node
.
factor
->
accept
(
*
this
);
}
// Done
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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