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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/native_handler.dart

Issue 12525007: Record dependency information to implement first version of dependency (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library native; 5 library native;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 import 'dart:uri'; 8 import 'dart:uri';
9 import 'dart2jslib.dart' hide SourceString; 9 import 'dart2jslib.dart' hide SourceString;
10 import 'dart_types.dart'; 10 import 'dart_types.dart';
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 flushing = false; 211 flushing = false;
212 } 212 }
213 213
214 processClass(ClassElement classElement, cause) { 214 processClass(ClassElement classElement, cause) {
215 assert(!registeredClasses.contains(classElement)); 215 assert(!registeredClasses.contains(classElement));
216 216
217 bool firstTime = registeredClasses.isEmpty; 217 bool firstTime = registeredClasses.isEmpty;
218 pendingClasses.remove(classElement); 218 pendingClasses.remove(classElement);
219 registeredClasses.add(classElement); 219 registeredClasses.add(classElement);
220 220
221 world.registerInstantiatedClass(classElement); 221 // TODO(ahe): Is this really a global dependency?
222 world.registerInstantiatedClass(classElement, compiler.globalDependencies);
222 223
223 // Also parse the node to know all its methods because otherwise it will 224 // Also parse the node to know all its methods because otherwise it will
224 // only be parsed if there is a call to one of its constructors. 225 // only be parsed if there is a call to one of its constructors.
225 classElement.parseNode(compiler); 226 classElement.parseNode(compiler);
226 227
227 if (firstTime) { 228 if (firstTime) {
228 queue.add(onFirstNativeClass); 229 queue.add(onFirstNativeClass);
229 } 230 }
230 } 231 }
231 232
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 void registerJsCall(Send node, ResolverVisitor resolver) { 310 void registerJsCall(Send node, ResolverVisitor resolver) {
310 NativeBehavior behavior = NativeBehavior.ofJsCall(node, compiler, resolver); 311 NativeBehavior behavior = NativeBehavior.ofJsCall(node, compiler, resolver);
311 processNativeBehavior(behavior, node); 312 processNativeBehavior(behavior, node);
312 nativeBehaviors[node] = behavior; 313 nativeBehaviors[node] = behavior;
313 flushQueue(); 314 flushQueue();
314 } 315 }
315 316
316 NativeBehavior getNativeBehaviorOf(Send node) => nativeBehaviors[node]; 317 NativeBehavior getNativeBehaviorOf(Send node) => nativeBehaviors[node];
317 318
318 processNativeBehavior(NativeBehavior behavior, cause) { 319 processNativeBehavior(NativeBehavior behavior, cause) {
320 // TODO(ahe): Are the uses of compiler.globalDependencies truly
321 // global dependencies below?
319 bool allUsedBefore = unusedClasses.isEmpty; 322 bool allUsedBefore = unusedClasses.isEmpty;
320 for (var type in behavior.typesInstantiated) { 323 for (var type in behavior.typesInstantiated) {
321 if (matchedTypeConstraints.contains(type)) continue; 324 if (matchedTypeConstraints.contains(type)) continue;
322 matchedTypeConstraints.add(type); 325 matchedTypeConstraints.add(type);
323 if (type is SpecialType) { 326 if (type is SpecialType) {
324 if (type == SpecialType.JsArray) { 327 if (type == SpecialType.JsArray) {
325 world.registerInstantiatedClass(compiler.listClass); 328 world.registerInstantiatedClass(compiler.listClass,
329 compiler.globalDependencies);
326 } else if (type == SpecialType.JsObject) { 330 } else if (type == SpecialType.JsObject) {
327 world.registerInstantiatedClass(compiler.objectClass); 331 world.registerInstantiatedClass(compiler.objectClass,
332 compiler.globalDependencies);
328 } 333 }
329 continue; 334 continue;
330 } 335 }
331 if (type is InterfaceType) { 336 if (type is InterfaceType) {
332 if (type.element == compiler.intClass) { 337 if (type.element == compiler.intClass) {
333 world.registerInstantiatedClass(compiler.intClass); 338 world.registerInstantiatedClass(
339 compiler.intClass, compiler.globalDependencies);
334 } else if (type.element == compiler.doubleClass) { 340 } else if (type.element == compiler.doubleClass) {
335 world.registerInstantiatedClass(compiler.doubleClass); 341 world.registerInstantiatedClass(
342 compiler.doubleClass, compiler.globalDependencies);
336 } else if (type.element == compiler.numClass) { 343 } else if (type.element == compiler.numClass) {
337 world.registerInstantiatedClass(compiler.doubleClass); 344 world.registerInstantiatedClass(
338 world.registerInstantiatedClass(compiler.intClass); 345 compiler.doubleClass, compiler.globalDependencies);
346 world.registerInstantiatedClass(
347 compiler.intClass, compiler.globalDependencies);
339 } else if (type.element == compiler.stringClass) { 348 } else if (type.element == compiler.stringClass) {
340 world.registerInstantiatedClass(compiler.stringClass); 349 world.registerInstantiatedClass(
350 compiler.stringClass, compiler.globalDependencies);
341 } else if (type.element == compiler.nullClass) { 351 } else if (type.element == compiler.nullClass) {
342 world.registerInstantiatedClass(compiler.nullClass); 352 world.registerInstantiatedClass(
353 compiler.nullClass, compiler.globalDependencies);
343 } else if (type.element == compiler.boolClass) { 354 } else if (type.element == compiler.boolClass) {
344 world.registerInstantiatedClass(compiler.boolClass); 355 world.registerInstantiatedClass(
356 compiler.boolClass, compiler.globalDependencies);
345 } 357 }
346 } 358 }
347 assert(type is DartType); 359 assert(type is DartType);
348 enqueueUnusedClassesMatching( 360 enqueueUnusedClassesMatching(
349 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), 361 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type),
350 cause, 362 cause,
351 'subtypeof($type)'); 363 'subtypeof($type)');
352 } 364 }
353 365
354 // Give an info so that library developers can compile with -v to find why 366 // Give an info so that library developers can compile with -v to find why
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 } else { 907 } else {
896 if (parameters.parameterCount != 0) { 908 if (parameters.parameterCount != 0) {
897 compiler.cancel( 909 compiler.cancel(
898 'native "..." syntax is restricted to functions with zero parameters', 910 'native "..." syntax is restricted to functions with zero parameters',
899 node: nativeBody); 911 node: nativeBody);
900 } 912 }
901 LiteralString jsCode = nativeBody.asLiteralString(); 913 LiteralString jsCode = nativeBody.asLiteralString();
902 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); 914 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[]));
903 } 915 }
904 } 916 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698