Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
C Compiler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gyuri
C Compiler
Commits
a359e28c
Commit
a359e28c
authored
Nov 21, 2020
by
gyuri
Browse files
Options
Downloads
Patches
Plain Diff
Implement initializer in declaration
parent
b58eb1e8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cg.c
+8
-1
8 additions, 1 deletion
src/cg.c
with
8 additions
and
1 deletion
src/cg.c
+
8
−
1
View file @
a359e28c
...
@@ -275,7 +275,14 @@ static void cg_gen_declaration(struct state *s, const struct ast_node *n) {
...
@@ -275,7 +275,14 @@ static void cg_gen_declaration(struct state *s, const struct ast_node *n) {
// TODO: type. now we assume literally EVERY type is 64 bit...
// TODO: type. now we assume literally EVERY type is 64 bit...
int
size
=
8
;
int
size
=
8
;
s
->
sp
-=
size
;
s
->
sp
-=
size
;
hashmap_put
(
&
s
->
vars
,
dd
->
ident
,
&
s
->
sp
);
int
loc
=
s
->
sp
;
hashmap_put
(
&
s
->
vars
,
dd
->
ident
,
&
loc
);
if
(
ni
->
init_declarator
.
initializer
)
{
val
val_init
=
cg_gen_expr
(
s
,
ni
->
init_declarator
.
initializer
);
val_read
(
s
,
&
val_init
,
"rax"
);
val_store
(
s
,
&
(
val
){
.
s
=
loc
},
"rax"
);
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment