/// <summary> /// Select the current named encoding /// </summary> /// <param name="encodingName">The encoding name</param> public void SelectEncoding(StringView encodingName) { if (!_maps.ContainsKey(encodingName)) { _maps.Add(encodingName, new Dictionary <int, int>()); } _currentMap = _maps[encodingName]; }
public Section(StringView name, int starts, int ends) { Name = name; Starts = starts; Ends = ends; Selected = false; OutputCount = 0; }
/// <summary> /// Constructs a new instance of a symbol exception. /// </summary> /// <param name="symbolName">The symbol's name.</param> /// <param name="position">The position in the symbol in the original source.</param> /// <param name="reason">The exception reason.</param> public SymbolException(StringView symbolName, int position, ExceptionReason reason) : base(string.Format(s_reasonMessages[reason], symbolName)) { Position = position; SymbolToken = null; SymbolName = symbolName; Reason = reason; }
/// <summary> /// Construct a enw instance of a symbol class. /// </summary> /// <param name="value">The symbol's value.</param> /// <param name="isMutable">The symbol's mutability flag.</param> public Symbol(StringView value, bool isMutable) : this() { StringValue = value; DataType = DataType.String; StorageType = StorageType.Scalar; IsMutable = isMutable; }
/// <summary> /// Creates a new instance of the Function class. /// </summary> /// <param name="name">The function's name.</param> /// <param name="parameterList">The list of parameters for the function.</param> /// <param name="iterator">The <see cref="SourceLine"/> iterator to traverse to define the function block.</param> /// <param name="services">The shared <see cref="AssemblyServices"/> object.</param> /// <param name="caseSensitive">Determines whether to compare the passed parameters /// to the source block's own defined parameters should be case-sensitive.</param> /// <exception cref="SyntaxException"></exception> public Function(StringView name, List <Token> parameterList, RandomAccessIterator <SourceLine> iterator, AssemblyServices services, bool caseSensitive) : base(parameterList, caseSensitive) { Name = name; _services = services; _definedLines = new List <SourceLine>(); SourceLine line; while ((line = iterator.GetNext()) != null) { if (line.Label != null && line.Label.Name.Equals("+")) { _services.Log.LogEntry(line.Label, "Anonymous labels are not supported inside functions.", false); } if (line.Instruction != null) { if (line.Instruction.Name.Equals(".global", _services.StringViewComparer)) { throw new SyntaxException(line.Instruction, $"Directive \".global\" not allowed inside a function block."); } if (line.Instruction.Name.Equals(".endfunction", _services.StringViewComparer)) { if (line.Operands.Count > 0) { throw new SyntaxException(line.Operands[0], "Unexpected expression found after \".endfunction\" directive."); } break; } } _definedLines.Add(line); } if (line == null) { throw new SyntaxException(iterator.Current.Instruction, "Function definition does not have a closing \".endfunction\" directive."); } }
public override bool Assembles(StringView s) => _openClosures.ContainsKey(s) || Reserved.IsReserved(s);
public override int GetHashCode(StringView obj) => obj.GetHashCode();
/// <summary> /// Determines whether the string represented by this /// <see cref="string"/> and a specified <see cref="StringView"/> /// object have the same value. A parameter specifies the culture, /// case, and sort rules used in the comparison. /// </summary> /// <param name="str">This string.</param> /// <param name="value">The <see cref="StringView"/> to compare to this /// instance.</param> /// <param name="comparisonType">One of the enumeration values that /// specifies how the strings will be compared.</param> /// <returns><c>true</c> if the value of the value parameter is the /// same as this <see cref="StringView"/>; otherwise, <c>false</c>. /// </returns> /// <exception cref="ArgumentException">comparisonType is not /// a <see cref="System.StringComparison"/> value.</exception> public static bool Equals(this string str, StringView value, StringComparison comparisonType) => value.Equals(str, comparisonType);
public override int Compare(StringView x, StringView y) => StringView.CompareViews(x, y, true);
public override bool Equals(StringView x, StringView y) => StringView.ViewsEqual(x, y, true);
public bool IsFunctionName(StringView symbol) => Reserved.IsOneOf("Functions", symbol);
/// <summary> /// Constructs a new token object /// </summary> /// <param name="name">The token's (parsed) name.</param> /// <param name="type">The token's <see cref="TokenType"/>.</param> public Token(StringView name, TokenType type) { Name = name; Type = type; Position = 1; }
/// <summary> /// Constructs a new token object /// </summary> /// <param name="name">The token's (parsed) name.</param> /// <param name="type">The token's <see cref="TokenType"/>.</param> /// <param name="position">The token's position in its line.</param> public Token(StringView name, TokenType type, int position) { Type = type; Name = name; Position = position; }
public override bool IsReserved(StringView symbol) => base.IsReserved(symbol) || _openClosures.ContainsKey(symbol) || _functionDefs.ContainsKey(symbol);
/// <summary> /// Constructs a new parameter. /// </summary> /// <param name="name">The parameter name.</param> /// <param name="defaultValue">The parameter's default value as a collection of /// parsed <see cref="Token"/>s.</param> public Param(StringView name, List <Token> defaultValue) => (Name, DefaultValue) = (name, defaultValue);
/// <summary> /// Determines whether the assembler assembles the keyword. /// </summary> /// <param name="s">The symbol/keyword name.</param> /// <returns><c>true</c> if the assembler assembles the keyword, /// otherwise <c>false</c>.</returns> public virtual bool Assembles(StringView s) => IsReserved(s.ToString());
/// <summary> /// Determines whether the token is a reserved word to the assembler object. /// </summary> /// <param name="symbol">The symbol name to check if reserved</param> /// <returns><c>true</c> if reserved, otherwise <c>false</c>.</returns> public virtual bool IsReserved(StringView symbol) => Reserved.IsReserved(symbol);
public bool IsFunctionName(StringView symbol) => _functionDefs.ContainsKey(symbol);
/// <summary> /// Construct a enw instance of a symbol class. /// </summary> /// <param name="value">The symbol's value.</param> public Symbol(StringView value) : this(value, false) { }