| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 import 'package:kernel/frontend/accessors.dart' | 6 import 'package:kernel/frontend/accessors.dart' |
| 7 show | 7 show |
| 8 Accessor, | 8 Accessor, |
| 9 IndexAccessor, | 9 IndexAccessor, |
| 10 NullAwarePropertyAccessor, | 10 NullAwarePropertyAccessor, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 final Map<JumpTarget, ir.LabeledStatement> breakTargets = | 192 final Map<JumpTarget, ir.LabeledStatement> breakTargets = |
| 193 <JumpTarget, ir.LabeledStatement>{}; | 193 <JumpTarget, ir.LabeledStatement>{}; |
| 194 | 194 |
| 195 final Map<LocalElement, ir.VariableDeclaration> locals = | 195 final Map<LocalElement, ir.VariableDeclaration> locals = |
| 196 <LocalElement, ir.VariableDeclaration>{}; | 196 <LocalElement, ir.VariableDeclaration>{}; |
| 197 | 197 |
| 198 final Map<CascadeReceiver, ir.VariableGet> cascadeReceivers = | 198 final Map<CascadeReceiver, ir.VariableGet> cascadeReceivers = |
| 199 <CascadeReceiver, ir.VariableGet>{}; | 199 <CascadeReceiver, ir.VariableGet>{}; |
| 200 | 200 |
| 201 final Map<ir.Node, Element> nodeToElement = <ir.Node, Element>{}; |
| 202 |
| 203 ir.Node associate(ir.Node node, Element element) { |
| 204 nodeToElement[node] = element; |
| 205 return node; |
| 206 } |
| 207 |
| 201 bool isVoidContext = false; | 208 bool isVoidContext = false; |
| 202 | 209 |
| 203 KernelVisitor(this.currentElement, this.elements, this.kernel); | 210 KernelVisitor(this.currentElement, this.elements, this.kernel); |
| 204 | 211 |
| 205 KernelVisitor get sendVisitor => this; | 212 KernelVisitor get sendVisitor => this; |
| 206 | 213 |
| 207 KernelVisitor get declVisitor => this; | 214 KernelVisitor get declVisitor => this; |
| 208 | 215 |
| 209 ir.TreeNode visitForValue(Expression node) { | 216 ir.TreeNode visitForValue(Expression node) { |
| 210 bool wasVoidContext = isVoidContext; | 217 bool wasVoidContext = isVoidContext; |
| (...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 if (setterKind == CompoundSetter.INVALID) { | 1911 if (setterKind == CompoundSetter.INVALID) { |
| 1905 setter = null; | 1912 setter = null; |
| 1906 } | 1913 } |
| 1907 return buildStaticAccessor(getter, setter).buildNullAwareAssignment( | 1914 return buildStaticAccessor(getter, setter).buildNullAwareAssignment( |
| 1908 visitForValue(rhs), | 1915 visitForValue(rhs), |
| 1909 voidContext: isVoidContext); | 1916 voidContext: isVoidContext); |
| 1910 } | 1917 } |
| 1911 | 1918 |
| 1912 ir.VariableDeclaration getLocal(LocalElement local) { | 1919 ir.VariableDeclaration getLocal(LocalElement local) { |
| 1913 return locals.putIfAbsent(local, () { | 1920 return locals.putIfAbsent(local, () { |
| 1914 return new ir.VariableDeclaration(local.name, | 1921 return associate( |
| 1915 initializer: null, | 1922 new ir.VariableDeclaration(local.name, |
| 1916 type: typeToIrHack(local.type), | 1923 initializer: null, |
| 1917 isFinal: local.isFinal, | 1924 type: typeToIrHack(local.type), |
| 1918 isConst: local.isConst); | 1925 isFinal: local.isFinal, |
| 1926 isConst: local.isConst), |
| 1927 local); |
| 1919 }); | 1928 }); |
| 1920 } | 1929 } |
| 1921 | 1930 |
| 1922 ir.FunctionNode buildFunctionNode(FunctionElement function, Node bodyNode) { | 1931 ir.FunctionNode buildFunctionNode(FunctionElement function, Node bodyNode) { |
| 1923 List<ir.TypeParameter> typeParameters = | 1932 List<ir.TypeParameter> typeParameters = |
| 1924 kernel.typeParametersNotImplemented(); | 1933 kernel.typeParametersNotImplemented(); |
| 1925 List<ir.VariableDeclaration> positionalParameters = | 1934 List<ir.VariableDeclaration> positionalParameters = |
| 1926 <ir.VariableDeclaration>[]; | 1935 <ir.VariableDeclaration>[]; |
| 1927 List<ir.VariableDeclaration> namedParameters = <ir.VariableDeclaration>[]; | 1936 List<ir.VariableDeclaration> namedParameters = <ir.VariableDeclaration>[]; |
| 1928 int requiredParameterCount = 0; | 1937 int requiredParameterCount = 0; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 break; | 1987 break; |
| 1979 | 1988 |
| 1980 default: | 1989 default: |
| 1981 internalError( | 1990 internalError( |
| 1982 function, "Unknown async maker: ${function.asyncMarker}"); | 1991 function, "Unknown async maker: ${function.asyncMarker}"); |
| 1983 break; | 1992 break; |
| 1984 } | 1993 } |
| 1985 } | 1994 } |
| 1986 ir.Statement body = | 1995 ir.Statement body = |
| 1987 (bodyNode == null) ? null : buildStatementInBlock(bodyNode); | 1996 (bodyNode == null) ? null : buildStatementInBlock(bodyNode); |
| 1988 return new ir.FunctionNode(body, | 1997 return associate( |
| 1989 asyncMarker: asyncMarker, | 1998 new ir.FunctionNode(body, |
| 1990 returnType: returnType, | 1999 asyncMarker: asyncMarker, |
| 1991 typeParameters: typeParameters, | 2000 returnType: returnType, |
| 1992 positionalParameters: positionalParameters, | 2001 typeParameters: typeParameters, |
| 1993 namedParameters: namedParameters, | 2002 positionalParameters: positionalParameters, |
| 1994 requiredParameterCount: requiredParameterCount); | 2003 namedParameters: namedParameters, |
| 2004 requiredParameterCount: requiredParameterCount), |
| 2005 function); |
| 1995 } | 2006 } |
| 1996 | 2007 |
| 1997 @override | 2008 @override |
| 1998 IrFunction visitStaticFunctionDeclaration(FunctionExpression node, | 2009 IrFunction visitStaticFunctionDeclaration(FunctionExpression node, |
| 1999 MethodElement function, NodeList parameters, Node body, _) { | 2010 MethodElement function, NodeList parameters, Node body, _) { |
| 2000 return buildIrFunction(ir.ProcedureKind.Method, function, body); | 2011 return buildIrFunction(ir.ProcedureKind.Method, function, body); |
| 2001 } | 2012 } |
| 2002 | 2013 |
| 2003 ir.ProcedureKind computeInstanceMethodKind(MethodElement method) { | 2014 ir.ProcedureKind computeInstanceMethodKind(MethodElement method) { |
| 2004 assert(method.isFunction); | 2015 assert(method.isFunction); |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2694 : this(null, true, node, initializers); | 2705 : this(null, true, node, initializers); |
| 2695 | 2706 |
| 2696 accept(ir.Visitor v) => throw "unsupported"; | 2707 accept(ir.Visitor v) => throw "unsupported"; |
| 2697 | 2708 |
| 2698 visitChildren(ir.Visitor v) => throw "unsupported"; | 2709 visitChildren(ir.Visitor v) => throw "unsupported"; |
| 2699 | 2710 |
| 2700 String toString() { | 2711 String toString() { |
| 2701 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 2712 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
| 2702 } | 2713 } |
| 2703 } | 2714 } |
| OLD | NEW |