Eval: Add the corresponding named type to a struct Value.
This commit is contained in:
@@ -10,6 +10,8 @@ import de.hsrm.compiler.Klang.nodes.loops.DoWhileLoop;
|
|||||||
import de.hsrm.compiler.Klang.nodes.loops.ForLoop;
|
import de.hsrm.compiler.Klang.nodes.loops.ForLoop;
|
||||||
import de.hsrm.compiler.Klang.nodes.loops.WhileLoop;
|
import de.hsrm.compiler.Klang.nodes.loops.WhileLoop;
|
||||||
import de.hsrm.compiler.Klang.nodes.statements.*;
|
import de.hsrm.compiler.Klang.nodes.statements.*;
|
||||||
|
import de.hsrm.compiler.Klang.types.NamedType;
|
||||||
|
import de.hsrm.compiler.Klang.types.NullType;
|
||||||
import de.hsrm.compiler.Klang.types.Type;
|
import de.hsrm.compiler.Klang.types.Type;
|
||||||
|
|
||||||
public class EvalVisitor implements Visitor<Value> {
|
public class EvalVisitor implements Visitor<Value> {
|
||||||
@@ -400,7 +402,7 @@ public class EvalVisitor implements Visitor<Value> {
|
|||||||
@Override
|
@Override
|
||||||
public Value visit(Block e) {
|
public Value visit(Block e) {
|
||||||
for (var stmt : e.statements) {
|
for (var stmt : e.statements) {
|
||||||
Value result = stmt.welcome(this);
|
var result = stmt.welcome(this);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -428,7 +430,7 @@ public class EvalVisitor implements Visitor<Value> {
|
|||||||
this.env = newEnv;
|
this.env = newEnv;
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
Value result = func.block.welcome(this);
|
var result = func.block.welcome(this);
|
||||||
|
|
||||||
// Das alte env wiederherstellen
|
// Das alte env wiederherstellen
|
||||||
this.env = oldEnv;
|
this.env = oldEnv;
|
||||||
@@ -502,7 +504,10 @@ public class EvalVisitor implements Visitor<Value> {
|
|||||||
struct.put(structDef.fields[i].name, arg);
|
struct.put(structDef.fields[i].name, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Value(struct);
|
var structValue = new Value(struct);
|
||||||
|
structValue.type = structDef.type;
|
||||||
|
|
||||||
|
return structValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user