@@ -11,7 +11,7 @@ use crate::types::expression::convert_type;
1111use crate :: types:: { array_length_bits, PrimitiveType , ResolvedScalarType , ResolvedType } ;
1212use crate :: warning:: Warnings ;
1313use canadensis_bit_length_set:: BitLengthSet ;
14- use canadensis_dsdl_parser:: { Identifier , Span , Statement } ;
14+ use canadensis_dsdl_parser:: { Config , Identifier , Span , Statement } ;
1515use once_cell:: sync:: Lazy ;
1616use std:: collections:: btree_map:: Entry ;
1717use std:: collections:: BTreeMap ;
@@ -32,8 +32,9 @@ static BIT_LENGTH_ZERO: Lazy<BitLengthSet> = Lazy::new(|| BitLengthSet::single(0
3232///
3333/// This function returns the compiled DSDL or an error. In either case, it also returns
3434/// a set of warnings.
35- pub ( crate ) fn compile ( files : BTreeMap < TypeKey , DsdlFile > ) -> CompileOutput {
35+ pub ( crate ) fn compile ( files : BTreeMap < TypeKey , DsdlFile > , config : & Config ) -> CompileOutput {
3636 let context = PersistentContext {
37+ config,
3738 pending : files,
3839 done : BTreeMap :: new ( ) ,
3940 warnings : Warnings :: new ( ) ,
@@ -53,14 +54,14 @@ pub(crate) struct CompileOutput {
5354///
5455/// They use its functions to collect information about the type currently being compiled, and
5556/// about other types.
56- pub ( crate ) struct CompileContext < ' p > {
57+ pub ( crate ) struct CompileContext < ' p , ' c : ' p > {
5758 /// Persistent context and information about other types
58- persistent : & ' p mut PersistentContext ,
59+ persistent : & ' p mut PersistentContext < ' c > ,
5960 /// Information about the type currently being compiled
6061 current_file : & ' p mut FileState ,
6162}
6263
63- impl < ' p > CompileContext < ' p > {
64+ impl < ' p , ' c : ' p > CompileContext < ' p , ' c > {
6465 /// Returns the constants that have been declared in the current file
6566 ///
6667 /// If the current file defines a service type, constants declared in the request section
@@ -220,15 +221,19 @@ impl<'p> CompileContext<'p> {
220221}
221222
222223/// A convenience function to make a `CompileContext`
223- fn ctx < ' p > ( p : & ' p mut PersistentContext , c : & ' p mut FileState ) -> CompileContext < ' p > {
224+ fn ctx < ' p , ' c : ' p > (
225+ p : & ' p mut PersistentContext < ' c > ,
226+ c : & ' p mut FileState ,
227+ ) -> CompileContext < ' p , ' c > {
224228 CompileContext {
225229 persistent : p,
226230 current_file : c,
227231 }
228232}
229233
230234/// A context used during the compilation process
231- struct PersistentContext {
235+ struct PersistentContext < ' c > {
236+ config : & ' c Config ,
232237 /// Files that have not been compiled
233238 pending : BTreeMap < TypeKey , DsdlFile > ,
234239 /// Files that have been compiled
@@ -237,7 +242,7 @@ struct PersistentContext {
237242 warnings : Warnings ,
238243}
239244
240- impl PersistentContext {
245+ impl < ' c > PersistentContext < ' c > {
241246 fn compile ( mut self ) -> CompileOutput {
242247 while let Some ( key) = self . pending . keys ( ) . next ( ) . cloned ( ) {
243248 let input = self . pending . remove ( & key) . unwrap ( ) ;
@@ -277,7 +282,7 @@ impl PersistentContext {
277282 let mut state = FileState :: new ( key. name ( ) . path ( ) ) ;
278283
279284 let text = input. read ( ) ?;
280- let ast = canadensis_dsdl_parser:: parse ( & text) ?;
285+ let ast = canadensis_dsdl_parser:: parse ( & text, & self . config ) ?;
281286
282287 for statement in ast. statements {
283288 match statement {
0 commit comments