From 1346e0ccf05d9a9d934e2d9d855145ec3682cc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Tue, 3 Jan 2023 12:56:40 +0100 Subject: [PATCH] Resolver - Return the map of resolved variables --- src/resolver.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/resolver.rs b/src/resolver.rs index e91d193..bc48b69 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -2,10 +2,12 @@ use std::collections::HashMap; use crate::{ast, errors::ParserError, tokens::Token}; -pub fn resolve_variables(program: &ast::ProgramNode) -> ResolverResult { +pub type ResolvedVariables = HashMap<*const ast::ExprNode, usize>; + +pub fn resolve_variables(program: &ast::ProgramNode) -> Result { let mut state = ResolverState::default(); program.resolve(&mut state)?; - Ok(()) + Ok(state.resolved) } type ResolverResult = Result<(), ParserError>; @@ -13,7 +15,7 @@ type ResolverResult = Result<(), ParserError>; #[derive(Default)] struct ResolverState { scopes: Vec>, - resolved: HashMap<*const ast::ExprNode, usize>, + resolved: ResolvedVariables, } impl ResolverState {