mirror of
https://codeberg.org/ProgramSnail/truffle-lama.git
synced 2025-12-05 22:38:43 +00:00
var virtual frame fix, other fixes
This commit is contained in:
parent
1068d95010
commit
da785b2faf
7 changed files with 30 additions and 13 deletions
|
|
@ -2,6 +2,7 @@ package org.programsnail.truffle_lama.nodes.expression;
|
|||
|
||||
import com.oracle.truffle.api.dsl.NodeChild;
|
||||
import com.oracle.truffle.api.dsl.Specialization;
|
||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||
import com.oracle.truffle.api.nodes.UnexpectedResultException;
|
||||
import org.programsnail.truffle_lama.nodes.LamaExpressionNode;
|
||||
import org.programsnail.truffle_lama.runtime.LamaException;
|
||||
|
|
@ -10,11 +11,22 @@ import org.programsnail.truffle_lama.runtime.LamaGlobalVarRef;
|
|||
|
||||
@NodeChild("leftNode")
|
||||
@NodeChild("rightNode")
|
||||
public abstract class LamaAssignNode extends LamaExpressionNode {
|
||||
public final class LamaAssignNode extends LamaExpressionNode {
|
||||
@Child
|
||||
private LamaExpressionNode leftNode, rightNode;
|
||||
|
||||
public LamaAssignNode(LamaExpressionNode leftNode, LamaExpressionNode rightNode) {
|
||||
this.leftNode = leftNode;
|
||||
this.rightNode = rightNode;
|
||||
}
|
||||
|
||||
@Specialization
|
||||
public Object assignValue(Object leftValue, Object rightValue) throws UnexpectedResultException {
|
||||
public Object executeGeneric(VirtualFrame frame) throws UnexpectedResultException {
|
||||
var leftValue = leftNode.executeGeneric(frame);
|
||||
var rightValue = rightNode.executeGeneric(frame);
|
||||
|
||||
if (leftValue instanceof LamaGlobalVarRef) {
|
||||
if (!((LamaGlobalVarRef) leftValue).assign(rightValue)) {
|
||||
if (!((LamaGlobalVarRef) leftValue).assign(rightValue, frame)) {
|
||||
throw new LamaException("Can't update variable by identifier '" + name + "'");
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
package org.programsnail.truffle_lama.nodes.expression;
|
||||
|
||||
public class LamaLeaveNode {
|
||||
public final class LamaLeaveNode {
|
||||
// TODO
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
package org.programsnail.truffle_lama.nodes.expression;
|
||||
|
||||
public class LamaScopeNode {
|
||||
public final class LamaScopeNode {
|
||||
// TODO
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package org.programsnail.truffle_lama.runtime;
|
||||
|
||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||
|
||||
public class LamaElemRef extends LamaObjRef {
|
||||
LamaArrayLike array;
|
||||
int id;
|
||||
|
|
@ -10,7 +12,7 @@ public class LamaElemRef extends LamaObjRef {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean assign(Object object) {
|
||||
public boolean assign(Object object, VirtualFrame frame) {
|
||||
return array.assignAt(id, object);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.programsnail.truffle_lama.runtime;
|
||||
|
||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||
import org.programsnail.truffle_lama.LamaContext;
|
||||
|
||||
public final class LamaGlobalVarRef extends LamaObjRef {
|
||||
|
|
@ -12,7 +13,7 @@ public final class LamaGlobalVarRef extends LamaObjRef {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean assign(Object object) {
|
||||
public boolean assign(Object object, VirtualFrame frame) {
|
||||
return this.context.globalScopeObject.updateVariable(name, object);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,16 +4,14 @@ import com.oracle.truffle.api.frame.VirtualFrame;
|
|||
|
||||
public final class LamaLocalVarRef extends LamaObjRef {
|
||||
private int id;
|
||||
private VirtualFrame frame;
|
||||
|
||||
public LamaLocalVarRef(int id, VirtualFrame frame) {
|
||||
public LamaLocalVarRef(int id) {
|
||||
this.id = id;
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean assign(Object object) {
|
||||
this.frame.setObject(id, object);
|
||||
public boolean assign(Object object, VirtualFrame frame) {
|
||||
frame.setObject(id, object);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package org.programsnail.truffle_lama.runtime;
|
||||
|
||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||
|
||||
public abstract class LamaObjRef {
|
||||
public abstract boolean assign(Object object);
|
||||
public abstract boolean assign(Object object, VirtualFrame frame);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue