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

Unified Diff: sdk/lib/_internal/compiler/implementation/enqueue.dart

Issue 11308257: - Parse the return type of JS during resolution to know what can be instantiated there. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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: sdk/lib/_internal/compiler/implementation/enqueue.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/enqueue.dart (revision 15445)
+++ sdk/lib/_internal/compiler/implementation/enqueue.dart (working copy)
@@ -388,6 +388,39 @@
universe.isChecks.add(type);
}
+ void registerJsCall(Send node, ResolverVisitor resolver) {
+ var argNodes = node.arguments;
sra1 2012/11/29 00:12:51 We should avoid parsing this string in two places.
ngeoffray 2012/11/29 11:10:44 Done.
+ if (argNodes.isEmpty) {
+ compiler.cancel("JS expression has no type", node: node);
+ }
+
+ LiteralString specLiteral = argNodes.head.asLiteralString();
+ if (specLiteral != null) {
+ // Register primitive types we know a JS can return.
+ String specString = specLiteral.dartString.slowToString();
+ for (String typeString in specString.split('|')) {
+ if (specString == 'int') {
+ registerInstantiatedClass(compiler.intClass);
+ } else if (specString == 'double') {
+ registerInstantiatedClass(compiler.doubleClass);
+ } else if (specString == 'num') {
+ registerInstantiatedClass(compiler.numClass);
+ } else if (specString == 'String') {
+ registerInstantiatedClass(compiler.stringClass);
+ } else if (specString == '=List') {
+ registerInstantiatedClass(compiler.listClass);
+ } else if (specString == 'bool') {
+ registerInstantiatedClass(compiler.boolClass);
+ } else if (specString == 'Null') {
+ registerInstantiatedClass(compiler.nullClass);
+ }
+ }
+ }
+
+ nativeEnqueuer.registerJsCall(node, resolver);
+ }
+
+
void forEach(f(WorkItem work)) {
while (!queue.isEmpty) {
f(queue.removeLast()); // TODO(kasperl): Why isn't this removeFirst?

Powered by Google App Engine
This is Rietveld 408576698