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

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

Issue 208583003: Fix string literals and add support for static methods in smoke. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: minor fix - inlcude name for static method too 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 92339739638b153d3e962311402f519710b814de..a5ccf1321002b252fd80f963602b4c388414eaa1 100644
--- a/pkg/smoke/lib/static.dart
+++ b/pkg/smoke/lib/static.dart
@@ -24,12 +24,16 @@ class StaticConfiguration {
/// instance, `#i: (o, v) { o.i = v; }`.
final Map<Symbol, Setter> setters;
- /// Maps a type to it's super class. For example, String: Object.
+ /// Maps a type to its super class. For example, String: Object.
final Map<Type, Type> parents;
/// For each type, a map of declarations per symbol (property or method).
final Map<Type, Map<Symbol, Declaration>> declarations;
+ /// Static methods for each type.
+ // TODO(sigmund): should we add static getters & setters too?
+ final Map<Type, Map<Symbol, Function>> staticMethods;
+
/// A map from symbol to strings.
final Map<Symbol, String> names;
@@ -39,8 +43,8 @@ class StaticConfiguration {
StaticConfiguration({
this.getters: const {}, this.setters: const {}, this.parents: const {},
- this.declarations: const {}, this.names: const {},
- this.checkedMode: true});
+ this.declarations: const {}, this.staticMethods: const {},
+ this.names: const {}, this.checkedMode: true});
}
/// Set up the smoke package to use a static implementation based on the given
@@ -55,10 +59,12 @@ useGeneratedCode(StaticConfiguration configuration) {
class GeneratedObjectAccessorService implements ObjectAccessorService {
final Map<Symbol, Getter> _getters;
final Map<Symbol, Setter> _setters;
+ final Map<Type, Map<Symbol, Function>> _staticMethods;
GeneratedObjectAccessorService(StaticConfiguration configuration)
: _getters = configuration.getters,
- _setters = configuration.setters;
+ _setters = configuration.setters,
+ _staticMethods = configuration.staticMethods;
read(Object object, Symbol name) {
var getter = _getters[name];
@@ -67,6 +73,7 @@ class GeneratedObjectAccessorService implements ObjectAccessorService {
}
return getter(object);
}
+
void write(Object object, Symbol name, value) {
var setter = _setters[name];
if (setter == null) {
@@ -78,6 +85,8 @@ class GeneratedObjectAccessorService implements ObjectAccessorService {
invoke(object, Symbol name, List args, {Map namedArgs, bool adjust: false}) {
var method;
if (object is Type) {
+ var classMethods = _staticMethods[object];
+ method = classMethods == null ? null : classMethods[name];
} else {
var getter = _getters[name];
method = getter == null ? null : getter(object);
« 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