Commit 4ccee870 authored by Christoph Reichenbach's avatar Christoph Reichenbach
Browse files

Fixed location reporting in structure fields

parent 57691c48
...@@ -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?
......
...@@ -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()) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment