void ReportInstanceErrors(AssemblingStatus status, MixInstruction.Instance instance) { var errorArray = instance.Validate(); if (errorArray != null) { int causeStartIndex = 0; int causeLength = 0; foreach (InstanceValidationError error in errorArray) { switch (error.Source) { case InstanceValidationError.Sources.Address: causeStartIndex = 0; causeLength = mIndexPartCharIndex; break; case InstanceValidationError.Sources.Index: causeStartIndex = mIndexPartCharIndex; causeLength = mFieldPartCharIndex - mIndexPartCharIndex; break; case InstanceValidationError.Sources.FieldSpec: causeStartIndex = mFieldPartCharIndex; causeLength = mTextLength - mFieldPartCharIndex; break; } status.ReportError(LineSection.AddressField, causeStartIndex, causeLength, error); } } }
int LoadInstructionInstance(MixInstruction.Instance instance, int locationCounter) { var validationErrors = instance.Validate(); if (validationErrors != null) { ReportLoadInstanceErrors(locationCounter, validationErrors); } FullMemory[locationCounter].MagnitudeLongValue = instance.InstructionWord.MagnitudeLongValue; FullMemory[locationCounter].Sign = instance.InstructionWord.Sign; FullMemory[locationCounter].SourceLine = instance.SourceLine; return(locationCounter + 1); }