struct WalkCtx<'a> {
src: &'a str,
scopes: Vec<HashMap<String, WgslType>>,
edits: Vec<TextEdit>,
}Expand description
AST walker state: a small stacked symbol table plus a sink for text
edits. Each walk_* consults and updates the table; walk_expr returns
the inferred type of the expression so callers can decide whether to
emit a fix-up edit.
Fields§
§src: &'a str§scopes: Vec<HashMap<String, WgslType>>§edits: Vec<TextEdit>Implementations§
Source§impl<'a> WalkCtx<'a>
impl<'a> WalkCtx<'a>
fn new(src: &'a str) -> Self
fn seed_globals(&mut self, tu: &TranslationUnit)
fn scope_push(&mut self)
fn scope_pop(&mut self)
fn declare(&mut self, name: &str, ty: WgslType)
fn lookup(&self, name: &str) -> WgslType
fn emit_truncation(&mut self, span: Span, target_size: usize)
Sourcefn emit_pad_vec2_to_vec3(&mut self, span: Span)
fn emit_pad_vec2_to_vec3(&mut self, span: Span)
Wrap a vec2 expression in vec3<f32>(<expr>, 0.0) so it satisfies
a helper that demands a vec3 (real example: MD2 presets calling
lum(roam_sin.yx) where the runtime padded implicitly). Emitted as
two zero-length insertions instead of one replace-range edit so any
inner edits inside the arg (e.g. a swizzle rewrite) don’t get
dropped by apply_edits’s overlap guard.
Sourcefn emit_scalar_to_vec2(&mut self, span: Span)
fn emit_scalar_to_vec2(&mut self, span: Span)
Wrap a scalar expression in vec2<f32>(<expr>) so it satisfies a
2D-texture coord parameter. MD2 presets occasionally pass a single
channel (tex2D(sampler_noise_hq, uv.x)) where naga demands a
vec2; HLSL silently broadcast in that situation. Emitted as two
zero-length insertions, same overlap-safety rationale as
Self::emit_pad_vec2_to_vec3.