public void Visit(Assignment assignment)
 {
     assignment.Id.Accept(this);
     _sb.Append(" = ");
     assignment.Exp.Accept(this);
     _sb.Append(";");
 }
예제 #2
0
 public Declaration(Typed typed, Assignment assignment)
 {
     _typed = typed;
     _assignment = assignment;
 }
 public void Visit(Assignment assignment)
 {
     assignment.Id.Accept(this);
     _sb.Append(" = ");
     _noTypeFlag = true;
     assignment.Exp.Accept(this);
 }
 public void Visit(Assignment assignment)
 {
     assignment.Id.Accept(this);
     if (_env.VariableAlreadyDefined(assignment.Id.Name))
     {
         assignment.Id.SmclType = _env.GetMyTypeFromId(assignment.Id.Name);
         assignment.Exp.Accept(this);
         if (!assignment.Id.SmclType.Equals(assignment.Exp.SmclType))
             throw new TypeCheckingException(
                 "wrong assignment. "
                 + assignment.Id.SmclType
                 + " = "
                 + assignment.Exp.SmclType
                 + "\nThey must be the same type."
                 );
     }
     else
     {
         throw new TypeCheckingException("variable never declared --> " + assignment.Id.Name);
     }
 }