mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 15:15:47 +03:00
Add span associated with the import statement to ast
This commit is contained in:
parent
3c2da076ff
commit
41a8bc5a73
@ -315,7 +315,7 @@ pub trait ProgramReconstructor: StatementReconstructor {
|
|||||||
imports: input
|
imports: input
|
||||||
.imports
|
.imports
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(id, import)| (id, self.reconstruct_import(import)))
|
.map(|(id, import)| (id, (self.reconstruct_import(import.0), import.1)))
|
||||||
.collect(),
|
.collect(),
|
||||||
program_scopes: input
|
program_scopes: input
|
||||||
.program_scopes
|
.program_scopes
|
||||||
|
@ -193,7 +193,7 @@ pub trait StatementVisitor<'a>: ExpressionVisitor<'a> {
|
|||||||
/// A Visitor trait for the program represented by the AST.
|
/// A Visitor trait for the program represented by the AST.
|
||||||
pub trait ProgramVisitor<'a>: StatementVisitor<'a> {
|
pub trait ProgramVisitor<'a>: StatementVisitor<'a> {
|
||||||
fn visit_program(&mut self, input: &'a Program) {
|
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
|
input
|
||||||
.program_scopes
|
.program_scopes
|
||||||
|
@ -24,6 +24,8 @@ pub use program_scope::*;
|
|||||||
|
|
||||||
use crate::Identifier;
|
use crate::Identifier;
|
||||||
|
|
||||||
|
use leo_span::Span;
|
||||||
|
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@ -32,7 +34,7 @@ use std::fmt;
|
|||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Program {
|
pub struct Program {
|
||||||
/// A map from import names to import definitions.
|
/// 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.
|
/// A map from program names to program scopes.
|
||||||
pub program_scopes: IndexMap<ProgramId, ProgramScope>,
|
pub program_scopes: IndexMap<ProgramId, ProgramScope>,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user