add the struct name to the struct field access expression node

This commit is contained in:
2020-03-06 00:18:48 +01:00
parent 1693eb6426
commit e2986b3d65
2 changed files with 6 additions and 3 deletions

View File

@@ -289,14 +289,15 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
}
// Get the type of the result of this expression
String structName = variableDef.type.getName();
Type resultType;
try {
resultType = Helper.drillType(this.structs, variableDef.type.getName(), path, 0);
resultType = Helper.drillType(this.structs, structName, path, 0);
} catch (Exception e) {
throw new RuntimeException(Helper.getErrorPrefix(line, col) + e.getMessage());
}
Node result = new StructFieldAccessExpression(varName, path);
Node result = new StructFieldAccessExpression(varName, structName, path);
result.type = resultType;
result.line = line;
result.col = col;

View File

@@ -4,10 +4,12 @@ import de.hsrm.compiler.Klang.visitors.Visitor;
public class StructFieldAccessExpression extends Expression {
public String varName;
public String structName;
public String[] path;
public StructFieldAccessExpression(String varName, String[] path) {
public StructFieldAccessExpression(String varName, String structName, String[] path) {
this.varName = varName;
this.structName = structName;
this.path = path;
}