pub struct SymbolTable {
pub locals: HashMap<String, WgslType>,
}Expand description
Maps locally-declared identifier → its WGSL type. Pre-seeded with the
uniforms and helper-function bindings the codegen wrapper exposes
inside fs_main (so that texsize, q1..q32, aspect, etc. resolve
to known types).
Fields§
§locals: HashMap<String, WgslType>Implementations§
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn from_source(src: &str) -> Self
pub fn from_source(src: &str) -> Self
Build a symbol table by scanning var NAME: TYPE / let NAME: TYPE
declarations in the translated source. Pre-seeded with the wrapper
preamble’s bindings so user code can be analysed in isolation.
pub fn lookup(&self, name: &str) -> Option<WgslType>
Sourcepub fn infer_expr_type(&self, expr: &str) -> WgslType
pub fn infer_expr_type(&self, expr: &str) -> WgslType
Best-effort type inference for an expression text. Returns a
confident type for the dominant patterns, WgslType::Unknown
otherwise — callers must treat Unknown as “do not modify”.
Recognised:
- A numeric literal (with or without
f/i/usuffix) →F32. - A bare identifier in the symbol table → that type.
- A constructor call
vec3<f32>(...)etc. → that type. - A call to a known helper (
GetPixel,GetBlur1..3,lum,textureSample, etc.) → its return type. - A swizzle access
<expr>.<comp>where the prefix is a vec type — narrowed toF32for.x/.y/.z/.w/.r/.g/.b/.aof length 1,Vec2Ffor 2,Vec3Ffor 3,Vec4Ffor 4. - A binary op (
+,-,*,/) where one side is vec → the widest vec type. Falls back toF32when both sides are scalar.
Auto Trait Implementations§
impl Freeze for SymbolTable
impl RefUnwindSafe for SymbolTable
impl Send for SymbolTable
impl Sync for SymbolTable
impl Unpin for SymbolTable
impl UnwindSafe for SymbolTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more