public void FormatMethod(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices executionContext) { String methodName = GetMethodName(formatterContext); sw.AppendLine($"public void {methodName}()"); { sw.AppendLine("{"); sw.Indent++; FormatMethodBody(sw, formatterContext, executionContext); sw.Indent--; sw.AppendLine("}"); } }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.Append("else if("); ((JPF)_list[0]).Format(sw, formatterContext, services); sw.AppendLine(")"); FormatBranch(sw, formatterContext, services, GetBodyInstructions()); }
public static void FormatGlobalSet <T>(GlobalVariableId <T> globalVariable, IJsmExpression value, Int32[] knownVariables, ScriptWriter sw, IScriptFormatterContext formatterContext, IServices executionContext) where T : unmanaged { sw.Append("G"); if (knownVariables == null || Array.BinarySearch(knownVariables, globalVariable.VariableId) < 0) { sw.Append("["); sw.Append(globalVariable.VariableId.ToString(CultureInfo.InvariantCulture)); sw.Append("]"); sw.Append(" = "); sw.Append("("); sw.Append(GlobalVariableId <T> .TypeName); sw.Append(")"); } else { sw.Append(GlobalVariableId <T> .TypeName); sw.Append("["); sw.Append(globalVariable.VariableId.ToString(CultureInfo.InvariantCulture)); sw.Append("]"); sw.Append(" = "); } value.Format(sw, formatterContext, executionContext); sw.AppendLine(";"); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.Append($"R{_index.ResultId}"); sw.Append(" = "); _value.Format(sw, formatterContext, services); sw.AppendLine(";"); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.Append("while("); ((JPF)_list[0]).Format(sw, formatterContext, services); sw.AppendLine(")"); FormatBranch(sw, formatterContext, services, _list.Skip(1)); }
protected void FormatBranch(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices executionContext, IEnumerable <IJsmInstruction> items) { sw.AppendLine("{"); sw.Indent++; var state = sw.RememberState(); FormatItems(sw, formatterContext, executionContext, items); if (!state.IsChanged) { sw.AppendLine("// do nothing"); } sw.Indent--; sw.AppendLine("}"); }
public static void FormatMonologue(ScriptWriter sw, String message) { if (!sw.HasWhiteLine) { sw.AppendLine(); } foreach (String str in SplitMonologue(message)) { if (String.IsNullOrEmpty(str)) { continue; } sw.Append("// "); sw.AppendLine(str); } }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.Append("if("); Jpf.Format(sw, formatterContext, services); sw.AppendLine(")"); FormatBranch(sw, formatterContext, services, GetBodyInstructions()); foreach (var item in _aggregator.EnumerateElseBlocks()) { item.Format(sw, formatterContext, services); } }
private static void FormatItems(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices executionContext, IEnumerable <IJsmInstruction> items) { foreach (var item in items) { if (item is IFormattableScript formattable) { formattable.Format(sw, formatterContext, executionContext); } else { sw.AppendLine(item.ToString()); } } }
public void FormatType(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices executionContext) { formatterContext.GetObjectScriptNamesById(Id, out String typeName, out _); sw.AppendLine($"public sealed class {typeName}"); { sw.AppendLine("{"); sw.Indent++; if (Scripts.Count > 0) { FormatConstructor(typeName, sw, formatterContext, executionContext); foreach (var script in Scripts.Skip(1)) { sw.AppendLine(); script.FormatMethod(sw, formatterContext, executionContext); } } sw.Indent--; sw.AppendLine("}"); } }
private void FormatConstructor(String typeName, ScriptWriter sw, IScriptFormatterContext formatterContext, IServices executionContext) { sw.AppendLine($"private readonly {nameof(IServices)} _ctx;"); sw.AppendLine(); sw.AppendLine($"public {typeName}({nameof(IServices)} executionContext)"); { sw.AppendLine("{"); sw.Indent++; sw.AppendLine("_ctx = executionContext;"); Scripts[0].FormatMethodBody(sw, formatterContext, executionContext); sw.Indent--; sw.AppendLine("}"); } }
public virtual void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine(this.ToString()); }
public void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine($"goto LABEL{_label};"); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine($"return {nameof(IRET)}({Unknown});"); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { formatterContext.GetObjectScriptNamesById(_scriptId, out String typeName, out String methodName); sw.AppendLine($"{nameof(REQEW)}(priority: {_priority}, GetObject<{typeName}>().{methodName}());"); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine($"R{ResultVariable.ResultId} = {nameof(Rnd)}.{nameof(Rnd.NextByte)}();"); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine($"// ScriptId: {Label}"); }
public static void FormatAnswers(ScriptWriter sw, String message, IJsmExpression top, IJsmExpression bottom, IJsmExpression begin, IJsmExpression cancel) { if (!(top is IConstExpression t) || !(bottom is IConstExpression b)) { FormatMonologue(sw, message); return; } if (!sw.HasWhiteLine) { sw.AppendLine(); } // Question //☞ Answer 1 // Answer 2 // Answer 3 //☜ Answer 4 Int32 to = t.Int32(); Int32 bo = b.Int32(); Int32 be = -1; Int32 ca = -1; if (begin is IConstExpression beg) { be = beg.Int32(); } if (cancel is IConstExpression can) { ca = can.Int32(); } String[] lines = SplitMonologue(message); for (Int32 i = 0; i < lines.Length; i++) { sw.Append("//"); if (i >= to && i <= bo) { if (i == be) { sw.Append("☞ "); } else if (i == ca) { sw.Append("☜ "); } else { sw.Append(" "); } } else { sw.Append(" "); } sw.AppendLine(lines[i]); } }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine("else"); FormatBranch(sw, formatterContext, services, GetBodyInstructions()); }