OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Static implementation of smoke services using code-generated data. | 5 /// Static implementation of smoke services using code-generated data. |
6 library smoke.static; | 6 library smoke.static; |
7 | 7 |
8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
9 | 9 |
10 import 'package:logging/logging.dart'; | 10 import 'package:logging/logging.dart'; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 void write(Object object, Symbol name, value) { | 109 void write(Object object, Symbol name, value) { |
110 var setter = _setters[name]; | 110 var setter = _setters[name]; |
111 if (setter == null) { | 111 if (setter == null) { |
112 throw new MissingCodeException('setter "$name" in $object'); | 112 throw new MissingCodeException('setter "$name" in $object'); |
113 } | 113 } |
114 setter(object, value); | 114 setter(object, value); |
115 } | 115 } |
116 | 116 |
117 invoke(object, Symbol name, List args, {Map namedArgs, bool adjust: false}) { | 117 invoke(object, Symbol name, List args, {Map namedArgs, bool adjust: false}) { |
118 var method; | 118 var method; |
119 if (object is Type) { | 119 if (object is Type && name != #toString) { |
120 var classMethods = _staticMethods[object]; | 120 var classMethods = _staticMethods[object]; |
121 method = classMethods == null ? null : classMethods[name]; | 121 method = classMethods == null ? null : classMethods[name]; |
122 } else { | 122 } else { |
123 var getter = _getters[name]; | 123 var getter = _getters[name]; |
124 method = getter == null ? null : getter(object); | 124 method = getter == null ? null : getter(object); |
125 } | 125 } |
126 if (method == null) { | 126 if (method == null) { |
127 throw new MissingCodeException('method "$name" in $object'); | 127 throw new MissingCodeException('method "$name" in $object'); |
128 } | 128 } |
129 var tentativeError; | 129 var tentativeError; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 /// Exception thrown when trynig to access something that should be there, but | 284 /// Exception thrown when trynig to access something that should be there, but |
285 /// the code generator didn't include it. | 285 /// the code generator didn't include it. |
286 class MissingCodeException implements Exception { | 286 class MissingCodeException implements Exception { |
287 final String description; | 287 final String description; |
288 MissingCodeException(this.description); | 288 MissingCodeException(this.description); |
289 | 289 |
290 String toString() => 'Missing $description. ' | 290 String toString() => 'Missing $description. ' |
291 'Code generation for the smoke package seems incomplete.'; | 291 'Code generation for the smoke package seems incomplete.'; |
292 } | 292 } |
OLD | NEW |