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

Unified Diff: lib/runtime/dart_runtime.js

Issue 1152583002: Add constructors to signatures (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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
Index: lib/runtime/dart_runtime.js
diff --git a/lib/runtime/dart_runtime.js b/lib/runtime/dart_runtime.js
index 255d61964ea7f6c2923ccc2f359d1333c4eb336e..4d0aa208d41ca4f43b0e48acd2b7837d88f2b6f6 100644
--- a/lib/runtime/dart_runtime.js
+++ b/lib/runtime/dart_runtime.js
@@ -997,6 +997,7 @@ var dart, _js_helper, _js_primitives;
}
dart.generic = generic;
+ let _constructorSig = Symbol('sigCtor');
let _methodSig = Symbol("sig");
let _staticSig = Symbol("sigStatic");
@@ -1017,6 +1018,22 @@ var dart, _js_helper, _js_primitives;
return sig;
}
+ /// Get the type of a constructor from a class using the stored signature
+ /// If name is undefined, returns the type of the default constructor
+ /// Returns undefined if the constructor is not found.
+ function _getConstructorType(cls, name) {
+ if(!name) name = cls.name;
+ if (cls === void 0) return void 0;
+ if (cls == null) return void 0;
+ let sigCtor = cls[_constructorSig];
+ if (sigCtor === void 0) return void 0;
+ let parts = sigCtor[name];
+ if (parts === void 0) return void 0;
+ let sig = functionType.apply(null, parts);
+ return sig;
+ }
+ dart.classGetConstructorType = _getConstructorType;
+
/// Given an object and a method name, tear off the method.
/// Sets the runtime type of the torn off method appropriately,
/// and also binds the object.
@@ -1039,6 +1056,11 @@ var dart, _js_helper, _js_primitives;
});
}
+ // Set up the constructor signature field on the constructor
+ function _setConstructorSignature(f, sigF) {
+ defineMemoizedGetter(f, _constructorSig, sigF);
+ }
+
// Set up the static signature field on the constructor
function _setStaticSignature(f, sigF) {
defineMemoizedGetter(f, _staticSig, sigF);
@@ -1066,12 +1088,15 @@ var dart, _js_helper, _js_primitives;
/// permit eagerly setting the runtimeType field on the methods
/// while still lazily computing the type descriptor object.
function setSignature(f, signature) {
+ let constructors =
+ ('constructors' in signature) ? signature.constructors : () => ({});
let methods =
('methods' in signature) ? signature.methods : () => ({});
let statics =
('statics' in signature) ? signature.statics : () => ({});
let names =
('names' in signature) ? signature.names : [];
+ _setConstructorSignature(f, constructors);
_setMethodSignature(f, methods);
_setStaticSignature(f, statics);
_setStaticTypes(f, names);

Powered by Google App Engine
This is Rietveld 408576698