private void addError(ErrorMessageRow msg) { Errors.Add(msg); }
public bool ParseOperation(Operation operation, string[] input) { ParameterInfo[] paramInfo = operation.method.GetParameters(); List <object> output = new List <object>(); ErrorMessageRow error = new ErrorMessageRow(null, operation.row.Index + 1); if (input.Length != paramInfo.Length) { error.Message = string.Format("Операция '{0}' имеет {1} оргумент(а)", operation.operation, paramInfo.Length); } for (int i = 0; i < input.Length && error.Message == null; i++) { Type needType = paramInfo[i].ParameterType; int oldCount = output.Count; string value = input[i]; value = value.TrimStart('#'); if (needType.BaseType == typeof(Register)) { Register reg = GetRegister(value.ToLower()); if (reg == null) { error.Message = string.Format("Регистр '{0}' не сущесвует", value); } if (!needType.IsInstanceOfType(reg)) { error.Message = string.Format("Регистр '{0}' не может использоватся здесь", value); } output.Add(reg); } else if (needType == typeof(int) || needType == typeof(short) || needType == typeof(char) || needType == typeof(byte)) { double?result = value.MathToDouble(); if (result != null) { output.Add(Convert.ChangeType(result, needType)); } else { error.Message = string.Format("'{0}' не является числом", value); } } else if (needType == typeof(Link)) { string[] temp = value.Split('['); Link link = new Link(); double? row = value.MathToDouble(); if (row != null) { link.Line = (int)row; } else { if (!Links.ContainsKey(temp[0])) { error.Message = string.Format("Метка '{0}' не определена", temp[0]); } else { link.Line = Links[temp[0]]; } } if (temp.Length == 2) { temp[1] = temp[1].Remove(temp[1].Length - 1).ToLower(); Register32 reg = GetRegister(temp[1]) as Register32; if (reg == null) { error.Message = string.Format("Регистр '{0}' не сущесвует или не может использоватся здесь", temp[1]); } else { link.reg32 = reg; } } output.Add(link); } if (oldCount == output.Count && error.Message != "") { error.Message = string.Format("Недопустимый пораметр {0}", value); } } operation.args = output.ToArray(); if (error.Message == null) { return(true); } addError(error); return(false); }