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

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

Issue 10540048: Implement 'as' operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make "as" a builtin identifier. Created 8 years, 6 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 SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 final JavaScriptBackend backend; 6 final JavaScriptBackend backend;
7 SsaCodeGeneratorTask(JavaScriptBackend backend) 7 SsaCodeGeneratorTask(JavaScriptBackend backend)
8 : this.backend = backend, 8 : this.backend = backend,
9 super(backend.compiler); 9 super(backend.compiler);
10 String get name() => 'SSA code generator'; 10 String get name() => 'SSA code generator';
(...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 buffer.add(".${name.slowToString()} === '${arguments.head}'"); 2228 buffer.add(".${name.slowToString()} === '${arguments.head}'");
2229 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); 2229 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE);
2230 }); 2230 });
2231 } 2231 }
2232 if (node.nullOk) { 2232 if (node.nullOk) {
2233 endExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); 2233 endExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE);
2234 } 2234 }
2235 } 2235 }
2236 2236
2237 void visitTypeConversion(HTypeConversion node) { 2237 void visitTypeConversion(HTypeConversion node) {
2238 Map<String, SourceString> castNames = const <SourceString> {
2239 "stringTypeCheck":
2240 const SourceString("stringTypeCast"),
2241 "doubleTypeCheck":
2242 const SourceString("doubleTypeCast"),
2243 "numTypeCheck":
2244 const SourceString("numTypeCast"),
2245 "boolTypeCheck":
2246 const SourceString("boolTypeCast"),
2247 "functionTypeCheck":
2248 const SourceString("functionTypeCast"),
2249 "intTypeCheck":
2250 const SourceString("intTypeCast"),
2251 "stringSuperNativeTypeCheck":
2252 const SourceString("stringSuperNativeTypeCast"),
2253 "stringSuperTypeCheck":
2254 const SourceString("stringSuperTypeCast"),
2255 "listTypeCheck":
2256 const SourceString("listTypeCast"),
2257 "listSuperNativeTypeCheck":
2258 const SourceString("listSuperNativeTypeCast"),
2259 "listSuperTypeCheck":
2260 const SourceString("listSuperTypeCast"),
2261 "callTypeCheck":
2262 const SourceString("callTypeCast"),
2263 "propertyTypeCheck":
2264 const SourceString("propertyTypeCast")
2265 };
2238 if (node.checked) { 2266 if (node.checked) {
2239 Element element = node.type.computeType(compiler).element; 2267 Element element = node.type.computeType(compiler).element;
2240 world.registerIsCheck(element); 2268 world.registerIsCheck(element);
2241 SourceString helper; 2269 SourceString helper;
2242 String additionalArgument; 2270 String additionalArgument;
2243 bool nativeCheck = 2271 bool nativeCheck =
2244 backend.emitter.nativeEmitter.requiresNativeIsCheck(element); 2272 backend.emitter.nativeEmitter.requiresNativeIsCheck(element);
2245 beginExpression(JSPrecedence.CALL_PRECEDENCE); 2273 beginExpression(JSPrecedence.CALL_PRECEDENCE);
2246 2274
2247 if (element == compiler.stringClass) { 2275 if (element == compiler.stringClass) {
(...skipping 23 matching lines...) Expand all
2271 helper = const SourceString('listSuperNativeTypeCheck'); 2299 helper = const SourceString('listSuperNativeTypeCheck');
2272 } else { 2300 } else {
2273 helper = const SourceString('listSuperTypeCheck'); 2301 helper = const SourceString('listSuperTypeCheck');
2274 } 2302 }
2275 } else if (nativeCheck) { 2303 } else if (nativeCheck) {
2276 helper = const SourceString('callTypeCheck'); 2304 helper = const SourceString('callTypeCheck');
2277 } else { 2305 } else {
2278 helper = const SourceString('propertyTypeCheck'); 2306 helper = const SourceString('propertyTypeCheck');
2279 } 2307 }
2280 } 2308 }
2309 if (node.isCast) {
2310 helper = castNames[helper.stringValue];
2311 }
2281 Element helperElement = compiler.findHelper(helper); 2312 Element helperElement = compiler.findHelper(helper);
2282 world.registerStaticUse(helperElement); 2313 world.registerStaticUse(helperElement);
2283 buffer.add(compiler.namer.isolateAccess(helperElement)); 2314 buffer.add(compiler.namer.isolateAccess(helperElement));
2284 buffer.add('('); 2315 buffer.add('(');
2285 use(node.checkedInput, JSPrecedence.EXPRESSION_PRECEDENCE); 2316 use(node.checkedInput, JSPrecedence.EXPRESSION_PRECEDENCE);
2286 if (additionalArgument !== null) buffer.add(", '$additionalArgument'"); 2317 if (additionalArgument !== null) buffer.add(", '$additionalArgument'");
2287 buffer.add(')'); 2318 buffer.add(')');
2288 endExpression(JSPrecedence.CALL_PRECEDENCE); 2319 endExpression(JSPrecedence.CALL_PRECEDENCE);
2289 } else { 2320 } else {
2290 use(node.checkedInput, expectedPrecedence); 2321 use(node.checkedInput, expectedPrecedence);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 startBailoutSwitch(); 2710 startBailoutSwitch();
2680 } 2711 }
2681 } 2712 }
2682 2713
2683 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2714 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2684 if (labeledBlockInfo.body.start.hasGuards()) { 2715 if (labeledBlockInfo.body.start.hasGuards()) {
2685 endBailoutSwitch(); 2716 endBailoutSwitch();
2686 } 2717 }
2687 } 2718 }
2688 } 2719 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698