#include "Node.h"

#include <stdio.h>

//  oop mVariable;
//  oop mValue;

AssignmentNode::AssignmentNode(oop variable, oop value)
{
  mVariable= variable;
  mValue= value;
}

oop AssignmentNode::withVariableValue(oop variable, oop value)
{
  return new AssignmentNode(variable, value);
}

oop AssignmentNode::encode(oop encoder)
{
  mVariable->encodeLvalue(encoder);
  mValue->encode(encoder);
  mLocation= mValue->location();
  return this;
}

oop AssignmentNode::gen(oop unit)
{
  oop stream= unit->outputStream();

  mValue->gen(unit);
  stream->format("  ");
  mVariable->genLvalue(unit);
  stream->format("= _%d;\n", mLocation);
  return this;
}
