Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); | 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'SSA code generator'; | 7 String get name() => 'SSA code generator'; |
| 8 | 8 |
| 9 String generate(WorkItem work, HGraph graph) { | 9 String generate(WorkItem work, HGraph graph) { |
| 10 return measure(() { | 10 return measure(() { |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 use(input, JSPrecedence.MEMBER_PRECEDENCE); | 922 use(input, JSPrecedence.MEMBER_PRECEDENCE); |
| 923 buffer.add('.constructor $cmp Array'); | 923 buffer.add('.constructor $cmp Array'); |
| 924 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 924 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 925 } | 925 } |
| 926 | 926 |
| 927 void visitIs(HIs node) { | 927 void visitIs(HIs node) { |
| 928 ClassElement element = node.typeExpression; | 928 ClassElement element = node.typeExpression; |
| 929 LibraryElement coreLibrary = compiler.coreLibrary; | 929 LibraryElement coreLibrary = compiler.coreLibrary; |
| 930 ClassElement objectClass = coreLibrary.find(const SourceString('Object')); | 930 ClassElement objectClass = coreLibrary.find(const SourceString('Object')); |
| 931 HInstruction input = node.expression; | 931 HInstruction input = node.expression; |
| 932 if (node.nullOk) { | |
| 933 use(input, JSPrecedence.EQUALITY_PRECEDENCE); | |
| 934 buffer.add(' === (void 0) ||'); | |
| 935 beginExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); | |
|
Lasse Reichstein Nielsen
2012/03/06 10:31:08
Sadly, that won't do what you want. It doesn't cha
ahe
2012/03/06 10:57:38
I think this is way too complicated, and I have no
| |
| 936 } | |
| 932 if (element == objectClass) { | 937 if (element == objectClass) { |
| 933 // TODO(ahe): This probably belongs in the constant folder. | 938 // TODO(ahe): This probably belongs in the constant folder. |
| 934 buffer.add('true'); | 939 buffer.add('true'); |
| 935 } else if (element == coreLibrary.find(const SourceString('String'))) { | 940 } else if (element == coreLibrary.find(const SourceString('String'))) { |
| 936 checkString(input, '==='); | 941 checkString(input, '==='); |
| 937 } else if (element == coreLibrary.find(const SourceString('double'))) { | 942 } else if (element == coreLibrary.find(const SourceString('double'))) { |
| 938 checkDouble(input, '==='); | 943 checkDouble(input, '==='); |
| 939 } else if (element == coreLibrary.find(const SourceString('num'))) { | 944 } else if (element == coreLibrary.find(const SourceString('num'))) { |
| 940 checkNum(input, '==='); | 945 checkNum(input, '==='); |
| 941 } else if (element == coreLibrary.find(const SourceString('bool'))) { | 946 } else if (element == coreLibrary.find(const SourceString('bool'))) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 buffer.add(compiler.emitter.nativeEmitter.dynamicIsCheckName); | 992 buffer.add(compiler.emitter.nativeEmitter.dynamicIsCheckName); |
| 988 buffer.add('('); | 993 buffer.add('('); |
| 989 use(input, JSPrecedence.MEMBER_PRECEDENCE); | 994 use(input, JSPrecedence.MEMBER_PRECEDENCE); |
| 990 buffer.add(", '${compiler.namer.operatorIs(node.typeExpression)}')"); | 995 buffer.add(", '${compiler.namer.operatorIs(node.typeExpression)}')"); |
| 991 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); | 996 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); |
| 992 } | 997 } |
| 993 endExpression(precedence); | 998 endExpression(precedence); |
| 994 if (endParen) buffer.add(')'); | 999 if (endParen) buffer.add(')'); |
| 995 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); | 1000 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); |
| 996 } | 1001 } |
| 1002 if (node.nullOk) { | |
| 1003 endExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); | |
| 1004 } | |
| 997 } | 1005 } |
| 998 | 1006 |
| 999 bool isStringSupertype(ClassElement cls) { | 1007 bool isStringSupertype(ClassElement cls) { |
| 1000 LibraryElement coreLibrary = compiler.coreLibrary; | 1008 LibraryElement coreLibrary = compiler.coreLibrary; |
| 1001 return (cls == coreLibrary.find(const SourceString('Comparable'))) | 1009 return (cls == coreLibrary.find(const SourceString('Comparable'))) |
| 1002 || (cls == coreLibrary.find(const SourceString('Hashable'))) | 1010 || (cls == coreLibrary.find(const SourceString('Hashable'))) |
| 1003 || (cls == coreLibrary.find(const SourceString('Pattern'))); | 1011 || (cls == coreLibrary.find(const SourceString('Pattern'))); |
| 1004 } | 1012 } |
| 1005 | 1013 |
| 1006 bool isListOrSupertype(ClassElement cls) { | 1014 bool isListOrSupertype(ClassElement cls) { |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1375 startBailoutSwitch(); | 1383 startBailoutSwitch(); |
| 1376 } | 1384 } |
| 1377 } | 1385 } |
| 1378 | 1386 |
| 1379 void endElse(HIf node) { | 1387 void endElse(HIf node) { |
| 1380 if (node.elseBlock.hasBailouts()) { | 1388 if (node.elseBlock.hasBailouts()) { |
| 1381 endBailoutSwitch(); | 1389 endBailoutSwitch(); |
| 1382 } | 1390 } |
| 1383 } | 1391 } |
| 1384 } | 1392 } |
| OLD | NEW |