| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using OpenVIII.Fields.Scripts.Instructions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace OpenVIII.Fields.Scripts
- {
- public static partial class Jsm
- {
- public static partial class Control
- {
- public sealed partial class If
- {
- private sealed class IfSegment : ExecutableSegment
- {
- private readonly If _aggregator;
- public IfSegment(Int32 from, Int32 to, If aggregator)
- : base(from, to)
- {
- _aggregator = aggregator;
- }
- public override void ToString(StringBuilder sb)
- {
- sb.Append("if(");
- sb.Append((JPF)_list[0]);
- sb.AppendLine(")");
- FormatBranch(sb, _list.Skip(1));
- }
- 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 override IScriptExecuter GetExecuter()
- {
- return new Executer(_aggregator);
- }
- public JPF Jpf => ((JPF)_list[0]);
- public IEnumerable<IJsmInstruction> GetBodyInstructions()
- {
- return _list.Skip(1);
- }
- }
- }
- }
- }
- }
|