11// ---------------------------------------------------------------------------------------
22// ILGPU Algorithms
3- // Copyright (c) 2019-2021 ILGPU Project
3+ // Copyright (c) 2019-2023 ILGPU Project
44// www.ilgpu.net
55//
66// File: CLContext.cs
@@ -40,7 +40,8 @@ static partial class CLContext
4040 private static readonly MethodInfo MathCodeGenerator =
4141 CLMathType . GetMethod (
4242 nameof ( CLMath . GenerateMathIntrinsic ) ,
43- AlgorithmContext . IntrinsicBindingFlags ) ;
43+ AlgorithmContext . IntrinsicBindingFlags )
44+ . ThrowIfNull ( ) ;
4445
4546 /// <summary>
4647 /// Represents the intrinsic representation of the
@@ -49,7 +50,8 @@ static partial class CLContext
4950 private static readonly CLIntrinsic MathCodeGeneratorIntrinsic =
5051 new CLIntrinsic (
5152 MathCodeGenerator ,
52- IntrinsicImplementationMode . GenerateCode ) ;
53+ IntrinsicImplementationMode . GenerateCode )
54+ . ThrowIfNull ( ) ;
5355
5456 /// <summary>
5557 /// The <see cref="CLGroupExtensions"/> type.
@@ -74,7 +76,8 @@ private static CLIntrinsic GetMathIntrinsic(string name, params Type[] types)
7476 AlgorithmContext . IntrinsicBindingFlags ,
7577 null ,
7678 types ,
77- null ) ;
79+ null )
80+ . ThrowIfNull ( ) ;
7881 return new CLIntrinsic ( targetMethod , IntrinsicImplementationMode . Redirect ) ;
7982 }
8083
@@ -93,7 +96,8 @@ private static void RegisterIntrinsicMapping(
9396 {
9497 var sourceMethod = sourceType . GetMethod (
9598 name ,
96- AlgorithmContext . IntrinsicBindingFlags ) ;
99+ AlgorithmContext . IntrinsicBindingFlags )
100+ . ThrowIfNull ( ) ;
97101 manager . RegisterMethod (
98102 sourceMethod ,
99103 new CLIntrinsic ( targetType , name , IntrinsicImplementationMode . Redirect ) ) ;
@@ -118,7 +122,8 @@ private static void RegisterIntrinsicCodeGenerator(
118122 {
119123 var sourceMethod = sourceType . GetMethod (
120124 name ,
121- AlgorithmContext . IntrinsicBindingFlags ) ;
125+ AlgorithmContext . IntrinsicBindingFlags )
126+ . ThrowIfNull ( ) ;
122127 manager . RegisterMethod (
123128 sourceMethod ,
124129 new CLIntrinsic (
@@ -150,7 +155,8 @@ private static void RegisterXMathCodeGenerator(
150155 AlgorithmContext . IntrinsicBindingFlags ,
151156 null ,
152157 types ,
153- null ) ,
158+ null )
159+ . ThrowIfNull ( ) ,
154160 new CLIntrinsic (
155161 targetType ,
156162 codeGeneratorName ,
@@ -176,7 +182,7 @@ internal static void GenerateScanReduce<T, TScanReduce>(
176182 where TScanReduce : struct , IScanReduceOperation < T >
177183 {
178184 // Allocate target and load source argument
179- var reduce = value as MethodCall ;
185+ var reduce = value . AsNotNullCast < MethodCall > ( ) ;
180186 var sourceValue = codeGenerator . Load ( reduce [ 0 ] ) ;
181187 var target = codeGenerator . Allocate ( value ) ;
182188
0 commit comments