Add span associated with the import statement to ast

This commit is contained in:
Pranav Gaddamadugu 2022-10-07 15:09:00 -07:00 committed by d0cd
parent 3c2da076ff
commit 41a8bc5a73
3 changed files with 5 additions and 3 deletions

View File

@ -315,7 +315,7 @@ pub trait ProgramReconstructor: StatementReconstructor {
imports: input
.imports
.into_iter()
.map(|(id, import)| (id, self.reconstruct_import(import)))
.map(|(id, import)| (id, (self.reconstruct_import(import.0), import.1)))
.collect(),
program_scopes: input
.program_scopes

View File

@ -193,7 +193,7 @@ pub trait StatementVisitor<'a>: ExpressionVisitor<'a> {
/// A Visitor trait for the program represented by the AST.
pub trait ProgramVisitor<'a>: StatementVisitor<'a> {
fn visit_program(&mut self, input: &'a Program) {
input.imports.values().for_each(|import| self.visit_import(import));
input.imports.values().for_each(|import| self.visit_import(&import.0));
input
.program_scopes

View File

@ -24,6 +24,8 @@ pub use program_scope::*;
use crate::Identifier;
use leo_span::Span;
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use std::fmt;
@ -32,7 +34,7 @@ use std::fmt;
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Program {
/// A map from import names to import definitions.
pub imports: IndexMap<Identifier, Program>,
pub imports: IndexMap<Identifier, (Program, Span)>,
/// A map from program names to program scopes.
pub program_scopes: IndexMap<ProgramId, ProgramScope>,
}