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 override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.Append($"R{_index.ResultId}"); sw.Append(" = "); _value.Format(sw, formatterContext, services); sw.AppendLine(";"); }
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 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)); }
/// <nodoc /> public static void WriteObject(ScriptWriter writer, ImmutableContextBase context, object value) { if (value == null) { writer.AppendToken("undefined"); return; } if (value is EvaluationResult result) { WriteObject(writer, context, result.Value); return; } // One of the types in the map is generic (ObjectLiteralLight<>). // To get a match from the dictionary we need to get open generic type // from already constructed type that would be provided by value.GetType(). var type = value.GetType(); if (type.IsGenericType) { type = type.GetGenericTypeDefinition(); } if (s_toStringMap.TryGetValue(type, out WriteObjectFunction writeFunction)) { writeFunction(writer, context, value); } else { writer.AppendLine(I($"Don't know how to get a string representation of '{type}'")); } }
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); } }
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 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()); } } }
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 override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { formatterContext.GetObjectScriptNamesById(ScriptID, out var typeName, out var methodName); sw.AppendLine($"{nameof(PREQEW)}(priority: {Priority}, GetObject<{typeName}>().{methodName}());"); }
public virtual void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine(this.ToString()); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { formatterContext.GetObjectScriptNamesById(_scriptId, out String typeName, out String methodName); sw.AppendLine($"{nameof(REQSW)}(priority: {_priority}, GetObject<{typeName}>().{methodName}());"); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine("else"); FormatBranch(sw, formatterContext, services, GetBodyInstructions()); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine($"// ScriptId: {Label}"); }
public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) { sw.AppendLine($"return {nameof(IRET)}({Unknown});"); }
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($"R{ResultVariable.ResultId} = {nameof(Rnd)}.{nameof(Rnd.NextByte)}();"); }