Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
latte
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zygzagZ
latte
Commits
75ea8c19
Commit
75ea8c19
authored
Jan 14, 2021
by
zygzagZ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tables
parent
e4d71bee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
QuadrupleGenerator.cpp
src/codeGen/QuadrupleGenerator.cpp
+4
-4
Variable.h
src/codeGen/Variable.h
+2
-1
No files found.
src/codeGen/QuadrupleGenerator.cpp
View file @
75ea8c19
...
...
@@ -312,7 +312,6 @@ void QuadrupleGenerator::visitEOr(EOr *p) {
void
QuadrupleGenerator
::
visitEIndexAcc
(
EIndexAcc
*
p
)
{
auto
lhs
=
evalExpr
(
p
->
expr_1
);
auto
index
=
evalExpr
(
p
->
expr_2
);
lastVar
=
alloc
();
auto
type
=
dynamic_pointer_cast
<
Array
>
(
lhs
->
type
);
if
(
!
type
)
{
throw
ParseError
(
"compiler evalExpr Variable has no Array type"
,
p
->
expr_1
);
...
...
@@ -320,11 +319,12 @@ void QuadrupleGenerator::visitEIndexAcc(EIndexAcc *p) {
if
(
!
type
->
type_
)
{
throw
ParseError
(
"compiler evalExpr Variable is Array of no type"
,
p
->
expr_1
);
}
lastVar
=
alloc
(
type
->
type_
->
clone
());
lastVar
->
memory
=
true
;
if
(
type
->
type_
->
size
()
>
4
)
{
// calculate quantifier, we multiply index because size is larger than 4
auto
q
=
alloc
(
type
->
type_
->
size
());
auto
newIndex
=
alloc
();
// calculate var = index * quantifier
addQuad
<
QAssign
>
(
newIndex
,
index
,
Op
::
Mul
,
q
);
...
...
@@ -423,7 +423,7 @@ void QuadrupleGenerator::visitENewArray(ENewArray *p) {
virtSymbol
=
Compiler
::
getVirtName
(
info
);
}
auto
count
=
evalExpr
(
p
->
expr_
);
lastVar
=
alloc
();
lastVar
=
alloc
(
new
Array
(
type
->
clone
())
);
addQuad
<
QAlloc
>
(
lastVar
,
size
,
virtSymbol
,
count
);
}
...
...
@@ -459,7 +459,7 @@ void QuadrupleGenerator::visitNoInit(Init *p) {
void
QuadrupleGenerator
::
assign
(
Expr
*
lval
,
VariablePtr
val
)
{
auto
dest
=
evalLVal
(
lval
);
if
(
dest
->
i
nfo
&&
dest
->
info
->
i
sInstanceVariable
())
{
if
(
dest
->
isInstanceVariable
())
{
// instance variable, need to write it to memory
auto
quad
=
dynamic_pointer_cast
<
QAccess
>
(
lastQuad
);
assert
(
quad
);
...
...
src/codeGen/Variable.h
View file @
75ea8c19
...
...
@@ -23,8 +23,9 @@ public:
int
val
{
0
};
std
::
string
name
;
int
registerColor
=
0
;
bool
memory
=
false
;
bool
isInstanceVariable
()
const
{
return
info
&&
info
->
isInstanceVariable
(
);
}
bool
isInstanceVariable
()
const
{
return
memory
||
(
info
&&
info
->
isInstanceVariable
()
);
}
vector
<
QuadruplePtr
>
uses
;
vector
<
QuadruplePtr
>
writes
;
...
...
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