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

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

Issue 2916893002: Handle int constant (Closed)
Patch Set: Updated cf. comments Created 3 years, 6 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.interceptor_stub_generator; 5 library dart2js.js_emitter.interceptor_stub_generator;
6 6
7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; 7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames;
8 8
9 import '../common_elements.dart'; 9 import '../common_elements.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
11 import '../elements/entities.dart'; 11 import '../elements/entities.dart';
12 import '../elements/types.dart' show InterfaceType; 12 import '../elements/types.dart' show InterfaceType;
13 import '../js/js.dart' as jsAst; 13 import '../js/js.dart' as jsAst;
14 import '../js/js.dart' show js; 14 import '../js/js.dart' show js;
15 import '../js_backend/namer.dart' show Namer; 15 import '../js_backend/namer.dart' show Namer;
16 import '../js_backend/constant_handler_javascript.dart'
17 show JavaScriptConstantCompiler;
18 import '../js_backend/custom_elements_analysis.dart' 16 import '../js_backend/custom_elements_analysis.dart'
19 show CustomElementsCodegenAnalysis; 17 show CustomElementsCodegenAnalysis;
20 import '../js_backend/native_data.dart'; 18 import '../js_backend/native_data.dart';
21 import '../js_backend/interceptor_data.dart'; 19 import '../js_backend/interceptor_data.dart';
22 import '../native/enqueue.dart'; 20 import '../native/enqueue.dart';
23 import '../options.dart'; 21 import '../options.dart';
24 import '../universe/selector.dart' show Selector; 22 import '../universe/selector.dart' show Selector;
25 import '../universe/world_builder.dart' show CodegenWorldBuilder; 23 import '../universe/world_builder.dart' show CodegenWorldBuilder;
26 import '../world.dart' show ClosedWorld; 24 import '../world.dart' show ClosedWorld;
27 25
28 import 'code_emitter_task.dart' show CodeEmitterTask, Emitter; 26 import 'code_emitter_task.dart' show CodeEmitterTask, Emitter;
29 27
30 class InterceptorStubGenerator { 28 class InterceptorStubGenerator {
31 final CompilerOptions _options; 29 final CompilerOptions _options;
32 final CommonElements _commonElements; 30 final CommonElements _commonElements;
33 final CodeEmitterTask _emitterTask; 31 final CodeEmitterTask _emitterTask;
34 final NativeCodegenEnqueuer _nativeCodegenEnqueuer; 32 final NativeCodegenEnqueuer _nativeCodegenEnqueuer;
35 final JavaScriptConstantCompiler _constants;
36 final Namer _namer; 33 final Namer _namer;
37 final OneShotInterceptorData _oneShotInterceptorData; 34 final OneShotInterceptorData _oneShotInterceptorData;
38 final CustomElementsCodegenAnalysis _customElementsCodegenAnalysis; 35 final CustomElementsCodegenAnalysis _customElementsCodegenAnalysis;
39 final CodegenWorldBuilder _codegenWorldBuilder; 36 final CodegenWorldBuilder _codegenWorldBuilder;
40 final ClosedWorld _closedWorld; 37 final ClosedWorld _closedWorld;
41 38
42 InterceptorStubGenerator( 39 InterceptorStubGenerator(
43 this._options, 40 this._options,
44 this._commonElements, 41 this._commonElements,
45 this._emitterTask, 42 this._emitterTask,
46 this._nativeCodegenEnqueuer, 43 this._nativeCodegenEnqueuer,
47 this._constants,
48 this._namer, 44 this._namer,
49 this._oneShotInterceptorData, 45 this._oneShotInterceptorData,
50 this._customElementsCodegenAnalysis, 46 this._customElementsCodegenAnalysis,
51 this._codegenWorldBuilder, 47 this._codegenWorldBuilder,
52 this._closedWorld); 48 this._closedWorld);
53 49
54 NativeData get _nativeData => _closedWorld.nativeData; 50 NativeData get _nativeData => _closedWorld.nativeData;
55 51
56 InterceptorData get _interceptorData => _closedWorld.interceptorData; 52 InterceptorData get _interceptorData => _closedWorld.interceptorData;
57 53
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 ]); 406 ]);
411 } 407 }
412 408
413 jsAst.ArrayInitializer generateTypeToInterceptorMap() { 409 jsAst.ArrayInitializer generateTypeToInterceptorMap() {
414 // TODO(sra): Perhaps inject a constant instead? 410 // TODO(sra): Perhaps inject a constant instead?
415 CustomElementsCodegenAnalysis analysis = _customElementsCodegenAnalysis; 411 CustomElementsCodegenAnalysis analysis = _customElementsCodegenAnalysis;
416 if (!analysis.needsTable) return null; 412 if (!analysis.needsTable) return null;
417 413
418 List<jsAst.Expression> elements = <jsAst.Expression>[]; 414 List<jsAst.Expression> elements = <jsAst.Expression>[];
419 List<ConstantValue> constants = 415 List<ConstantValue> constants =
420 _constants.getConstantsForEmission(_emitter.compareConstants); 416 _codegenWorldBuilder.getConstantsForEmission(_emitter.compareConstants);
421 for (ConstantValue constant in constants) { 417 for (ConstantValue constant in constants) {
422 if (constant is TypeConstantValue && 418 if (constant is TypeConstantValue &&
423 constant.representedType is InterfaceType) { 419 constant.representedType is InterfaceType) {
424 InterfaceType type = constant.representedType; 420 InterfaceType type = constant.representedType;
425 ClassEntity classElement = type.element; 421 ClassEntity classElement = type.element;
426 if (!analysis.needsClass(classElement)) continue; 422 if (!analysis.needsClass(classElement)) continue;
427 423
428 elements.add(_emitter.constantReference(constant)); 424 elements.add(_emitter.constantReference(constant));
429 elements.add(_emitter.interceptorClassAccess(classElement)); 425 elements.add(_emitter.interceptorClassAccess(classElement));
430 426
(...skipping 19 matching lines...) Expand all
450 } 446 }
451 447
452 var map = new jsAst.ObjectInitializer(properties); 448 var map = new jsAst.ObjectInitializer(properties);
453 elements.add(map); 449 elements.add(map);
454 } 450 }
455 } 451 }
456 452
457 return new jsAst.ArrayInitializer(elements); 453 return new jsAst.ArrayInitializer(elements);
458 } 454 }
459 } 455 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698