package org.hummingbirdlang.nodes;

import com.oracle.truffle.api.frame.VirtualFrame;

import org.hummingbirdlang.types.realize.InferenceVisitor;

public class HBAssignmentNode extends HBExpressionNode {
  @Child private HBExpressionNode targetNode;
  @Child private HBExpressionNode valueNode;

  public HBAssignmentNode(HBExpressionNode targetNode, HBExpressionNode valueNode) {
    this.targetNode = targetNode;
    this.valueNode = valueNode;
  }

  public void accept(InferenceVisitor visitor) {
    return;
  }

  @Override
  public Object executeGeneric(VirtualFrame frame) {
    return null;
  }

  @Override
  public String toString() {
    StringBuilder result = new StringBuilder("HBAssignmentNode");
    result.append("(");
    result.append(this.targetNode.toString());
    result.append(" = ");
    result.append(this.valueNode.toString());
    result.append(")");
    return result.toString();
  }
}

@@ -29,16 +29,63 @@
 nodes;%0A%0A
+import com.oracle.truffle.api.frame.FrameSlot;%0A
 import c
@@ -631,19 +631,468 @@
     
-return null
+if (!(this.targetNode instanceof HBIdentifierNode)) %7B%0A      throw new RuntimeException(%22Cannot yet handle assignment of non-identifier node: %22 + this.targetNode.toString());%0A    %7D%0A    HBIdentifierNode identifierNode = (HBIdentifierNode)this.targetNode;%0A%0A    Object value = this.valueNode.executeGeneric(frame);%0A    FrameSlot frameSlot = frame.getFrameDescriptor().findFrameSlot(identifierNode.getName());%0A    frame.setObject(frameSlot, value);%0A    return value
 ;%0A  

Add rudimentary implementation of assignment node