private string HandleTimesDirective(IReadOnlyList <string> aSegments, ref int aArgIndex, ref DirectiveCodes aDirCode) { // Skip the TIMES directive term as it will // trigger an early loop break below. ++aArgIndex; object?dirCode = null; string timesExprStr = string.Empty; var hasValidDir = false; var len = aSegments.Count; for (; aArgIndex < len; aArgIndex++) { if (!Enum.TryParse(typeof(DirectiveCodes), aSegments[aArgIndex].ToUpper(), out dirCode)) { // We have not found a valid directive. // Add this argument to the expression string. timesExprStr += aSegments[aArgIndex]; continue; } // Ensure that this directive can use the times // prefix. hasValidDir = dirCode switch { DirectiveCodes.DB => true, _ => false }; break; } // We did not find a valid directive after the times // prefix. This syntax is invalid. // We have to null check dirCode here as the compiler // doesn't understand that it cannot ever be null here. if (!hasValidDir || dirCode is null) { AsmParser.Assert(true, AsmParser.ExIDs.InvalidDirectiveType); return(string.Empty); } // Update the directive code. aDirCode = (DirectiveCodes)dirCode; return(timesExprStr); }
public CompilerDir(DirectiveCodes aDirCode, string aDirLabel, byte[]?aByteData = null, string?aStringData = null, string?aTimesExprString = null, CompilerDir?aSubDir = null) { DirCode = aDirCode; DirLabel = aDirLabel; ByteData = aByteData ?? new byte[0]; StringData = aStringData ?? string.Empty; TimesExprString = aTimesExprString ?? string.Empty; SubDirective = aSubDir; }