Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.ir_builder; | 5 library dart2js.ir_builder; |
| 6 | 6 |
| 7 import '../constants/expressions.dart'; | 7 import '../constants/expressions.dart'; |
| 8 import '../constants/values.dart' show PrimitiveConstantValue; | 8 import '../constants/values.dart' show PrimitiveConstantValue; |
| 9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../dart2jslib.dart'; | 10 import '../dart2jslib.dart'; |
| (...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1757 catchBuilder.removeMutableVariable(variable); | 1757 catchBuilder.removeMutableVariable(variable); |
| 1758 catchBuilder.environment.update(variable, value); | 1758 catchBuilder.environment.update(variable, value); |
| 1759 } | 1759 } |
| 1760 | 1760 |
| 1761 // TODO(kmillikin): Handle multiple catch clauses. | 1761 // TODO(kmillikin): Handle multiple catch clauses. |
| 1762 assert(catchClauseInfos.length == 1); | 1762 assert(catchClauseInfos.length == 1); |
| 1763 for (CatchClauseInfo catchClauseInfo in catchClauseInfos) { | 1763 for (CatchClauseInfo catchClauseInfo in catchClauseInfos) { |
| 1764 LocalVariableElement exceptionVariable = | 1764 LocalVariableElement exceptionVariable = |
| 1765 catchClauseInfo.exceptionVariable; | 1765 catchClauseInfo.exceptionVariable; |
| 1766 ir.Parameter exceptionParameter = new ir.Parameter(exceptionVariable); | 1766 ir.Parameter exceptionParameter = new ir.Parameter(exceptionVariable); |
| 1767 catchBuilder.environment.extend(exceptionVariable, exceptionParameter); | 1767 catchBuilder.declareLocalVariable(exceptionVariable, |
|
Kevin Millikin (Google)
2015/04/17 09:52:10
It is necessary to 'declare' these parameters in c
| |
| 1768 initialValue: exceptionParameter); | |
| 1768 ir.Parameter traceParameter; | 1769 ir.Parameter traceParameter; |
| 1769 LocalVariableElement stackTraceVariable = | 1770 LocalVariableElement stackTraceVariable = |
| 1770 catchClauseInfo.stackTraceVariable; | 1771 catchClauseInfo.stackTraceVariable; |
| 1771 if (stackTraceVariable != null) { | 1772 if (stackTraceVariable != null) { |
| 1772 traceParameter = new ir.Parameter(stackTraceVariable); | 1773 traceParameter = new ir.Parameter(stackTraceVariable); |
| 1773 catchBuilder.environment.extend(stackTraceVariable, traceParameter); | 1774 catchBuilder.declareLocalVariable(stackTraceVariable, |
| 1775 initialValue: traceParameter); | |
| 1774 } else { | 1776 } else { |
| 1775 // Use a dummy continuation parameter for the stack trace parameter. | 1777 // Use a dummy continuation parameter for the stack trace parameter. |
| 1776 // This will ensure that all handlers have two parameters and so they | 1778 // This will ensure that all handlers have two parameters and so they |
| 1777 // can be treated uniformly. | 1779 // can be treated uniformly. |
| 1778 traceParameter = new ir.Parameter(null); | 1780 traceParameter = new ir.Parameter(null); |
| 1779 } | 1781 } |
| 1780 catchClauseInfo.buildCatchBlock(catchBuilder); | 1782 catchClauseInfo.buildCatchBlock(catchBuilder); |
| 1781 if (catchBuilder.isOpen) catchBuilder.jumpTo(join); | 1783 if (catchBuilder.isOpen) catchBuilder.jumpTo(join); |
| 1782 List<ir.Parameter> catchParameters = | 1784 List<ir.Parameter> catchParameters = |
| 1783 <ir.Parameter>[exceptionParameter, traceParameter]; | 1785 <ir.Parameter>[exceptionParameter, traceParameter]; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1874 assert(isOpen); | 1876 assert(isOpen); |
| 1875 for (JumpCollector collector in collectors) { | 1877 for (JumpCollector collector in collectors) { |
| 1876 if (target == collector.target) { | 1878 if (target == collector.target) { |
| 1877 jumpTo(collector); | 1879 jumpTo(collector); |
| 1878 return true; | 1880 return true; |
| 1879 } | 1881 } |
| 1880 } | 1882 } |
| 1881 return false; | 1883 return false; |
| 1882 } | 1884 } |
| 1883 | 1885 |
| 1886 void buildThrow(ir.Primitive value) { | |
| 1887 assert(isOpen); | |
| 1888 add(new ir.Throw(value)); | |
| 1889 _current = null; | |
| 1890 } | |
| 1891 | |
| 1892 ir.Primitive buildNonTailThrow(ir.Primitive value) { | |
| 1893 assert(isOpen); | |
| 1894 return addPrimitive(new ir.NonTailThrow(value)); | |
| 1895 } | |
| 1896 | |
| 1897 void buildRethrow() { | |
| 1898 assert(isOpen); | |
| 1899 add(new ir.Rethrow()); | |
|
asgerf
2015/04/17 10:33:01
I would imagine this needs a reference to the exce
Kevin Millikin (Google)
2015/04/17 11:17:07
It will be translated by the unsugar pass to 'thro
| |
| 1900 _current = null; | |
| 1901 } | |
| 1902 | |
| 1884 /// Create a negation of [condition]. | 1903 /// Create a negation of [condition]. |
| 1885 ir.Primitive buildNegation(ir.Primitive condition) { | 1904 ir.Primitive buildNegation(ir.Primitive condition) { |
| 1886 // ! e is translated as e ? false : true | 1905 // ! e is translated as e ? false : true |
| 1887 | 1906 |
| 1888 // Add a continuation parameter for the result of the expression. | 1907 // Add a continuation parameter for the result of the expression. |
| 1889 ir.Parameter resultParameter = new ir.Parameter(null); | 1908 ir.Parameter resultParameter = new ir.Parameter(null); |
| 1890 | 1909 |
| 1891 ir.Continuation joinContinuation = new ir.Continuation([resultParameter]); | 1910 ir.Continuation joinContinuation = new ir.Continuation([resultParameter]); |
| 1892 ir.Continuation thenContinuation = new ir.Continuation([]); | 1911 ir.Continuation thenContinuation = new ir.Continuation([]); |
| 1893 ir.Continuation elseContinuation = new ir.Continuation([]); | 1912 ir.Continuation elseContinuation = new ir.Continuation([]); |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2640 } | 2659 } |
| 2641 | 2660 |
| 2642 /// Synthetic parameter to a JavaScript factory method that takes the type | 2661 /// Synthetic parameter to a JavaScript factory method that takes the type |
| 2643 /// argument given for the type variable [variable]. | 2662 /// argument given for the type variable [variable]. |
| 2644 class TypeInformationParameter implements Local { | 2663 class TypeInformationParameter implements Local { |
| 2645 final TypeVariableElement variable; | 2664 final TypeVariableElement variable; |
| 2646 final ExecutableElement executableContext; | 2665 final ExecutableElement executableContext; |
| 2647 TypeInformationParameter(this.variable, this.executableContext); | 2666 TypeInformationParameter(this.variable, this.executableContext); |
| 2648 String get name => variable.name; | 2667 String get name => variable.name; |
| 2649 } | 2668 } |
| OLD | NEW |