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

Side by Side Diff: dart/frog/leg/emitter.dart

Issue 9474040: Improve exception handling: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add TODO Created 8 years, 9 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
« no previous file with comments | « no previous file | dart/frog/leg/lib/js_helper.dart » ('j') | 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) 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,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 164
165 void addInstanceMember(Element member, 165 void addInstanceMember(Element member,
166 String prototype, 166 String prototype,
167 StringBuffer buffer) { 167 StringBuffer buffer) {
168 assert(member.isInstanceMember()); 168 assert(member.isInstanceMember());
169 if (member.kind === ElementKind.FUNCTION 169 if (member.kind === ElementKind.FUNCTION
170 || member.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY 170 || member.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY
171 || member.kind === ElementKind.GETTER 171 || member.kind === ElementKind.GETTER
172 || member.kind === ElementKind.SETTER) { 172 || member.kind === ElementKind.SETTER) {
173 if (member.modifiers !== null && member.modifiers.isAbstract()) return;
173 String codeBlock = compiler.universe.generatedCode[member]; 174 String codeBlock = compiler.universe.generatedCode[member];
174 if (codeBlock == null) return; 175 if (codeBlock == null) return;
175 buffer.add('$prototype.${namer.getName(member)} = $codeBlock;\n'); 176 buffer.add('$prototype.${namer.getName(member)} = $codeBlock;\n');
176 codeBlock = compiler.universe.generatedBailoutCode[member]; 177 codeBlock = compiler.universe.generatedBailoutCode[member];
177 if (codeBlock !== null) { 178 if (codeBlock !== null) {
178 String name = namer.getBailoutName(member); 179 String name = namer.getBailoutName(member);
179 buffer.add('$prototype.$name = $codeBlock;\n'); 180 buffer.add('$prototype.$name = $codeBlock;\n');
180 } 181 }
181 FunctionElement function = member; 182 FunctionElement function = member;
182 if (!function.computeParameters(compiler).optionalParameters.isEmpty()) { 183 if (!function.computeParameters(compiler).optionalParameters.isEmpty()) {
183 addParameterStubs(member, (name) => '$prototype.$name', buffer); 184 addParameterStubs(member, (name) => '$prototype.$name', buffer);
184 } 185 }
185 } else if (member.kind === ElementKind.FIELD) { 186 } else if (member.kind === ElementKind.FIELD) {
186 // TODO(ngeoffray): Have another class generate the code for the 187 // TODO(ngeoffray): Have another class generate the code for the
187 // fields. 188 // fields.
188 if (compiler.universe.invokedSetters.contains(member.name)) { 189 if ((member.modifiers === null || !member.modifiers.isFinal()) &&
190 compiler.universe.invokedSetters.contains(member.name)) {
189 String setterName = namer.setterName(member.name); 191 String setterName = namer.setterName(member.name);
190 buffer.add('$prototype.$setterName = function(v){\n' + 192 buffer.add('$prototype.$setterName = function(v){\n' +
191 ' this.${namer.getName(member)} = v;\n};\n'); 193 ' this.${namer.getName(member)} = v;\n};\n');
192 } 194 }
193 if (compiler.universe.invokedGetters.contains(member.name)) { 195 if (compiler.universe.invokedGetters.contains(member.name)) {
194 String getterName = namer.getterName(member.name); 196 String getterName = namer.getterName(member.name);
195 buffer.add('$prototype.$getterName = function(){\n' + 197 buffer.add('$prototype.$getterName = function(){\n' +
196 ' return this.${namer.getName(member)};\n};\n'); 198 ' return this.${namer.getName(member)};\n};\n');
197 } 199 }
198 } else { 200 } else {
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 emitCompileTimeConstants(buffer); 608 emitCompileTimeConstants(buffer);
607 emitStaticFinalFieldInitializations(buffer); 609 emitStaticFinalFieldInitializations(buffer);
608 buffer.add('var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n'); 610 buffer.add('var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n');
609 Element main = compiler.mainApp.find(Compiler.MAIN); 611 Element main = compiler.mainApp.find(Compiler.MAIN);
610 buffer.add('${namer.isolateAccess(main)}();\n'); 612 buffer.add('${namer.isolateAccess(main)}();\n');
611 compiler.assembledCode = buffer.toString(); 613 compiler.assembledCode = buffer.toString();
612 }); 614 });
613 return compiler.assembledCode; 615 return compiler.assembledCode;
614 } 616 }
615 } 617 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698