Line data Source code
1 : // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 : // for details. All rights reserved. Use of this source code is governed by a
3 : // BSD-style license that can be found in the LICENSE file.
4 :
5 : import 'frame.dart';
6 : import 'trace.dart';
7 :
8 : /// A thunk for lazily constructing a [Trace].
9 : typedef Trace TraceThunk();
10 :
11 : /// A wrapper around a [TraceThunk]. This works around issue 9579 by avoiding
12 : /// the conversion of native [StackTrace]s to strings until it's absolutely
13 : /// necessary.
14 : class LazyTrace implements Trace {
15 : final TraceThunk _thunk;
16 : Trace _inner;
17 :
18 5 : LazyTrace(this._thunk);
19 :
20 : Trace get _trace {
21 0 : if (_inner == null) _inner = _thunk();
22 0 : return _inner;
23 : }
24 :
25 0 : List<Frame> get frames => _trace.frames;
26 0 : StackTrace get original => _trace.original;
27 0 : StackTrace get vmTrace => _trace.vmTrace;
28 0 : Trace get terse => new LazyTrace(() => _trace.terse);
29 : Trace foldFrames(bool predicate(Frame frame), {bool terse: false}) =>
30 0 : new LazyTrace(() => _trace.foldFrames(predicate, terse: terse));
31 0 : String toString() => _trace.toString();
32 :
33 : // Work around issue 14075.
34 0 : set frames(_) => throw new UnimplementedError();
35 : }
|