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

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

Issue 1245833003: dart2js: Support checked setters in the program builder. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix bad copy/paste. Created 5 years, 5 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
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/model.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.program_builder; 5 library dart2js.js_emitter.program_builder;
6 6
7 import '../js_emitter.dart' show computeMixinClass, Emitter; 7 import '../js_emitter.dart' show computeMixinClass, Emitter;
8 import '../model.dart'; 8 import '../model.dart';
9 9
10 import '../../common.dart'; 10 import '../../common.dart';
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 /// HACK for Incremental Compilation. 343 /// HACK for Incremental Compilation.
344 /// 344 ///
345 /// Returns a class that contains the fields of a class. 345 /// Returns a class that contains the fields of a class.
346 Class buildFieldsHackForIncrementalCompilation(ClassElement element) { 346 Class buildFieldsHackForIncrementalCompilation(ClassElement element) {
347 assert(_compiler.hasIncrementalSupport); 347 assert(_compiler.hasIncrementalSupport);
348 348
349 List<Field> instanceFields = _buildFields(element, false); 349 List<Field> instanceFields = _buildFields(element, false);
350 js.Name name = namer.className(element); 350 js.Name name = namer.className(element);
351 351
352 return new Class( 352 return new Class(
353 element, name, null, [], instanceFields, [], [], [], [], [], null, 353 element, name, null, [], instanceFields, [], [], [], [], [], [], null,
354 isDirectlyInstantiated: true, 354 isDirectlyInstantiated: true,
355 onlyForRti: false, 355 onlyForRti: false,
356 isNative: element.isNative); 356 isNative: element.isNative);
357 } 357 }
358 358
359 Class _buildClass(ClassElement element) { 359 Class _buildClass(ClassElement element) {
360 bool onlyForRti = collector.classesOnlyNeededForRti.contains(element); 360 bool onlyForRti = collector.classesOnlyNeededForRti.contains(element);
361 361
362 List<Method> methods = []; 362 List<Method> methods = [];
363 List<StubMethod> callStubs = <StubMethod>[]; 363 List<StubMethod> callStubs = <StubMethod>[];
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 List<Field> instanceFields = 423 List<Field> instanceFields =
424 onlyForRti ? const <Field>[] : _buildFields(element, false); 424 onlyForRti ? const <Field>[] : _buildFields(element, false);
425 List<Field> staticFieldsForReflection = 425 List<Field> staticFieldsForReflection =
426 onlyForRti ? const <Field>[] : _buildFields(element, true); 426 onlyForRti ? const <Field>[] : _buildFields(element, true);
427 427
428 TypeTestProperties typeTests = 428 TypeTestProperties typeTests =
429 runtimeTypeGenerator.generateIsTests( 429 runtimeTypeGenerator.generateIsTests(
430 element, 430 element,
431 storeFunctionTypeInMetadata: _storeFunctionTypesInMetadata); 431 storeFunctionTypeInMetadata: _storeFunctionTypesInMetadata);
432 432
433 List<StubMethod> checkedSetters = <StubMethod>[];
434 for (Field field in instanceFields) {
435 if (field.needsCheckedSetter) {
436 assert(!field.needsUncheckedSetter);
437 Element element = field.element;
438 js.Expression code = backend.generatedCode[element];
439 assert(code != null);
440 js.Name name = namer.deriveSetterName(field.accessorName);
441 checkedSetters.add(_buildStubMethod(name, code, element: element));
442 }
443 }
444
433 List<StubMethod> isChecks = <StubMethod>[]; 445 List<StubMethod> isChecks = <StubMethod>[];
434 typeTests.properties.forEach((js.Name name, js.Node code) { 446 typeTests.properties.forEach((js.Name name, js.Node code) {
435 isChecks.add(_buildStubMethod(name, code)); 447 isChecks.add(_buildStubMethod(name, code));
436 }); 448 });
437 449
438 js.Name name = namer.className(element); 450 js.Name name = namer.className(element);
439 String holderName = namer.globalObjectFor(element); 451 String holderName = namer.globalObjectFor(element);
440 // TODO(floitsch): we shouldn't update the registry in the middle of 452 // TODO(floitsch): we shouldn't update the registry in the middle of
441 // building a class. 453 // building a class.
442 Holder holder = _registry.registerHolder(holderName); 454 Holder holder = _registry.registerHolder(holderName);
443 bool isInstantiated = 455 bool isInstantiated =
444 _compiler.codegenWorld.directlyInstantiatedClasses.contains(element); 456 _compiler.codegenWorld.directlyInstantiatedClasses.contains(element);
445 457
446 Class result; 458 Class result;
447 if (element.isMixinApplication && !onlyForRti) { 459 if (element.isMixinApplication && !onlyForRti) {
448 assert(!element.isNative); 460 assert(!element.isNative);
449 assert(methods.isEmpty); 461 assert(methods.isEmpty);
450 462
451 result = new MixinApplication(element, 463 result = new MixinApplication(element,
452 name, holder, 464 name, holder,
453 instanceFields, 465 instanceFields,
454 staticFieldsForReflection, 466 staticFieldsForReflection,
455 callStubs, 467 callStubs,
456 typeVariableReaderStubs, 468 typeVariableReaderStubs,
469 checkedSetters,
457 isChecks, 470 isChecks,
458 typeTests.functionTypeIndex, 471 typeTests.functionTypeIndex,
459 isDirectlyInstantiated: isInstantiated, 472 isDirectlyInstantiated: isInstantiated,
460 onlyForRti: onlyForRti); 473 onlyForRti: onlyForRti);
461 } else { 474 } else {
462 result = new Class(element, 475 result = new Class(element,
463 name, holder, methods, instanceFields, 476 name, holder, methods, instanceFields,
464 staticFieldsForReflection, 477 staticFieldsForReflection,
465 callStubs, 478 callStubs,
466 typeVariableReaderStubs, 479 typeVariableReaderStubs,
467 noSuchMethodStubs, 480 noSuchMethodStubs,
481 checkedSetters,
468 isChecks, 482 isChecks,
469 typeTests.functionTypeIndex, 483 typeTests.functionTypeIndex,
470 isDirectlyInstantiated: isInstantiated, 484 isDirectlyInstantiated: isInstantiated,
471 onlyForRti: onlyForRti, 485 onlyForRti: onlyForRti,
472 isNative: element.isNative); 486 isNative: element.isNative);
473 } 487 }
474 _classes[element] = result; 488 _classes[element] = result;
475 return result; 489 return result;
476 } 490 }
477 491
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 Constant constant = new Constant(name, holder, constantValue); 814 Constant constant = new Constant(name, holder, constantValue);
801 _constants[constantValue] = constant; 815 _constants[constantValue] = constant;
802 } 816 }
803 } 817 }
804 818
805 Holder _registerStaticStateHolder() { 819 Holder _registerStaticStateHolder() {
806 return _registry.registerHolder( 820 return _registry.registerHolder(
807 namer.staticStateHolder, isStaticStateHolder: true); 821 namer.staticStateHolder, isStaticStateHolder: true);
808 } 822 }
809 } 823 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/model.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698