mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 18:34:03 +03:00
Fix polymorphic frame slot writes (#710)
This commit is contained in:
parent
25494bbb43
commit
1c8600e53f
@ -38,7 +38,7 @@ public abstract class AssignmentNode extends ExpressionNode {
|
||||
* @param ctx language context for global values access
|
||||
* @return the unit type
|
||||
*/
|
||||
@Specialization
|
||||
@Specialization(guards = "isLongOrIllegal(frame)")
|
||||
protected Object writeLong(
|
||||
VirtualFrame frame, long value, @CachedContext(Language.class) Context ctx) {
|
||||
frame.getFrameDescriptor().setFrameSlotKind(getFrameSlot(), FrameSlotKind.Long);
|
||||
@ -64,6 +64,11 @@ public abstract class AssignmentNode extends ExpressionNode {
|
||||
return ctx.getUnit().newInstance();
|
||||
}
|
||||
|
||||
boolean isLongOrIllegal(VirtualFrame frame) {
|
||||
FrameSlotKind kind = frame.getFrameDescriptor().getFrameSlotKind(getFrameSlot());
|
||||
return kind == FrameSlotKind.Long || kind == FrameSlotKind.Illegal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current frame slot
|
||||
*
|
||||
|
@ -16,10 +16,10 @@ import org.enso.interpreter.runtime.scope.FramePointer;
|
||||
/** Reads from a local target (variable or call target). */
|
||||
@NodeInfo(shortName = "readVar", description = "Access local variable value.")
|
||||
@NodeField(name = "framePointer", type = FramePointer.class)
|
||||
public abstract class ReadLocalTargetNode extends ExpressionNode {
|
||||
public abstract class ReadLocalVariableNode extends ExpressionNode {
|
||||
public abstract FramePointer getFramePointer();
|
||||
|
||||
ReadLocalTargetNode() {}
|
||||
ReadLocalVariableNode() {}
|
||||
|
||||
/**
|
||||
* Creates an instance of this node.
|
||||
@ -27,8 +27,8 @@ public abstract class ReadLocalTargetNode extends ExpressionNode {
|
||||
* @param pointer the pointer to the local target
|
||||
* @return a node that reads from {@code pointer}
|
||||
*/
|
||||
public static ReadLocalTargetNode build(FramePointer pointer) {
|
||||
return ReadLocalTargetNodeGen.create(pointer);
|
||||
public static ReadLocalVariableNode build(FramePointer pointer) {
|
||||
return ReadLocalVariableNodeGen.create(pointer);
|
||||
}
|
||||
|
||||
/**
|
@ -30,7 +30,7 @@ import org.enso.interpreter.node.expression.literal.{
|
||||
IntegerLiteralNode,
|
||||
TextLiteralNode
|
||||
}
|
||||
import org.enso.interpreter.node.scope.{AssignmentNode, ReadLocalTargetNode}
|
||||
import org.enso.interpreter.node.scope.{AssignmentNode, ReadLocalVariableNode}
|
||||
import org.enso.interpreter.node.{
|
||||
ClosureRootNode,
|
||||
ExpressionNode => RuntimeExpression
|
||||
@ -543,7 +543,7 @@ class IRToTruffle(
|
||||
if (nameStr == Constants.Names.CURRENT_MODULE) {
|
||||
ConstructorNode.build(moduleScope.getAssociatedType)
|
||||
} else if (slot.isDefined) {
|
||||
ReadLocalTargetNode.build(slot.get)
|
||||
ReadLocalVariableNode.build(slot.get)
|
||||
} else if (atomCons.isDefined) {
|
||||
ConstructorNode.build(atomCons.get)
|
||||
} else {
|
||||
|
@ -4,7 +4,7 @@ import org.enso.interpreter.node.callable.function.CreateFunctionNode
|
||||
import org.enso.interpreter.node.callable.thunk.ForceNode
|
||||
import org.enso.interpreter.node.controlflow.MatchNode
|
||||
import org.enso.interpreter.node.expression.literal.IntegerLiteralNode
|
||||
import org.enso.interpreter.node.scope.{AssignmentNode, ReadLocalTargetNode}
|
||||
import org.enso.interpreter.node.scope.{AssignmentNode, ReadLocalVariableNode}
|
||||
import org.enso.interpreter.test.InterpreterTest
|
||||
|
||||
class CodeLocationsTest extends InterpreterTest {
|
||||
@ -63,9 +63,9 @@ class CodeLocationsTest extends InterpreterTest {
|
||||
|""".stripMargin
|
||||
instrumenter.assertNodeExists(12, 13, classOf[AssignmentNode])
|
||||
instrumenter.assertNodeExists(30, 9, classOf[AssignmentNode])
|
||||
instrumenter.assertNodeExists(34, 1, classOf[ReadLocalTargetNode])
|
||||
instrumenter.assertNodeExists(38, 1, classOf[ReadLocalTargetNode])
|
||||
instrumenter.assertNodeExists(55, 1, classOf[ReadLocalTargetNode])
|
||||
instrumenter.assertNodeExists(34, 1, classOf[ReadLocalVariableNode])
|
||||
instrumenter.assertNodeExists(38, 1, classOf[ReadLocalVariableNode])
|
||||
instrumenter.assertNodeExists(55, 1, classOf[ReadLocalVariableNode])
|
||||
eval(code)
|
||||
()
|
||||
}
|
||||
@ -83,8 +83,9 @@ class CodeLocationsTest extends InterpreterTest {
|
||||
|
|
||||
|main = Unit.method
|
||||
|""".stripMargin
|
||||
|
||||
instrumenter.assertNodeExists(80, 5, classOf[ApplicationNode])
|
||||
instrumenter.assertNodeExists(98, 1, classOf[ReadLocalTargetNode])
|
||||
instrumenter.assertNodeExists(98, 1, classOf[ReadLocalVariableNode])
|
||||
instrumenter.assertNodeExists(94, 7, classOf[ApplicationNode])
|
||||
instrumenter.assertNodeExists(106, 9, classOf[ApplicationNode])
|
||||
eval(code)
|
||||
@ -145,9 +146,10 @@ class CodeLocationsTest extends InterpreterTest {
|
||||
| foo = x -> (y = bar x) -> x + y
|
||||
| foo 0
|
||||
|""".stripMargin
|
||||
|
||||
instrumenter.assertNodeExists(53, 5, classOf[ApplicationNode])
|
||||
instrumenter.assertNodeExists(53, 3, classOf[ReadLocalTargetNode])
|
||||
instrumenter.assertNodeExists(57, 1, classOf[ReadLocalTargetNode])
|
||||
instrumenter.assertNodeExists(53, 3, classOf[ReadLocalVariableNode])
|
||||
instrumenter.assertNodeExists(57, 1, classOf[ReadLocalVariableNode])
|
||||
eval(code)
|
||||
()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user