/// <summary> /// Sets a operand argument. /// </summary> /// <param name="index">The index.</param> /// <param name="value">The value.</param> public void SetOperandArgument(int index, PapyrusAsmValue value) { if (index >= opargs.Count) { FillOpArgs(1 + index - opargs.Count); } opargs[index] = value; }
public List <PapyrusAsmValue> GetAsmValues(string input) { var res = new List <PapyrusAsmValue>(); PapyrusAsmValue activeVal = null; var insideString = false; var specialToken = false; foreach (var token in input.TakeWhile(c => c != ';')) { if (activeVal == null) { activeVal = new PapyrusAsmValue(); } switch (token) { case '\\': specialToken = true; continue; case '"': if (specialToken) { specialToken = false; activeVal.Value += "\\\""; // \" continue; } insideString = !insideString; if (insideString) { continue; } if (activeVal.Value == null) { activeVal.Value = string.Empty; // Value should just be empty, not null. } res.Add(activeVal); activeVal = null; break; default: if ((token == ' ' || token == '\t') && !insideString) { if (!string.IsNullOrEmpty(activeVal.Value)) { res.Add(activeVal); } activeVal = null; } else { activeVal.Value += token; } break; } } if (!string.IsNullOrEmpty(activeVal?.Value)) { res.Add(activeVal); } return(res); }
/// <summary> /// Sets an argument. /// </summary> /// <param name="index">The index.</param> /// <param name="value">The value.</param> public void SetArgument(int index, PapyrusAsmValue value) => args[index] = value;