@@ -49,7 +49,7 @@ class SimDart implements SimDartInterface {
4949 RunState _runState = RunState .notStarted;
5050 RunState get runState => _runState;
5151
52- DebugListener ? _debugListener;
52+ DebugListener ? _debugListener;
5353
5454 final SimListener ? listener;
5555
@@ -110,7 +110,6 @@ class SimDart implements SimDartInterface {
110110 /// - [until] : The time at which execution should stop. Execution will include events
111111 /// scheduled at this time (inclusive). If null, execution will continue indefinitely.
112112 Future <SimResult > run ({int ? until}) async {
113-
114113 if (runState != RunState .notStarted) {
115114 throw StateError ('Simulation has already started.' );
116115 }
@@ -131,11 +130,7 @@ class SimDart implements SimDartInterface {
131130 _startTime = null ;
132131 _scheduleNextAction ();
133132 await _terminator.future;
134-
135- print ('terminou' );
136- print ('foi com erro? -> ${_error .runtimeType }: $_error ' );
137133 if (_error != null ) {
138- print ('ue? erro?' );
139134 _runState = RunState .error;
140135 throw _error! ;
141136 } else {
@@ -147,18 +142,16 @@ class SimDart implements SimDartInterface {
147142 }
148143
149144 void stop () {
150- print ("stop" );
151- _addAction (StopAction (start: now, sim: this ));
145+ _addAction (StopAction (start: now, sim: this ));
152146 }
153147
154148 void _disposeCompleterList () {
155149 while (_completerList.isNotEmpty) {
156150 Completer <void > completer = _completerList.removeAt (0 );
157151 _debugListener? .onRemoveCompleter ();
158152 if (! completer.isCompleted) {
159- print ('vai CompleterInterrupt' );
160153 // prevents subsequent methods from being executed after complete inside the async method.
161- completer.completeError (CompleterInterrupt ());
154+ completer.completeError (CompleterInterrupt ());
162155 }
163156 }
164157 }
@@ -237,8 +230,6 @@ class SimDart implements SimDartInterface {
237230
238231 void _scheduleNextAction () {
239232 if (! _nextActionScheduled) {
240- print ('_scheduleNextAction' );
241- _debugListener? .onScheduleNextAction ();
242233 _nextActionScheduled = true ;
243234 if (executionPriority == 0 || _executionCount < executionPriority) {
244235 _executionCount++ ;
@@ -251,16 +242,16 @@ class SimDart implements SimDartInterface {
251242 }
252243
253244 void _addAction (TimeAction action) {
254- if (_runState== RunState .running || _runState== RunState .notStarted) {
245+ if (_runState == RunState .running || _runState == RunState .notStarted) {
255246 _actions.add (action);
256247 }
257248 }
258249
259250 Future <void > _nextAction () async {
260251 _nextActionScheduled = false ;
261- if (_actions.isEmpty || runState!= RunState .running) {
252+ if (_actions.isEmpty || runState != RunState .running) {
262253 _disposeCompleterList ();
263- if (! _terminator.isCompleted) {
254+ if (! _terminator.isCompleted) {
264255 _terminator.complete ();
265256 }
266257 return ;
@@ -282,7 +273,6 @@ class SimDart implements SimDartInterface {
282273
283274 _startTime ?? = now;
284275
285- _debugListener? .onExecuteAction ();
286276 action.execute ();
287277 }
288278}
@@ -320,21 +310,19 @@ class SimDartHelper {
320310 sim._debugListener? .onRemoveCompleter ();
321311 }
322312
323- static void error ({required SimDart sim, required StateError error}) {
324- print ('error' );
325- if (sim._error== null ) {
313+ static void error ({required SimDart sim, required Object error}) {
314+ if (sim._error == null ) {
326315 sim._error = error;
327316 sim._runState = RunState .error;
328317 }
329318 }
330-
331- static void setDebugListener ({required SimDart sim, required DebugListener ? listener}) {
332- sim._debugListener= listener;
319+
320+ static void setDebugListener (
321+ {required SimDart sim, required DebugListener ? listener}) {
322+ sim._debugListener = listener;
333323 }
334324
335325 static void stop ({required SimDart sim}) {
336- print ('stopando' );
337- sim._debugListener? .onStop ();
338326 sim._runState = RunState .stopped;
339327 }
340328}
0 commit comments