void EvaluateAssignmentExpression(AssignmentExpression exp) { ConstantType val = EvaluateArithmeticExpression(exp.GetExpression()); Variable variable; if (m_Context.GetState().GetVariable(exp.GetVariable().GetName().Value, out variable)) { variable.SetValue(Variable.GetValueFromConstant(variable.GetVariableType(), val)); } }
string GetAssignmentExpressionString(AssignmentExpression exp) { string retVal; string rhs = GetArithmeticExpressionString(exp.GetExpression()); string variableName = exp.GetVariable().GetName().Value; retVal = variableName + " = " + rhs; return(retVal); }
VariableType ValidateAssignmentExpression(AssignmentExpression assignment, out bool valid) { bool expressionValid = true; VariableType returnType = VariableType.INT; valid = true; VariableType varType = (VariableType)assignment.GetVariable().GetType2().Value; VariableType expressionType = ValidateArithmeticExpression(assignment.GetExpression(), out expressionValid); bool typesValid = IsTypeCompatible(varType, expressionType, out returnType); valid = typesValid && expressionValid; return(returnType); }