private Ast.Argument KernelArgument(Type type, string name) { Ast.Argument result; if (type.IsSubclassOf(typeof(KernelArg))) { var typeDef = type.GetGenericTypeDefinition(); var elemType = type.GetGenericArguments()[0]; result = typeDef == typeof(Value <>) ? ClcAst.KArg(elemType, name, ClcAst.KernelArgumentKind.Value) : typeDef == typeof(Buffer <>) ? ClcAst.KArg(elemType, name, ClcAst.KernelArgumentKind.Buffer, ClcAst.KernelArgumentMemory.Global) : null; if (result == null) { throw new ParseException("Argument groups are only valid as kernel arguments."); } } else { result = Ast.Arg(type, name); } _currentScope.AddLocal(name, result); return(result); }