public void Process(Instruction instruction)
{
if (recording)
{
if (instruction.InstructionType == InstructionType.StartMember)
{
depth++;
}
if (instruction.InstructionType == InstructionType.EndMember)
{
depth--;
if (depth == 0)
{
recording = false;
var loaded = assembler.Load(new ReadOnlyCollection<Instruction>(nodeList), this.objectAssembler.TypeSource);
objectAssembler.OverrideInstance(loaded);
objectAssembler.Process(instruction);
}
}
if (depth > 0)
{
nodeList.Add(instruction);
}
}
else
{
if (instruction.InstructionType == InstructionType.StartMember && !instruction.Member.IsDirective)
{
var hasAssembler = TryGetDeferredAssembler((MutableMember) instruction.Member, out assembler);
if (hasAssembler)
{
recording = true;
nodeList = new Collection<Instruction>();
depth++;
objectAssembler.Process(instruction);
}
}
if (!recording)
{
objectAssembler.Process(instruction);
}
}
}