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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/native_emitter.dart

Issue 2871583002: Pass InterceptorData through ResolutionWorldBuilder and access it through ClosedWorld (Closed)
Patch Set: Created 3 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 unified diff | Download patch
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 dart2js.js_emitter.native_emitter; 5 library dart2js.js_emitter.native_emitter;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../compiler.dart' show Compiler; 8 import '../compiler.dart' show Compiler;
9 import '../elements/types.dart' show DartType, FunctionType; 9 import '../elements/types.dart' show DartType, FunctionType;
10 import '../elements/entities.dart'; 10 import '../elements/entities.dart';
11 import '../js/js.dart' as jsAst; 11 import '../js/js.dart' as jsAst;
12 import '../js/js.dart' show js; 12 import '../js/js.dart' show js;
13 import '../js_backend/js_backend.dart' show JavaScriptBackend, Namer; 13 import '../js_backend/js_backend.dart' show JavaScriptBackend, Namer;
14 import '../js_backend/interceptor_data.dart'; 14 import '../js_backend/interceptor_data.dart';
15 import '../js_backend/native_data.dart'; 15 import '../js_backend/native_data.dart';
16 import '../universe/world_builder.dart' show CodegenWorldBuilder; 16 import '../universe/world_builder.dart' show CodegenWorldBuilder;
17 17
18 import 'code_emitter_task.dart' show CodeEmitterTask; 18 import 'code_emitter_task.dart' show CodeEmitterTask;
19 import 'model.dart'; 19 import 'model.dart';
20 20
21 class NativeEmitter { 21 class NativeEmitter {
22 final CodeEmitterTask emitterTask; 22 final CodeEmitterTask emitterTask;
23 final NativeData nativeData; 23 final NativeData nativeData;
24 final InterceptorData interceptorData;
24 25
25 // Whether the application contains native classes. 26 // Whether the application contains native classes.
26 bool hasNativeClasses = false; 27 bool hasNativeClasses = false;
27 28
28 // Caches the native subtypes of a native class. 29 // Caches the native subtypes of a native class.
29 Map<ClassEntity, List<ClassEntity>> subtypes = 30 Map<ClassEntity, List<ClassEntity>> subtypes =
30 <ClassEntity, List<ClassEntity>>{}; 31 <ClassEntity, List<ClassEntity>>{};
31 32
32 // Caches the direct native subtypes of a native class. 33 // Caches the direct native subtypes of a native class.
33 Map<ClassEntity, List<ClassEntity>> directSubtypes = 34 Map<ClassEntity, List<ClassEntity>> directSubtypes =
34 <ClassEntity, List<ClassEntity>>{}; 35 <ClassEntity, List<ClassEntity>>{};
35 36
36 // Caches the methods that have a native body. 37 // Caches the methods that have a native body.
37 Set<FunctionEntity> nativeMethods = new Set<FunctionEntity>(); 38 Set<FunctionEntity> nativeMethods = new Set<FunctionEntity>();
38 39
39 NativeEmitter(this.emitterTask, this.nativeData); 40 NativeEmitter(this.emitterTask, this.nativeData, this.interceptorData);
40 41
41 Compiler get compiler => emitterTask.compiler; 42 Compiler get compiler => emitterTask.compiler;
42 43
43 JavaScriptBackend get backend => compiler.backend; 44 JavaScriptBackend get backend => compiler.backend;
44 45
45 CodegenWorldBuilder get worldBuilder => compiler.codegenWorldBuilder; 46 CodegenWorldBuilder get worldBuilder => compiler.codegenWorldBuilder;
46 47
47 InterceptorData get interceptorData => backend.interceptorData;
48
49 Namer get namer => backend.namer; 48 Namer get namer => backend.namer;
50 49
51 /** 50 /**
52 * Prepares native classes for emission. Returns the unneeded classes. 51 * Prepares native classes for emission. Returns the unneeded classes.
53 * 52 *
54 * Removes trivial classes (that can be represented by a super type) and 53 * Removes trivial classes (that can be represented by a super type) and
55 * generates properties that have to be added to classes (native or not). 54 * generates properties that have to be added to classes (native or not).
56 * 55 *
57 * Updates the `nativeLeafTags`, `nativeNonLeafTags` and `nativeExtensions` 56 * Updates the `nativeLeafTags`, `nativeNonLeafTags` and `nativeExtensions`
58 * fields of the given classes. This data must be emitted with the 57 * fields of the given classes. This data must be emitted with the
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // satisfy a check against [element], in which case an interceptor must be 360 // satisfy a check against [element], in which case an interceptor must be
362 // used. We should also use an interceptor if the check can't be satisfied 361 // used. We should also use an interceptor if the check can't be satisfied
363 // by a native class in case we get a native instance that tries to spoof 362 // by a native class in case we get a native instance that tries to spoof
364 // the type info. i.e the criteria for whether or not to use an interceptor 363 // the type info. i.e the criteria for whether or not to use an interceptor
365 // is whether the receiver can be native, not the type of the test. 364 // is whether the receiver can be native, not the type of the test.
366 ClassEntity cls = element; 365 ClassEntity cls = element;
367 if (nativeData.isNativeOrExtendsNative(cls)) return true; 366 if (nativeData.isNativeOrExtendsNative(cls)) return true;
368 return isSupertypeOfNativeClass(element); 367 return isSupertypeOfNativeClass(element);
369 } 368 }
370 } 369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698