Trait glsl::visitor::Host

source ·
pub trait Host {
    // Required method
    fn visit<V>(&self, visitor: &mut V)
       where V: Visitor;
}
Expand description

Part of the AST that can be visited.

You shouldn’t have to worry about this type nor how to implement it – it’s completely implemented for you. However, it works in a pretty simple way: any implementor of the host trait can be used with a visitor.

The idea is that visiting an AST node is a two-step process:

  • First, you can get your visitor called once as soon as an interesting node gets visited. For instance, if your visitor has an implementation for visiting expressions, everytime an expression gets visited, your visitor will run.
  • If your implementation of visiting an AST node returns Visit::Children and if the given node has children, the visitor will go deeper, invoking other calls if you have defined any. A typical pattern you might want to do is to implement your visitor to gets run on all typenames. Since expressions contains variables, you will get your visitor called once again there.
  • Notice that since visitors are mutable, you can accumulate a state as you go deeper in the AST to implement various checks and validations.

Note that this trait exists in two versions: an immutable one, Host, which doesn’t allow you to mutate the AST (but takes a &), and a mutable one, HostMut, which allows for AST mutation.

Required Methods§

source

fn visit<V>(&self, visitor: &mut V)
where V: Visitor,

Visit an AST node.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> Host for Option<T>
where T: Host,

source§

fn visit<V>(&self, visitor: &mut V)
where V: Visitor,

source§

impl<T> Host for Box<T>
where T: Host,

source§

fn visit<V>(&self, visitor: &mut V)
where V: Visitor,

Implementors§

source§

impl Host for ArraySpecifierDimension

source§

impl Host for AssignmentOp

source§

impl Host for BinaryOp

source§

impl Host for CaseLabel

source§

impl Host for Condition

source§

impl Host for Declaration

source§

impl Host for Expr

source§

impl Host for ExternalDeclaration

source§

impl Host for ForInitStatement

source§

impl Host for FunIdentifier

source§

impl Host for FunctionParameterDeclaration

source§

impl Host for Initializer

source§

impl Host for InterpolationQualifier

source§

impl Host for IterationStatement

source§

impl Host for JumpStatement

source§

impl Host for LayoutQualifierSpec

source§

impl Host for PrecisionQualifier

source§

impl Host for Preprocessor

source§

impl Host for PreprocessorDefine

source§

impl Host for PreprocessorExtensionBehavior

source§

impl Host for PreprocessorExtensionName

source§

impl Host for PreprocessorVersionProfile

source§

impl Host for SelectionRestStatement

source§

impl Host for SimpleStatement

source§

impl Host for Statement

source§

impl Host for StorageQualifier

source§

impl Host for TypeQualifierSpec

source§

impl Host for TypeSpecifierNonArray

source§

impl Host for UnaryOp

source§

impl Host for ArraySpecifier

source§

impl Host for ArrayedIdentifier

source§

impl Host for Block

source§

impl Host for CompoundStatement

source§

impl Host for ForRestStatement

source§

impl Host for FullySpecifiedType

source§

impl Host for FunctionDefinition

source§

impl Host for FunctionParameterDeclarator

source§

impl Host for FunctionPrototype

source§

impl Host for Identifier

source§

impl Host for InitDeclaratorList

source§

impl Host for LayoutQualifier

source§

impl Host for PreprocessorElIf

source§

impl Host for PreprocessorError

source§

impl Host for PreprocessorExtension

source§

impl Host for PreprocessorIf

source§

impl Host for PreprocessorIfDef

source§

impl Host for PreprocessorIfNDef

source§

impl Host for PreprocessorInclude

source§

impl Host for PreprocessorLine

source§

impl Host for PreprocessorPragma

source§

impl Host for PreprocessorUndef

source§

impl Host for PreprocessorVersion

source§

impl Host for SelectionStatement

source§

impl Host for SingleDeclaration

source§

impl Host for SingleDeclarationNoType

source§

impl Host for StructFieldSpecifier

source§

impl Host for StructSpecifier

source§

impl Host for SwitchStatement

source§

impl Host for TranslationUnit

source§

impl Host for TypeName

source§

impl Host for TypeQualifier

source§

impl Host for TypeSpecifier