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

Side by Side Diff: lib/compiler/implementation/ssa/builder.dart

Issue 10265027: Move all the builtin$ interceptors to a new interceptors library and shorten the names of them. (Closed) Base URL: https://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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 26 matching lines...) Expand all
37 if (name === '>>=') return const SourceString('shr'); 37 if (name === '>>=') return const SourceString('shr');
38 if (name === '|=') return const SourceString('or'); 38 if (name === '|=') return const SourceString('or');
39 if (name === '&=') return const SourceString('and'); 39 if (name === '&=') return const SourceString('and');
40 if (name === '^=') return const SourceString('xor'); 40 if (name === '^=') return const SourceString('xor');
41 if (name === '++') return const SourceString('add'); 41 if (name === '++') return const SourceString('add');
42 if (name === '--') return const SourceString('sub'); 42 if (name === '--') return const SourceString('sub');
43 compiler.unimplemented('Unknown operator', node: op); 43 compiler.unimplemented('Unknown operator', node: op);
44 } 44 }
45 45
46 Element getStaticInterceptor(SourceString name, int parameters) { 46 Element getStaticInterceptor(SourceString name, int parameters) {
47 String mangledName = "builtin\$${name.slowToString()}\$${parameters}"; 47 String mangledName = "${name.slowToString()}";
floitsch 2012/05/01 14:37:44 String name = ... and no need to go through string
48 return compiler.findHelper(new SourceString(mangledName)); 48 Element element = compiler.findInterceptor(new SourceString(mangledName));
49 if (element !== null && element.isFunction()) {
50 // Only pick the function element with the short name if the
51 // number of parameters it expects matches the number we're
52 // passing modulo the receiver.
53 FunctionElement function = element;
54 if (function.parameterCount(compiler) == parameters + 1) return element;
55 }
56 String longMangledName = "$mangledName\$$parameters";
floitsch 2012/05/01 14:37:44 you can use mangledName here then.
57 return compiler.findInterceptor(new SourceString(longMangledName));
49 } 58 }
50 59
51 Element getStaticGetInterceptor(SourceString name) { 60 Element getStaticGetInterceptor(SourceString name) {
52 String mangledName = "builtin\$get\$${name.slowToString()}"; 61 String mangledName = "get\$${name.slowToString()}";
53 return compiler.findHelper(new SourceString(mangledName)); 62 return compiler.findInterceptor(new SourceString(mangledName));
54 } 63 }
55 64
56 Element getStaticSetInterceptor(SourceString name) { 65 Element getStaticSetInterceptor(SourceString name) {
57 String mangledName = "builtin\$set\$${name.slowToString()}"; 66 String mangledName = "set\$${name.slowToString()}";
58 return compiler.findHelper(new SourceString(mangledName)); 67 return compiler.findInterceptor(new SourceString(mangledName));
59 } 68 }
60 69
61 Element getOperatorInterceptor(Operator op) { 70 Element getOperatorInterceptor(Operator op) {
62 SourceString name = mapOperatorToMethodName(op); 71 SourceString name = mapOperatorToMethodName(op);
63 return compiler.findHelper(name); 72 return compiler.findHelper(name);
64 } 73 }
65 74
66 Element getBoolifiedVersionOf(Element interceptor) { 75 Element getBoolifiedVersionOf(Element interceptor) {
67 String boolifiedName = "${interceptor.name.slowToString()}B"; 76 String boolifiedName = "${interceptor.name.slowToString()}B";
68 return compiler.findHelper(new SourceString(boolifiedName)); 77 return compiler.findHelper(new SourceString(boolifiedName));
(...skipping 3043 matching lines...) Expand 10 before | Expand all | Expand 10 after
3112 <HInstruction>[target, input], 3121 <HInstruction>[target, input],
3113 HType.STRING)); 3122 HType.STRING));
3114 return builder.pop(); 3123 return builder.pop();
3115 } 3124 }
3116 3125
3117 HInstruction result() { 3126 HInstruction result() {
3118 flushLiterals(); 3127 flushLiterals();
3119 return prefix; 3128 return prefix;
3120 } 3129 }
3121 } 3130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698