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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart

Issue 12051056: Allow native classes to mixin behavior from an ordinary Dart class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comments. Created 7 years, 11 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 part of js_backend; 5 part of js_backend;
6 6
7 class NativeEmitter { 7 class NativeEmitter {
8 8
9 CodeEmitterTask emitter; 9 CodeEmitterTask emitter;
10 CodeBuffer nativeBuffer; 10 CodeBuffer nativeBuffer;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 String get defineNativeClassFunction { 94 String get defineNativeClassFunction {
95 return """ 95 return """
96 function(cls, desc) { 96 function(cls, desc) {
97 var fields = desc['']; 97 var fields = desc[''];
98 var fields_array = fields ? fields.split(',') : []; 98 var fields_array = fields ? fields.split(',') : [];
99 for (var i = 0; i < fields_array.length; i++) { 99 for (var i = 0; i < fields_array.length; i++) {
100 ${emitter.currentGenerateAccessorName}(fields_array[i], desc); 100 ${emitter.currentGenerateAccessorName}(fields_array[i], desc);
101 } 101 }
102 var hasOwnProperty = Object.prototype.hasOwnProperty; 102 var hasOwnProperty = Object.prototype.hasOwnProperty;
103 for (var method in desc) { 103 for (var method in desc) {
104 if (method) { """/* Short version of: if (method != '') */""" 104 if (method) {
kasperl 2013/01/24 11:06:54 I removed this comment because the newline after t
105 if (hasOwnProperty.call(desc, method)) { 105 if (hasOwnProperty.call(desc, method)) {
106 $dynamicName(method)[cls] = desc[method]; 106 $dynamicName(method)[cls] = desc[method];
107 } 107 }
108 } 108 }
109 } 109 }
110 }"""; 110 }""";
111 } 111 }
112 112
113 bool isNativeGlobal(String quotedName) { 113 bool isNativeGlobal(String quotedName) {
114 return identical(quotedName[1], '@'); 114 return identical(quotedName[1], '@');
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 if (emitter.compiler.enableMinification) targetBuffer.add(';'); 537 if (emitter.compiler.enableMinification) targetBuffer.add(';');
538 targetBuffer.add(js.prettyPrint( 538 targetBuffer.add(js.prettyPrint(
539 new js.ExpressionStatement(init), compiler)); 539 new js.ExpressionStatement(init), compiler));
540 targetBuffer.add('\n'); 540 targetBuffer.add('\n');
541 } 541 }
542 542
543 targetBuffer.add(nativeBuffer); 543 targetBuffer.add(nativeBuffer);
544 targetBuffer.add('\n'); 544 targetBuffer.add('\n');
545 } 545 }
546 } 546 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698