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

Unified 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: No entries in language.status, vm and dartc already implemented 'as'. 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/ssa/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index c4e41ad8737e9a3bd53c236a92bdbae164f91aab..47cd58efd11b69f814aacd6bfd9066b20e8723e9 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -2494,7 +2494,36 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
}
void visitTypeConversion(HTypeConversion node) {
- if (node.isChecked()) {
+ Map<String, SourceString> castNames = const <SourceString> {
+ "stringTypeCheck":
+ const SourceString("stringTypeCast"),
+ "doubleTypeCheck":
+ const SourceString("doubleTypeCast"),
+ "numTypeCheck":
+ const SourceString("numTypeCast"),
+ "boolTypeCheck":
+ const SourceString("boolTypeCast"),
+ "functionTypeCheck":
+ const SourceString("functionTypeCast"),
+ "intTypeCheck":
+ const SourceString("intTypeCast"),
+ "stringSuperNativeTypeCheck":
+ const SourceString("stringSuperNativeTypeCast"),
+ "stringSuperTypeCheck":
+ const SourceString("stringSuperTypeCast"),
+ "listTypeCheck":
+ const SourceString("listTypeCast"),
+ "listSuperNativeTypeCheck":
+ const SourceString("listSuperNativeTypeCast"),
+ "listSuperTypeCheck":
+ const SourceString("listSuperTypeCast"),
+ "callTypeCheck":
+ const SourceString("callTypeCast"),
+ "propertyTypeCheck":
+ const SourceString("propertyTypeCast")
+ };
+
+ if (node.isChecked) {
Element element = node.type.computeType(compiler).element;
world.registerIsCheck(element);
SourceString helper;
@@ -2503,7 +2532,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
backend.emitter.nativeEmitter.requiresNativeIsCheck(element);
beginExpression(JSPrecedence.CALL_PRECEDENCE);
- if (node.isArgumentTypeCheck()) {
+ if (node.isArgumentTypeCheck) {
buffer.add('if (');
if (element == compiler.intClass) {
checkInt(node.checkedInput, '!==');
@@ -2516,7 +2545,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
return;
}
- assert(node.isCheckedModeCheck());
+ assert(node.isCheckedModeCheck);
if (element == compiler.stringClass) {
helper = const SourceString('stringTypeCheck');
} else if (element == compiler.doubleClass) {
@@ -2552,6 +2581,9 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
helper = const SourceString('propertyTypeCheck');
}
}
+ if (node.isCastTypeCheck) {
+ helper = castNames[helper.stringValue];
+ }
Element helperElement = compiler.findHelper(helper);
world.registerStaticUse(helperElement);
buffer.add(compiler.namer.isolateAccess(helperElement));

Powered by Google App Engine
This is Rietveld 408576698