Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christoph Reichenbach
EDAP15-exercise-3
Commits
4ccee870
Commit
4ccee870
authored
Dec 13, 2020
by
Christoph Reichenbach
Browse files
Fixed location reporting in structure fields
parent
57691c48
Changes
2
Hide whitespace changes
Inline
Side-by-side
compiler/teal0/backend/IRGen.jrag
View file @
4ccee870
...
@@ -269,6 +269,9 @@ aspect IRGen {
...
@@ -269,6 +269,9 @@ aspect IRGen {
m.getIRFunctions().add(f);
m.getIRFunctions().add(f);
}
}
// Custom postprocessing operations after initial IR construction, e.g., to work around circular dependencies
public void Decl.postprocessIR() {}
syn IRModule Module.genIR() {
syn IRModule Module.genIR() {
String name = getName().stream().collect(Collectors.joining("::"));
String name = getName().stream().collect(Collectors.joining("::"));
...
@@ -278,6 +281,7 @@ aspect IRGen {
...
@@ -278,6 +281,7 @@ aspect IRGen {
// Add code for all class elements
// Add code for all class elements
for (Decl d : getDecls()) {
for (Decl d : getDecls()) {
d.addIRToModule(m);
d.addIRToModule(m);
d.postprocessIR();
}
}
// FIXME: do we still need this code? What does it do that the loop above doesn't do already?
// FIXME: do we still need this code? What does it do that the loop above doesn't do already?
...
...
compiler/teal2/backend/IRGenType.jrag
View file @
4ccee870
...
@@ -14,12 +14,25 @@ aspect IRGenType {
...
@@ -14,12 +14,25 @@ aspect IRGenType {
klass.setSourceLocation(this.sourceLocation());
klass.setSourceLocation(this.sourceLocation());
// set formal type parameters
// set formal type parameters
for (TypeVarDecl d : getTypeFormals()) {
for (TypeVarDecl d : getTypeFormals()) {
klass.addIRTypeFormal(d.genIR());
IRTypeFormal formal = d.genIR();
formal.setSourceLocation(d.sourceLocation());
klass.addIRTypeFormal(formal);
}
}
return klass;
return klass;
}
}
@Override
public void TypeDecl.postprocessIR() {
IRClass klass = this.genIRStruct();
// set fields
for (VarDecl d : getFunFormals()) {
IRVar field = d.genIR();
field.setSourceLocation(d.sourceLocation());
klass.addIRVar(field);
}
}
public void TypeDecl.genCode(IRClass klass) {
public void TypeDecl.genCode(IRClass klass) {
// add the class argument parameters as fields
// add the class argument parameters as fields
for (VarDecl d : getFunFormals()) {
for (VarDecl d : getFunFormals()) {
...
...
Write
Preview
Supports
Markdown
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