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

Side by Side Diff: lib/compiler/implementation/emitter.dart

Issue 10398044: Reverting 7667 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | 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 /** 5 /**
6 * A function element that represents a closure call. The signature is copied 6 * A function element that represents a closure call. The signature is copied
7 * from the given element. 7 * from the given element.
8 */ 8 */
9 class ClosureInvocationElement extends FunctionElement { 9 class ClosureInvocationElement extends FunctionElement {
10 ClosureInvocationElement(SourceString name, 10 ClosureInvocationElement(SourceString name,
11 FunctionElement other) 11 FunctionElement other)
12 : super.from(name, other, other.enclosingElement); 12 : super.from(name, other, other.enclosingElement);
13 13
14 isInstanceMember() => true; 14 isInstanceMember() => true;
15 } 15 }
16 16
17 /** 17 /**
18 * Generates the code for all used classes in the program. Static fields (even 18 * Generates the code for all used classes in the program. Static fields (even
19 * in classes) are ignored, since they can be treated as non-class elements. 19 * in classes) are ignored, since they can be treated as non-class elements.
20 * 20 *
21 * The code for the containing (used) methods must exist in the [:universe:]. 21 * The code for the containing (used) methods must exist in the [:universe:].
22 */ 22 */
23 class CodeEmitterTask extends CompilerTask { 23 class CodeEmitterTask extends CompilerTask {
24 bool needsInheritFunction = false; 24 bool needsInheritFunction = false;
25 bool needsDefineClass = false; 25 bool needsDefineClass = false;
26 bool needsClosureClass = false; 26 bool needsClosureClass = false;
27 final Namer namer; 27 final Namer namer;
28 NativeEmitter nativeEmitter; 28 final NativeEmitter nativeEmitter;
29 StringBuffer boundClosureBuffer; 29 StringBuffer boundClosureBuffer;
30 StringBuffer mainBuffer; 30 StringBuffer mainBuffer;
31 /** Shorter access to [isolatePropertiesName]. Both here in the code, as 31 /** Shorter access to [isolatePropertiesName]. Both here in the code, as
32 well as in the generated code. */ 32 well as in the generated code. */
33 String isolateProperties; 33 String isolateProperties;
34 34
35 CodeEmitterTask(Compiler compiler) 35 CodeEmitterTask(Compiler compiler)
36 : namer = compiler.namer, 36 : namer = compiler.namer,
37 nativeEmitter = new NativeEmitter(compiler),
37 boundClosureBuffer = new StringBuffer(), 38 boundClosureBuffer = new StringBuffer(),
38 mainBuffer = new StringBuffer(), 39 mainBuffer = new StringBuffer(),
39 super(compiler) { 40 super(compiler);
40 nativeEmitter = new NativeEmitter(this);
41 }
42 41
43 String get name() => 'CodeEmitter'; 42 String get name() => 'CodeEmitter';
44 43
45 String get defineClassName() 44 String get defineClassName()
46 => '${namer.ISOLATE}.\$defineClass'; 45 => '${namer.ISOLATE}.\$defineClass';
47 String get finishClassesName() 46 String get finishClassesName()
48 => '${namer.ISOLATE}.\$finishClasses'; 47 => '${namer.ISOLATE}.\$finishClasses';
49 String get finishIsolateConstructorName() 48 String get finishIsolateConstructorName()
50 => '${namer.ISOLATE}.\$finishIsolateConstructor'; 49 => '${namer.ISOLATE}.\$finishIsolateConstructor';
51 String get pendingClassesName() 50 String get pendingClassesName()
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 }; 763 };
765 '''); 764 ''');
766 } 765 }
767 766
768 void emitExtraAccessors(Element member, 767 void emitExtraAccessors(Element member,
769 void defineInstanceMember(String invocationName, 768 void defineInstanceMember(String invocationName,
770 String definition)) { 769 String definition)) {
771 if (member.kind == ElementKind.GETTER || member.kind == ElementKind.FIELD) { 770 if (member.kind == ElementKind.GETTER || member.kind == ElementKind.FIELD) {
772 Set<Selector> selectors = compiler.universe.invokedNames[member.name]; 771 Set<Selector> selectors = compiler.universe.invokedNames[member.name];
773 if (selectors !== null && !selectors.isEmpty()) { 772 if (selectors !== null && !selectors.isEmpty()) {
774 emitCallStubForGetter(member, selectors, defineInstanceMember); 773 compiler.emitter.emitCallStubForGetter(member, selectors,
774 defineInstanceMember);
775 } 775 }
776 } else if (member.kind == ElementKind.FUNCTION) { 776 } else if (member.kind == ElementKind.FUNCTION) {
777 if (compiler.universe.hasGetter(member, compiler)) { 777 if (compiler.universe.hasGetter(member, compiler)) {
778 emitDynamicFunctionGetter(member, defineInstanceMember); 778 compiler.emitter.emitDynamicFunctionGetter(member,
779 defineInstanceMember);
779 } 780 }
780 } 781 }
781 } 782 }
782 783
783 void emitNoSuchMethodCalls(void defineInstanceMember(String invocationName, 784 void emitNoSuchMethodCalls(void defineInstanceMember(String invocationName,
784 String definition)) { 785 String definition)) {
785 // Do not generate no such method calls if there is no class. 786 // Do not generate no such method calls if there is no class.
786 if (compiler.universe.instantiatedClasses.isEmpty()) return; 787 if (compiler.universe.instantiatedClasses.isEmpty()) return;
787 788
788 ClassElement objectClass = 789 ClassElement objectClass =
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 mainBuffer.add('function init() {\n'); 972 mainBuffer.add('function init() {\n');
972 mainBuffer.add(' $isolateProperties = {};\n'); 973 mainBuffer.add(' $isolateProperties = {};\n');
973 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer); 974 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer);
974 emitFinishIsolateConstructor(mainBuffer); 975 emitFinishIsolateConstructor(mainBuffer);
975 mainBuffer.add('}\n'); 976 mainBuffer.add('}\n');
976 compiler.assembledCode = mainBuffer.toString(); 977 compiler.assembledCode = mainBuffer.toString();
977 }); 978 });
978 return compiler.assembledCode; 979 return compiler.assembledCode;
979 } 980 }
980 } 981 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/native_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698