Chromium Code Reviews| Index: lib/compiler/implementation/ssa/codegen.dart |
| =================================================================== |
| --- lib/compiler/implementation/ssa/codegen.dart (revision 7269) |
| +++ lib/compiler/implementation/ssa/codegen.dart (working copy) |
| @@ -959,8 +959,10 @@ |
| visit(instruction, JSPrecedence.STATEMENT_PRECEDENCE); |
| return; |
| } else if (!isGenerateAtUseSite(instruction)) { |
| - if (instruction is !HIf && instruction is !HTypeGuard && |
| - instruction is !HLoopBranch && !isGeneratingExpression()) { |
| + if (instruction is !HIf |
| + && instruction is !HTypeGuard |
| + && instruction is !HLoopBranch |
| + && !isGeneratingExpression()) { |
| addIndentation(); |
| } |
| if (isGeneratingExpression()) { |
| @@ -975,8 +977,9 @@ |
| } |
| // Control flow instructions, and some other instructions, |
| // know how to handle ';'. |
| - if (instruction is !HControlFlow && instruction is !HTypeGuard && |
| - !isGeneratingExpression()) { |
| + if (instruction is !HControlFlow |
| + && instruction is !HTypeGuard |
| + && !isGeneratingExpression()) { |
| buffer.add(';\n'); |
| } |
| } else if (instruction is HIf) { |
| @@ -1750,7 +1753,11 @@ |
| } |
| void checkExtendableArray(HInstruction input) { |
| - compiler.unimplemented("check extendable array"); |
| + beginExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| + buffer.add('!!'); |
| + use(input, JSPrecedence.MEMBER_PRECEDENCE); |
| + buffer.add('.fixed\$length'); |
| + endExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| } |
| void checkNull(HInstruction input) { |
| @@ -1892,8 +1899,56 @@ |
| } |
| void visitTypeConversion(HTypeConversion node) { |
| - assert(isGenerateAtUseSite(node)); |
| - use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); |
| + if (node.checked) { |
|
floitsch
2012/05/07 11:06:56
not sure I like that all of this is in the codegen
ngeoffray
2012/05/07 13:15:42
As discussed, I will live it here, but we can revi
|
| + Element element = node.type.computeType(compiler).element; |
| + compiler.registerIsCheck(element); |
| + SourceString helper; |
| + String additionalArgument; |
| + bool nativeCheck = |
| + compiler.emitter.nativeEmitter.requiresNativeIsCheck(element); |
| + beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| + |
| + if (element == compiler.stringClass) { |
| + helper = const SourceString('stringTypeCheck'); |
| + } else if (element == compiler.doubleClass) { |
| + helper = const SourceString('doubleTypeCheck'); |
| + } else if (element == compiler.numClass) { |
| + helper = const SourceString('numTypeCheck'); |
| + } else if (element == compiler.boolClass) { |
| + helper = const SourceString('boolTypeCheck'); |
| + } else if (element == compiler.functionClass || element.isTypedef()) { |
| + helper = const SourceString('functionTypeCheck'); |
| + } else if (element == compiler.intClass) { |
| + helper = const SourceString('intTypeCheck'); |
| + } else if (Elements.isStringSupertype(element, compiler)) { |
| + helper = const SourceString('stringSuperTypeCheck'); |
| + } else if (element === compiler.listClass) { |
| + helper = const SourceString('listTypeCheck'); |
| + } else { |
| + additionalArgument = compiler.namer.operatorIs(element); |
| + if (Elements.isListSupertype(element, compiler)) { |
| + if (nativeCheck) { |
| + helper = const SourceString('listSuperNativeTypeCheck'); |
| + } else { |
| + helper = const SourceString('listSuperTypeCheck'); |
| + } |
| + } else if (nativeCheck) { |
| + helper = const SourceString('callTypeCheck'); |
| + } else { |
| + helper = const SourceString('propertyTypeCheck'); |
| + } |
| + } |
| + Element helperElement = compiler.findHelper(helper); |
| + compiler.registerStaticUse(helperElement); |
| + buffer.add(compiler.namer.isolateAccess(helperElement)); |
| + buffer.add('('); |
| + use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); |
| + if (additionalArgument !== null) buffer.add(", '$additionalArgument'"); |
| + buffer.add(')'); |
| + endExpression(JSPrecedence.CALL_PRECEDENCE); |
| + } else { |
| + use(node.inputs[0], expectedPrecedence); |
| + } |
| } |
| } |