Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Unified Diff: pkg/smoke/lib/static.dart

Issue 194813007: Add codegen support in smoke (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/smoke/lib/codegen/recorder.dart ('k') | pkg/smoke/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/smoke/lib/static.dart
diff --git a/pkg/smoke/lib/static.dart b/pkg/smoke/lib/static.dart
index 4b276fc575dd7b63feb1694996f1b2940a6e986a..3c8d59cc7f4adc82e49a2a6806cec746047aaefe 100644
--- a/pkg/smoke/lib/static.dart
+++ b/pkg/smoke/lib/static.dart
@@ -37,9 +37,15 @@ class StaticConfiguration {
/// A map from strings to symbols (the reverse of [names]).
final Map<String, Symbol> symbols;
+
+ /// Whether to check for missing declarations, otherwise, return default
+ /// values (for example a missing parent class can be treated as Object)
+ final bool checkedMode;
+
StaticConfiguration({
this.getters: const {}, this.setters: const {}, this.parents: const {},
- this.declarations: const {}, this.names: const {}})
+ this.declarations: const {}, this.names: const {},
+ this.checkedMode: true})
: this.symbols = {} {
names.forEach((k, v) { symbols[v] = k; });
}
@@ -120,6 +126,7 @@ class _GeneratedTypeInspectorService implements TypeInspectorService {
var parentType = _configuration.parents[type];
if (parentType == supertype) return true;
if (parentType == null) {
+ if (!_configuration.checkedMode) return false;
throw new MissingCodeException('superclass of "$type" ($parentType)');
}
type = parentType;
@@ -147,6 +154,7 @@ class _GeneratedTypeInspectorService implements TypeInspectorService {
bool hasStaticMethod(Type type, Symbol name) {
final map = _configuration.declarations[type];
if (map == null) {
+ if (!_configuration.checkedMode) return false;
throw new MissingCodeException('declarations for $type');
}
final decl = map[name];
@@ -156,25 +164,27 @@ class _GeneratedTypeInspectorService implements TypeInspectorService {
Declaration getDeclaration(Type type, Symbol name) {
var decl = _findDeclaration(type, name);
if (decl == null) {
+ if (!_configuration.checkedMode) return null;
throw new MissingCodeException('declaration for $type.$name');
}
return decl;
}
List<Declaration> query(Type type, QueryOptions options) {
- var result;
+ var result = [];
if (options.includeInherited) {
var superclass = _configuration.parents[type];
if (superclass == null) {
- throw new MissingCodeException('superclass of "$type"');
+ if (_configuration.checkedMode) {
+ throw new MissingCodeException('superclass of "$type"');
+ }
+ } else if (superclass != options.includeUpTo) {
+ result = query(superclass, options);
}
- result = (superclass == options.includeUpTo) ? []
- : query(superclass, options);
- } else {
- result = [];
}
var map = _configuration.declarations[type];
if (map == null) {
+ if (!_configuration.checkedMode) return result;
throw new MissingCodeException('declarations for $type');
}
for (var decl in map.values) {
@@ -218,6 +228,7 @@ Declaration _findDeclaration(Type type, Symbol name) {
}
var parentType = _configuration.parents[type];
if (parentType == null) {
+ if (!_configuration.checkedMode) return null;
throw new MissingCodeException('superclass of "$type"');
}
type = parentType;
« no previous file with comments | « pkg/smoke/lib/codegen/recorder.dart ('k') | pkg/smoke/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698