public void EndIf() { CodeBlock block = PopBlock(); CodeIf cif = currentBlock.GetLastItem() as CodeIf; if (cif == null || cif.FalseBlock != null || nestedIfs.Count == 0) { throw new InvalidOperationException("'EndIf' not allowed here"); } if (cif.TrueBlock == null) { cif.TrueBlock = block; } else { cif.FalseBlock = block; } int num = (int)nestedIfs [nestedIfs.Count - 1]; if (num > 0) { nestedIfs [nestedIfs.Count - 1] = --num; EndIf(); } else { nestedIfs.RemoveAt(nestedIfs.Count - 1); } }
public void Else() { CodeBlock block = PopBlock(); CodeIf cif = currentBlock.GetLastItem() as CodeIf; if (cif == null || cif.TrueBlock != null) { throw new InvalidOperationException("'Else' not allowed here"); } cif.TrueBlock = block; PushNewBlock(); }
public override void Generate (ILGenerator gen) { if (blocks.Count == 0) return; CodeIf initialIf = new CodeIf ((CodeExpression)conditions[0]); initialIf.TrueBlock = (CodeBlock) blocks[0]; CodeIf prevCif = initialIf; for (int n=1; n<blocks.Count; n++) { CodeIf cif = new CodeIf ((CodeExpression)conditions[n]); cif.TrueBlock = (CodeBlock) blocks[n]; CodeBlock cb = new CodeBlock (); cb.Add (cif); prevCif.FalseBlock = cb; prevCif = cif; } initialIf.Generate (gen); }
public override void Generate(ILGenerator gen) { if (blocks.Count == 0) { return; } CodeIf initialIf = new CodeIf((CodeExpression)conditions[0]); initialIf.TrueBlock = (CodeBlock)blocks[0]; CodeIf prevCif = initialIf; for (int n = 1; n < blocks.Count; n++) { CodeIf cif = new CodeIf((CodeExpression)conditions[n]); cif.TrueBlock = (CodeBlock)blocks[n]; CodeBlock cb = new CodeBlock(); cb.Add(cif); prevCif.FalseBlock = cb; prevCif = cif; } initialIf.Generate(gen); }