private void ValidateBranch( Branch branch, BranchArgumentKind extraAllowedKind, BlockFlow flow, List <string> errors) { if (Implementation.ContainsBasicBlock(branch.Target)) { var blockParams = Implementation.GetBasicBlock(branch.Target).Parameters; int blockParamCount = blockParams.Count; if (blockParamCount != branch.Arguments.Count) { errors.Add( string.Format( "Branch argument count ('{0}') mismatches target " + "block parameter count ('{1}').", branch.Arguments.Count, blockParamCount)); } else { for (int i = 0; i < blockParamCount; i++) { var arg = branch.Arguments[i]; if (arg.IsValue) { var argType = Implementation.GetValueType(arg.ValueOrNull); if (!argType.Equals(blockParams[i].Type)) { errors.Add( string.Format( "Branch argument type '{0}' mismatches target " + "block parameter type '{1}'.", branch.Arguments.Count, blockParams[i].Type)); } } else if (arg.Kind != extraAllowedKind) { errors.Add( string.Format( "Branch argument kind '{0}' is not allowed in this " + "branch of '{1}' flow.", arg.Kind, flow)); } } } } else { errors.Add("Branch to block outside of graph."); } }
private BranchArgument(BranchArgumentKind kind, ValueTag value) { this = default(BranchArgument); this.Kind = kind; this.ValueOrNull = value; }