private void EmitListIn(FleeIlGenerator ilg, IServiceProvider services, BranchManager bm) { var ce = new CompareElement(); var endLabel = bm.FindLabel("endLabel"); var trueTerminal = bm.FindLabel("trueTerminal"); var lb = ilg.DeclareLocal(this.myOperand.ResultType); var targetIndex = lb.LocalIndex; this.myOperand.Emit(ilg, services); Utility.EmitStoreLocal(ilg, targetIndex); var targetShim = new LocalBasedElement(this.myOperand, targetIndex); this.myArguments.ForEach(argumentElement => { ce.Initialize(targetShim, argumentElement, LogicalCompareOperation.Equal); ce.Emit(ilg, services); EmitBranchToTrueTerminal(ilg, trueTerminal, bm); }); //try //{ // var enumerator = this.myArguments.GetEnumerator(); // while (enumerator.MoveNext()) // { // var argumentElement = enumerator.Current; // ce.Initialize(targetShim, argumentElement, LogicalCompareOperation.Equal); // ce.Emit(ilg, services); // EmitBranchToTrueTerminal(ilg, trueTerminal, bm); // } //} //finally //{ // List<ExpressionElement>.Enumerator enumerator; // ((IDisposable)enumerator).Dispose(); //} ilg.Emit(OpCodes.Ldc_I4_0); ilg.Emit(OpCodes.Br_S, endLabel); bm.MarkLabel(ilg, trueTerminal); ilg.MarkLabel(trueTerminal); ilg.Emit(OpCodes.Ldc_I4_1); bm.MarkLabel(ilg, endLabel); ilg.MarkLabel(endLabel); }
public override void Emit(FleeIlGenerator ilg, IServiceProvider services) { var flag = this.myTargetCollectionType != null; if (flag) { this.EmitCollectionIn(ilg, services); } else { var bm = new BranchManager(); bm.GetLabel("endLabel", ilg); bm.GetLabel("trueTerminal", ilg); var ilgTemp = this.CreateTempFleeIlGenerator(ilg); Utility.SyncFleeILGeneratorLabels(ilg, ilgTemp); this.EmitListIn(ilgTemp, services, bm); bm.ComputeBranches(); this.EmitListIn(ilg, services, bm); } }
public override void Emit(FleeIlGenerator ilg, IServiceProvider services) { var bm = new BranchManager(); bm.GetLabel("falseLabel", ilg); bm.GetLabel("endLabel", ilg); var isTemp = ilg.IsTemp; if (isTemp) { this.EmitConditional(ilg, services, bm); } else { var ilgTemp = this.CreateTempFleeIlGenerator(ilg); Utility.SyncFleeILGeneratorLabels(ilg, ilgTemp); this.EmitConditional(ilgTemp, services, bm); bm.ComputeBranches(); this.EmitConditional(ilg, services, bm); } }
private void EmitConditional(FleeIlGenerator ilg, IServiceProvider services, BranchManager bm) { var falseLabel = bm.FindLabel("falseLabel"); var endLabel = bm.FindLabel("endLabel"); this.myCondition.Emit(ilg, services); var isTemp = ilg.IsTemp; if (isTemp) { bm.AddBranch(ilg, falseLabel); ilg.Emit(OpCodes.Brfalse_S, falseLabel); } else { var flag = !bm.IsLongBranch(ilg, falseLabel); ilg.Emit(flag ? OpCodes.Brfalse_S : OpCodes.Brfalse, falseLabel); } this.myWhenTrue.Emit(ilg, services); ImplicitConverter.EmitImplicitConvert(this.myWhenTrue.ResultType, this.myResultType, ilg); var isTemp2 = ilg.IsTemp; if (isTemp2) { bm.AddBranch(ilg, endLabel); ilg.Emit(OpCodes.Br_S, endLabel); } else { var flag2 = !bm.IsLongBranch(ilg, endLabel); ilg.Emit(flag2 ? OpCodes.Br_S : OpCodes.Br, endLabel); } bm.MarkLabel(ilg, falseLabel); ilg.MarkLabel(falseLabel); this.myWhenFalse.Emit(ilg, services); ImplicitConverter.EmitImplicitConvert(this.myWhenFalse.ResultType, this.myResultType, ilg); bm.MarkLabel(ilg, endLabel); ilg.MarkLabel(endLabel); }
private static void EmitBranchToTrueTerminal(FleeIlGenerator ilg, Label trueTerminal, BranchManager bm) { var isTemp = ilg.IsTemp; if (isTemp) { bm.AddBranch(ilg, trueTerminal); ilg.Emit(OpCodes.Brtrue_S, trueTerminal); } else { var flag = !bm.IsLongBranch(ilg, trueTerminal); ilg.Emit(flag ? OpCodes.Brtrue_S : OpCodes.Brtrue, trueTerminal); } }
public ShortCircuitInfo() { this.Operands = new Stack(); this.Operators = new Stack(); this.Branches = new BranchManager(); }