| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 class InterceptorEmitter extends CodeEmitterHelper { | 7 class InterceptorEmitter extends CodeEmitterHelper { |
| 8 final Set<String> interceptorInvocationNames = new Set<String>(); | 8 final Set<String> interceptorInvocationNames = new Set<String>(); |
| 9 | 9 |
| 10 void recordMangledNameOfMemberMethod(FunctionElement member, String name) { | 10 void recordMangledNameOfMemberMethod(FunctionElement member, String name) { |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 handler.getConstantsForEmission(task.compareConstants); | 407 handler.getConstantsForEmission(task.compareConstants); |
| 408 for (Constant constant in constants) { | 408 for (Constant constant in constants) { |
| 409 if (constant is TypeConstant) { | 409 if (constant is TypeConstant) { |
| 410 TypeConstant typeConstant = constant; | 410 TypeConstant typeConstant = constant; |
| 411 Element element = typeConstant.representedType.element; | 411 Element element = typeConstant.representedType.element; |
| 412 if (element is ClassElement) { | 412 if (element is ClassElement) { |
| 413 ClassElement classElement = element; | 413 ClassElement classElement = element; |
| 414 if (!analysis.needsClass(classElement)) continue; | 414 if (!analysis.needsClass(classElement)) continue; |
| 415 | 415 |
| 416 elements.add(backend.emitter.constantReference(constant)); | 416 elements.add(backend.emitter.constantReference(constant)); |
| 417 elements.add(js(namer.isolateAccess(classElement))); | 417 elements.add(namer.elementAccess(classElement)); |
| 418 | 418 |
| 419 // Create JavaScript Object map for by-name lookup of generative | 419 // Create JavaScript Object map for by-name lookup of generative |
| 420 // constructors. For example, the class A has three generative | 420 // constructors. For example, the class A has three generative |
| 421 // constructors | 421 // constructors |
| 422 // | 422 // |
| 423 // class A { | 423 // class A { |
| 424 // A() {} | 424 // A() {} |
| 425 // A.foo() {} | 425 // A.foo() {} |
| 426 // A.bar() {} | 426 // A.bar() {} |
| 427 // } | 427 // } |
| 428 // | 428 // |
| 429 // Which are described by the map | 429 // Which are described by the map |
| 430 // | 430 // |
| 431 // {"": A.A$, "foo": A.A$foo, "bar": A.A$bar} | 431 // {"": A.A$, "foo": A.A$foo, "bar": A.A$bar} |
| 432 // | 432 // |
| 433 // We expect most of the time the map will be a singleton. | 433 // We expect most of the time the map will be a singleton. |
| 434 var properties = []; | 434 var properties = []; |
| 435 for (Element member in analysis.constructors(classElement)) { | 435 for (Element member in analysis.constructors(classElement)) { |
| 436 properties.add( | 436 properties.add( |
| 437 new jsAst.Property( | 437 new jsAst.Property( |
| 438 js.string(member.name), | 438 js.string(member.name), |
| 439 new jsAst.VariableUse( | 439 backend.namer.elementAccess(member))); |
| 440 backend.namer.isolateAccess(member)))); | |
| 441 } | 440 } |
| 442 | 441 |
| 443 var map = new jsAst.ObjectInitializer(properties); | 442 var map = new jsAst.ObjectInitializer(properties); |
| 444 elements.add(map); | 443 elements.add(map); |
| 445 } | 444 } |
| 446 } | 445 } |
| 447 } | 446 } |
| 448 | 447 |
| 449 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer.from(elements); | 448 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer.from(elements); |
| 450 String name = | 449 String name = |
| 451 backend.namer.getNameOfGlobalField(backend.mapTypeToInterceptor); | 450 backend.namer.getNameOfGlobalField(backend.mapTypeToInterceptor); |
| 452 jsAst.Expression assignment = | 451 jsAst.Expression assignment = |
| 453 js('${task.isolateProperties}.# = #', [name, array]); | 452 js('${task.isolateProperties}.# = #', [name, array]); |
| 454 | 453 |
| 455 buffer.write(jsAst.prettyPrint(assignment, compiler)); | 454 buffer.write(jsAst.prettyPrint(assignment, compiler)); |
| 456 buffer.write(N); | 455 buffer.write(N); |
| 457 } | 456 } |
| 458 } | 457 } |
| OLD | NEW |