@@ -5,15 +5,21 @@ use std::time::Instant;
55
66use thiserror:: Error ;
77
8- pub use self :: { buildings:: * , processor:: * , variables:: * } ;
8+ use self :: variables:: Constants ;
9+ pub use self :: {
10+ buildings:: { Building , BuildingData , CustomBuildingData } ,
11+ instructions:: InstructionResult ,
12+ processor:: { InstructionHook , Processor , ProcessorBuilder , ProcessorState } ,
13+ variables:: { Content , LObject , LString , LValue , LVar } ,
14+ } ;
915#[ cfg( feature = "std" ) ]
1016use crate :: types:: { Schematic , SchematicTile } ;
1117use crate :: { types:: PackedPoint2 , utils:: RapidHashMap } ;
1218
13- mod buildings;
19+ pub mod buildings;
1420pub mod instructions;
1521mod processor;
16- mod variables;
22+ pub mod variables;
1723
1824const MILLIS_PER_SEC : u64 = 1_000 ;
1925const NANOS_PER_MILLI : u32 = 1_000_000 ;
@@ -50,6 +56,12 @@ impl LogicVM {
5056 builder. build ( )
5157 }
5258
59+ pub fn from_buildings ( buildings : impl IntoIterator < Item = Building > ) -> VMLoadResult < Self > {
60+ let mut builder = LogicVMBuilder :: new ( ) ;
61+ builder. add_buildings ( buildings) ;
62+ builder. build ( )
63+ }
64+
5365 pub fn building ( & self , position : PackedPoint2 ) -> Option < & Building > {
5466 self . buildings_map
5567 . get ( & position)
@@ -154,10 +166,7 @@ impl LogicVMBuilder {
154166 } ;
155167 }
156168
157- pub fn add_buildings < T > ( & mut self , buildings : T )
158- where
159- T : IntoIterator < Item = Building > ,
160- {
169+ pub fn add_buildings ( & mut self , buildings : impl IntoIterator < Item = Building > ) {
161170 for building in buildings. into_iter ( ) {
162171 self . add_building ( building) ;
163172 }
@@ -269,11 +278,10 @@ mod tests {
269278 use pretty_assertions:: assert_eq;
270279 use widestring:: u16str;
271280
272- use super :: LogicVMBuilder ;
281+ use super :: * ;
273282 use crate :: {
274283 parser:: ast,
275284 types:: { PackedPoint2 , content} ,
276- vm:: { Building , BuildingData , LObject , LVar , processor:: ProcessorBuilder } ,
277285 } ;
278286
279287 #[ test]
@@ -370,9 +378,12 @@ mod tests {
370378 use widestring:: { U16Str , U16String , u16str} ;
371379
372380 use super :: {
373- buildings:: { LOGIC_PROCESSOR , WORLD_PROCESSOR } ,
374- instructions:: { Instruction , InstructionResult } ,
375- processor:: Processor ,
381+ buildings:: {
382+ HYPER_PROCESSOR , LOGIC_PROCESSOR , MEMORY_BANK , MEMORY_CELL , MESSAGE , MICRO_PROCESSOR ,
383+ SWITCH , WORLD_CELL , WORLD_PROCESSOR ,
384+ } ,
385+ instructions:: Instruction ,
386+ variables:: Constants ,
376387 * ,
377388 } ;
378389 use crate :: {
@@ -381,13 +392,6 @@ mod tests {
381392 Team , colors:: COLORS , content,
382393 } ,
383394 utils:: u16format,
384- vm:: {
385- buildings:: {
386- HYPER_PROCESSOR , MEMORY_BANK , MEMORY_CELL , MESSAGE , MICRO_PROCESSOR , SWITCH ,
387- WORLD_CELL ,
388- } ,
389- variables:: { Content , LValue , LVar } ,
390- } ,
391395 } ;
392396
393397 fn single_processor_vm ( name : & str , code : & str ) -> LogicVM {
0 commit comments