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

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: Rebased 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): Is this really a global dependency?
321 TreeElements elements = compiler.globalDependencies;
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, elements);
326 } else if (type == SpecialType.JsObject) { 329 } else if (type == SpecialType.JsObject) {
327 world.registerInstantiatedClass(compiler.objectClass); 330 world.registerInstantiatedClass(compiler.objectClass, elements);
328 } 331 }
329 continue; 332 continue;
330 } 333 }
331 if (type is InterfaceType) { 334 if (type is InterfaceType) {
332 if (type.element == compiler.intClass) { 335 if (type.element == compiler.intClass) {
333 world.registerInstantiatedClass(compiler.intClass); 336 world.registerInstantiatedClass(compiler.intClass, elements);
334 } else if (type.element == compiler.doubleClass) { 337 } else if (type.element == compiler.doubleClass) {
335 world.registerInstantiatedClass(compiler.doubleClass); 338 world.registerInstantiatedClass(compiler.doubleClass, elements);
336 } else if (type.element == compiler.numClass) { 339 } else if (type.element == compiler.numClass) {
337 world.registerInstantiatedClass(compiler.doubleClass); 340 world.registerInstantiatedClass(compiler.doubleClass, elements);
338 world.registerInstantiatedClass(compiler.intClass); 341 world.registerInstantiatedClass(compiler.intClass, elements);
339 } else if (type.element == compiler.stringClass) { 342 } else if (type.element == compiler.stringClass) {
340 world.registerInstantiatedClass(compiler.stringClass); 343 world.registerInstantiatedClass(compiler.stringClass, elements);
341 } else if (type.element == compiler.nullClass) { 344 } else if (type.element == compiler.nullClass) {
342 world.registerInstantiatedClass(compiler.nullClass); 345 world.registerInstantiatedClass(compiler.nullClass, elements);
343 } else if (type.element == compiler.boolClass) { 346 } else if (type.element == compiler.boolClass) {
344 world.registerInstantiatedClass(compiler.boolClass); 347 world.registerInstantiatedClass(compiler.boolClass, elements);
345 } 348 }
346 } 349 }
347 assert(type is DartType); 350 assert(type is DartType);
348 enqueueUnusedClassesMatching( 351 enqueueUnusedClassesMatching(
349 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), 352 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type),
350 cause, 353 cause,
351 'subtypeof($type)'); 354 'subtypeof($type)');
352 } 355 }
353 356
354 // Give an info so that library developers can compile with -v to find why 357 // Give an info so that library developers can compile with -v to find why
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } else { 899 } else {
897 if (parameters.parameterCount != 0) { 900 if (parameters.parameterCount != 0) {
898 compiler.cancel( 901 compiler.cancel(
899 'native "..." syntax is restricted to functions with zero parameters', 902 'native "..." syntax is restricted to functions with zero parameters',
900 node: nativeBody); 903 node: nativeBody);
901 } 904 }
902 LiteralString jsCode = nativeBody.asLiteralString(); 905 LiteralString jsCode = nativeBody.asLiteralString();
903 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); 906 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[]));
904 } 907 }
905 } 908 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698