public void AddJumpIfFalse(JumpLabel jumpTarget, string comment = "") { #if USE_UDON_LABELS AppendCommentedLine($"JUMP_IF_FALSE, {jumpTarget.uniqueName}", comment); #else if (jumpTarget.IsResolved) { AppendCommentedLine($"JUMP_IF_FALSE, {jumpTarget.AddresStr()}", comment); } else { AppendCommentedLine($"JUMP_IF_FALSE_LABEL, [{jumpTarget.uniqueName}]", comment); } #endif programCounter += UdonSharpUtils.GetUdonInstructionSize("JUMP_IF_FALSE"); }
private string ReplaceLabels(string assemblyString, LabelTable labelTable) { StringBuilder newAssemblyBuilder = new StringBuilder(); using (StringReader reader = new StringReader(assemblyString)) { string currentLine = reader.ReadLine(); while (currentLine != null) { string line = currentLine.TrimStart(_trimChars); if (line.StartsWith("JUMP_LABEL,", StringComparison.Ordinal)) { int startIdx = line.IndexOf('[') + 1; int endIdx = line.IndexOf(']'); string labelName = line.Substring(startIdx, endIdx - startIdx); JumpLabel label = labelTable.GetLabel(labelName); newAssemblyBuilder.AppendFormat(" JUMP, {0}\n", label.AddresStr()); } else if (line.StartsWith("JUMP_IF_FALSE_LABEL,", StringComparison.Ordinal)) { int startIdx = line.IndexOf('[') + 1; int endIdx = line.IndexOf(']'); string labelName = line.Substring(startIdx, endIdx - startIdx); JumpLabel label = labelTable.GetLabel(labelName); newAssemblyBuilder.AppendFormat(" JUMP_IF_FALSE, {0}\n", label.AddresStr()); } else { newAssemblyBuilder.Append(currentLine); newAssemblyBuilder.Append("\n"); } currentLine = reader.ReadLine(); } } return(newAssemblyBuilder.ToString()); }