// Copyright 2026 Leo Cheng
// SPDX-License-Identifier: Apache-2.0

///|
/// A shader module: source code the device can build entry points from.
pub struct ShaderModule {
  device : Device
  id : @types.ShaderModuleId
  label : String
}

///|
/// The module's identity inside its device.
pub fn ShaderModule::id(self : ShaderModule) -> @types.ShaderModuleId {
  self.id
}

///|
/// The module's label.
pub fn ShaderModule::label(self : ShaderModule) -> String {
  self.label
}

///|
/// `getCompilationInfo`: what the backend's compiler said about this module.
///
/// A module with an error in it is still created, as in the specification; the
/// messages are how a caller learns that a pipeline built from it will fail.
/// https://www.w3.org/TR/webgpu/#dom-gpushadermodule-getcompilationinfo
pub fn ShaderModule::get_compilation_info(
  self : ShaderModule,
) -> @types.CompilationInfo raise @core.Refused {
  self.device.hub.compilation_info(self.id)
}