public override void Generate (ILGenerator gen) { CodeBlock block = new CodeBlock(); CodeWhile cw; block.Add (initExp); block.Add (cw = new CodeWhile (conditionExp)); CodeBlock loopBlock = new CodeBlock (); loopBlock.Add (forBlock); loopBlock.Add (nextExp); cw.WhileBlock = loopBlock; block.Generate (gen); }
public override void Generate (ILGenerator gen) { Type t = array.GetResultType (); if (t.IsArray) { CodeBlock block = new CodeBlock(); CodeVariableDeclaration indexDec; CodeWhile cw; CodeValueReference index; CodeValueReference item; block.Add (itemDec); item = itemDec.Variable; block.Add (indexDec = new CodeVariableDeclaration (typeof(int), "n")); index = indexDec.Variable; block.Add (new CodeAssignment (index, new CodeLiteral (0))); block.Add (cw = new CodeWhile (CodeExpression.IsSmallerThan (index, array.ArrayLength))); CodeBlock loopBlock = new CodeBlock (); loopBlock.Add (new CodeAssignment (item, array[index])); loopBlock.Add (new CodeIncrement(index)); loopBlock.Add (forBlock); cw.WhileBlock = loopBlock; block.Generate (gen); } else { CodeBlock block = new CodeBlock(); CodeVariableDeclaration dec; CodeWhile cw; CodeValueReference enumerator; CodeValueReference item; block.Add (itemDec); item = itemDec.Variable; block.Add (dec = new CodeVariableDeclaration (typeof(IEnumerator), "e")); enumerator = dec.Variable; block.Add (new CodeAssignment (enumerator, array.Call("GetEnumerator"))); block.Add (cw = new CodeWhile (enumerator.Call ("MoveNext"))); CodeBlock loopBlock = new CodeBlock (); loopBlock.Add (new CodeAssignment (item, enumerator["Current"])); loopBlock.Add (forBlock); cw.WhileBlock = loopBlock; block.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); }
public void AddCase (CodeExpression condition, CodeBlock block) { conditions.Add (condition); blocks.Add (block); }
CodeBuilder (CodeBlock block) { currentBlock = block; }
public CodeBuilder (CodeClass codeClass) { this.codeClass = codeClass; mainBlock = new CodeBlock (); currentBlock = mainBlock; }
CodeBlock PopBlock () { CodeBlock block = currentBlock; currentBlock = (CodeBlock) blockStack.Pop (); return block; }
void PushNewBlock () { blockStack.Push (currentBlock); currentBlock = new CodeBlock (); }
public CodeTry () { tryBlock = new CodeBlock (); catchBlocks = new ArrayList (); finallyBlock = new CodeBlock (); }
public CodeTry() { tryBlock = new CodeBlock(); catchBlocks = new ArrayList(); finallyBlock = new CodeBlock(); }
CodeBuilder(CodeBlock block) { currentBlock = block; }
void PushNewBlock() { blockStack.Push(currentBlock); currentBlock = new CodeBlock(); }
public CodeBuilder(CodeClass codeClass) { this.codeClass = codeClass; mainBlock = new CodeBlock(); currentBlock = mainBlock; }
public void AddCase(CodeExpression condition, CodeBlock block) { conditions.Add(condition); blocks.Add(block); }