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

Unified Diff: lib/compiler/implementation/native_emitter.dart

Issue 10696194: Introduce CodeBuffer as StringBuffer replacement in compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/native_emitter.dart
diff --git a/lib/compiler/implementation/native_emitter.dart b/lib/compiler/implementation/native_emitter.dart
index 85fde0010f3ebddae29003cc853034428fc0bf14..53dc02b39a198c1834c11ae90266c5dacd939ea8 100644
--- a/lib/compiler/implementation/native_emitter.dart
+++ b/lib/compiler/implementation/native_emitter.dart
@@ -5,7 +5,7 @@
class NativeEmitter {
CodeEmitterTask emitter;
- StringBuffer nativeBuffer;
+ CodeBuffer nativeBuffer;
// Classes that participate in dynamic dispatch. These are the
// classes that contain used members.
@@ -40,7 +40,7 @@ class NativeEmitter {
overriddenMethods = new Set<FunctionElement>(),
nativeMethods = new Set<FunctionElement>(),
redirectingMethods = new Map<FunctionElement, String>(),
- nativeBuffer = new StringBuffer();
+ nativeBuffer = new CodeBuffer();
Compiler get compiler() => emitter.compiler;
@@ -103,9 +103,7 @@ function(cls, fields, methods) {
nativeBuffer.add(nativeCode);
nativeBuffer.add(';\n');
- void defineInstanceMember(String name,
- String value,
- [List<SourceMappingEntry> sourceMappings]) {
+ void defineInstanceMember(String name, CodeBuffer value) {
nativeBuffer.add("$className.$name = $value;\n");
}
@@ -146,10 +144,10 @@ function(cls, fields, methods) {
return;
}
- StringBuffer fieldBuffer = new StringBuffer();
+ CodeBuffer fieldBuffer = new CodeBuffer();
emitter.emitClassFields(classElement, fieldBuffer);
- StringBuffer methodBuffer = new StringBuffer();
+ CodeBuffer methodBuffer = new CodeBuffer();
emitter.emitInstanceMembers(classElement, methodBuffer, false);
if (methodBuffer.isEmpty() && fieldBuffer.isEmpty()) return;
@@ -169,7 +167,7 @@ function(cls, fields, methods) {
return result === null ? const<ClassElement>[] : result;
}
- void potentiallyConvertDartClosuresToJs(StringBuffer code,
+ void potentiallyConvertDartClosuresToJs(CodeBuffer code,
FunctionElement member,
List<String> argumentsBuffer) {
FunctionSignature parameters = member.computeSignature(compiler);
@@ -194,7 +192,7 @@ function(cls, fields, methods) {
String stubParameters,
List<String> argumentsBuffer,
int indexOfLastOptionalArgumentInParameters,
- StringBuffer buffer) {
+ CodeBuffer buffer) {
// The target JS function may check arguments.length so we need to
// make sure not to pass any unspecified optional arguments to it.
// For example, for the following Dart method:
@@ -211,7 +209,7 @@ function(cls, fields, methods) {
String nativeName = classElement.nativeName.slowToString();
String nativeArguments = Strings.join(nativeArgumentsBuffer, ",");
- StringBuffer code = new StringBuffer();
+ CodeBuffer code = new CodeBuffer();
potentiallyConvertDartClosuresToJs(code, member, argumentsBuffer);
if (!nativeMethods.contains(member)) {
@@ -374,7 +372,7 @@ function(cls, fields, methods) {
return isSupertypeOfNativeClass(element);
}
- void emitIsChecks(StringBuffer checkBuffer) {
+ void emitIsChecks(CodeBuffer checkBuffer) {
for (Element type in compiler.codegenWorld.isChecks) {
if (!requiresNativeIsCheck(type)) continue;
String name = compiler.namer.operatorIs(type);
@@ -383,7 +381,7 @@ function(cls, fields, methods) {
}
}
- void assembleCode(StringBuffer targetBuffer) {
+ void assembleCode(CodeBuffer targetBuffer) {
if (nativeClasses.isEmpty()) return;
emitDynamicDispatchMetadata();
@@ -392,7 +390,7 @@ function(cls, fields, methods) {
// attach to the JS Object prototype these methods that return
// false, and will be overridden by subclasses when they have to
// return true.
- StringBuffer objectProperties = new StringBuffer();
+ CodeBuffer objectProperties = new CodeBuffer();
emitIsChecks(objectProperties);
// In order to have the toString method on every native class,

Powered by Google App Engine
This is Rietveld 408576698