Module glsl

Source
Expand description

A GLSL450/GLSL460 transpiler that takes a syntax tree and writes it as a plain raw GLSL String.

§Foreword

This module exports several functions that just transform a part of a syntax tree into its raw GLSL String representation.

Important note: this module – and actually, any transpiler module – is not responsible in optimizing the syntax tree nor semantically check its validity. This is done in other stages of the compilation process.

In order to achieve that purpose, you could:

  • For each elements in the AST, return a String or Cow<str>.
  • Insert the string representation via a formatter.

The second solution is better because it lets the user handle the memory the way they want: they might just use a dynamic buffer that implements Write or simply pass a &mut String. It’s up to you.

§How to use this module

First, head over to the ast module. That module defines the AST items defined by GLSL. This very module provides you with functions like show_* taking the AST item and writing it to a Write object. You’re likely to be interested in show_translation_unit to start with.

Structs§

FormattingSettings
Formatting settings for the GLSL transpiler
FormattingState
Formatting state of the GLSL transpiler

Enums§

IndentStyle
Indentation style of the output
Whitespace
Formatter whitespace

Statics§

DEFAULT_SETTINGS 🔒

Traits§

HasPrecedence 🔒
Precedence information for transpiling parentheses properly

Functions§

show_array_spec
Transpile an array_spec to GLSL
show_arrayed_identifier
Transpile an arrayed_identifier to GLSL
show_assignment_op
Transpile an assignment_op to GLSL
show_binary_op
Transpile a binary_op to GLSL
show_block
Transpile a block(f: &mut F, b: &ast::Block, state: &mut FormattingState to GLSL
show_case_label
Transpile a case_label to GLSL
show_compound_statement
Transpile a compound_statement to GLSL
show_condition
Transpile a condition to GLSL
show_declaration
Transpile a declaration to GLSL
show_double
Transpile a double(f: &mut F, x: f64, _: &mut FormattingState to GLSL
show_expr
Transpile an expr to GLSL
show_expression_statement
Transpile an expression_statement to GLSL
show_external_declaration
Transpile an external_declaration to GLSL
show_float
Transpile a float(f: &mut F, x: f32, _: &mut FormattingState to GLSL
show_for_init_statement
Transpile a for_init_statement to GLSL
show_for_rest_statement
Transpile a for_rest_statement to GLSL
show_fully_specified_type
Transpile a fully_specified_type to GLSL
show_function_definition
Transpile a function_definition to GLSL
show_function_identifier
Transpile a function_identifier to GLSL
show_function_parameter_declaration
Transpile a function_parameter_declaration to GLSL
show_function_parameter_declarator
Transpile a function_parameter_declarator to GLSL
show_function_prototype
Transpile a function_prototype to GLSL
show_identifier
Transpile an identifier to GLSL
show_init_declarator_list
Transpile an init_declarator_list to GLSL
show_initializer
Transpile an initializer to GLSL
show_interpolation_qualifier
Transpile an interpolation_qualifier to GLSL
show_iteration_statement
Transpile an iteration_statement to GLSL
show_jump_statement
Transpile a jump_statement to GLSL
show_layout_qualifier
Transpile a layout_qualifier to GLSL
show_layout_qualifier_spec
Transpile a layout_qualifier_spec to GLSL
show_path
Transpile a path(f: &mut F, path: &ast::Path, _: &mut FormattingState to GLSL
show_precision_qualifier
Transpile a precision_qualifier to GLSL
show_preprocessor
Transpile a preprocessor to GLSL
show_preprocessor_define
Transpile a preprocessor_define to GLSL
show_preprocessor_else
Transpile a preprocessor_else(f: &mut F, _: &mut FormattingState to GLSL
show_preprocessor_elseif
Transpile a preprocessor_elseif to GLSL
show_preprocessor_endif
Transpile a preprocessor_endif(f: &mut F, _: &mut FormattingState to GLSL
show_preprocessor_error
Transpile a preprocessor_error to GLSL
show_preprocessor_extension
Transpile a preprocessor_extension to GLSL
show_preprocessor_if
Transpile a preprocessor_if to GLSL
show_preprocessor_ifdef
Transpile a preprocessor_ifdef to GLSL
show_preprocessor_ifndef
Transpile a preprocessor_ifndef to GLSL
show_preprocessor_include
Transpile a preprocessor_include to GLSL
show_preprocessor_line
Transpile a preprocessor_line to GLSL
show_preprocessor_pragma
Transpile a preprocessor_pragma to GLSL
show_preprocessor_undef
Transpile a preprocessor_undef to GLSL
show_preprocessor_version
Transpile a preprocessor_version to GLSL
show_selection_rest_statement
Transpile a selection_rest_statement to GLSL
show_selection_statement
Transpile a selection_statement to GLSL
show_single_declaration
Transpile a single_declaration to GLSL
show_single_declaration_no_type
Transpile a single_declaration_no_type to GLSL
show_statement
Transpile a statement to GLSL
show_storage_qualifier
Transpile a storage_qualifier to GLSL
show_struct
Transpile a struct to GLSL
show_struct_field
Transpile a struct_field to GLSL
show_struct_non_declaration
Transpile a struct_non_declaration to GLSL
show_subroutine
Transpile a subroutine to GLSL
show_switch_statement
Transpile a switch_statement to GLSL
show_translation_unit
Transpile a translation_unit to GLSL
show_type_name
Transpile a type_name to GLSL
show_type_qualifier
Transpile a type_qualifier to GLSL
show_type_qualifier_spec
Transpile a type_qualifier_spec to GLSL
show_type_specifier
Transpile a type_specifier to GLSL
show_type_specifier_non_array
Transpile a type_specifier_non_array to GLSL
show_unary_op
Transpile an unary_op to GLSL