private static bool IsValidSwitchBucketConstant(ConstantValue constant) { return(constant != null && SwitchConstantValueHelper.IsValidSwitchCaseLabelConstant(constant) && !constant.IsNull && !constant.IsString); }
private static int CompareIntegralSwitchLabels( KeyValuePair <ConstantValue, object> first, KeyValuePair <ConstantValue, object> second ) { ConstantValue firstConstant = first.Key; ConstantValue secondConstant = second.Key; RoslynDebug.Assert(firstConstant != null); Debug.Assert( SwitchConstantValueHelper.IsValidSwitchCaseLabelConstant(firstConstant) && !firstConstant.IsString ); RoslynDebug.Assert(secondConstant != null); Debug.Assert( SwitchConstantValueHelper.IsValidSwitchCaseLabelConstant(secondConstant) && !secondConstant.IsString ); return(SwitchConstantValueHelper.CompareSwitchCaseLabelConstants( firstConstant, secondConstant )); }
private void EmitCondBranchForSwitch(ILOpCode branchCode, ConstantValue constant, object targetLabel) { Debug.Assert(branchCode.IsBranchToLabel()); Debug.Assert(constant != null && SwitchConstantValueHelper.IsValidSwitchCaseLabelConstant(constant)); Debug.Assert(targetLabel != null); // ldloc key // ldc constant // branch branchCode targetLabel _builder.EmitLoad(_key); _builder.EmitConstantValue(constant); _builder.EmitBranch(branchCode, targetLabel, GetReverseBranchCode(branchCode)); }
private void EmitEqBranchForSwitch(ConstantValue constant, object targetLabel) { Debug.Assert(constant != null && SwitchConstantValueHelper.IsValidSwitchCaseLabelConstant(constant)); Debug.Assert(targetLabel != null); _builder.EmitLoad(_key); if (constant.IsDefaultValue) { // ldloc key // brfalse targetLabel _builder.EmitBranch(ILOpCode.Brfalse, targetLabel); } else { _builder.EmitConstantValue(constant); _builder.EmitBranch(ILOpCode.Beq, targetLabel); } }