rasen 0.12.0

Build a SPIR-V module from a data flow graph
//! Error-related definitions generated by `error_chain`

use types::TypeName;
use module::FunctionRef;

error_chain! {
    errors {
        /// The compiler was provided with a cyclic graph, but the data flow graph
        /// should always be acyclic
        CyclicGraph {
            description("graph is cyclic")
            display("graph is cyclic")
        }

        /// A call node is referencing an unknown function
        MissingFunction(index: FunctionRef) {
            description("missing function")
            display("missing function {:?}", index)
        }

        /// A node is not receiving the expected number of values
        WrongArgumentsCount(actual: usize, expected: usize) {
            description("wrong number of arguments")
            display("got {} arguments, expected {}", actual, expected)
        }

        /// A composite type was acessed with an invalid index (eg. 2 in a `vec2`)
        IndexOutOfBound(index: u32, len: u32) {
            description("index out of bounds")
            display("index out of bounds ({} >= {})", index, len)
        }

        /// A generic arguments error, usually thrown when a node receives a combination of
        /// types it cannot handle
        BadArguments(args: Box<[&'static TypeName]>) {
            description("bad arguments")
            display("bad arguments: {:?}", args)
        }

        /// Hopefully temporary error type, thrown when creating a constant with a type not yet supported
        UnsupportedConstant(ty: &'static TypeName) {
            description("unsupported constant type")
            display("unsupported constant type {:?}", ty)
        }

        /// A node is used in an incompatible context
        UnsupportedOperation(name: &'static str) {
            description("unsupported operation")
            display("unsupported operation {}", name)
        }

        /// Used to wrap another error with metadata about its origin node
        BuildError(node: &'static str, id: usize) {
            description("build error")
            display("compilation failed at {} node with id {}", node, id)
        }
    }
}