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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 final List<JumpCollector> breakCollectors = <JumpCollector>[]; | 212 final List<JumpCollector> breakCollectors = <JumpCollector>[]; |
| 213 | 213 |
| 214 /// A stack of collectors for continues. | 214 /// A stack of collectors for continues. |
| 215 final List<JumpCollector> continueCollectors = <JumpCollector>[]; | 215 final List<JumpCollector> continueCollectors = <JumpCollector>[]; |
| 216 | 216 |
| 217 final List<ConstDeclaration> localConstants = <ConstDeclaration>[]; | 217 final List<ConstDeclaration> localConstants = <ConstDeclaration>[]; |
| 218 | 218 |
| 219 final ExecutableElement currentElement; | 219 final ExecutableElement currentElement; |
| 220 | 220 |
| 221 final ir.Continuation returnContinuation = new ir.Continuation.retrn(); | 221 final ir.Continuation returnContinuation = new ir.Continuation.retrn(); |
| 222 ir.Parameter _thisParameter; | |
| 222 | 223 |
| 223 final List<ir.Definition> functionParameters = <ir.Definition>[]; | 224 final List<ir.Definition> functionParameters = <ir.Definition>[]; |
| 224 | 225 |
| 225 IrBuilderDelimitedState(this.constantSystem, this.currentElement); | 226 IrBuilderDelimitedState(this.constantSystem, this.currentElement); |
| 227 | |
| 228 ir.Parameter get thisParameter => _thisParameter; | |
| 229 void set thisParameter(ir.Parameter value) { | |
| 230 assert(_thisParameter == null); | |
| 231 _thisParameter = value; | |
| 232 } | |
| 233 } | |
| 234 | |
| 235 class ThisLocal implements Local { | |
| 236 final ExecutableElement executableContext; | |
| 237 ThisLocal(this.executableContext); | |
| 238 String get name => 'this'; | |
| 239 toString() => 'ThisLocal($executableContext)'; | |
| 226 } | 240 } |
|
asgerf
2015/03/18 13:28:25
There is already a ThisLocal in closure.dart. Can
sra1
2015/03/19 10:42:51
I kept this one (but renamed).
The other one has g
| |
| 227 | 241 |
| 228 /// A factory for building the cps IR. | 242 /// A factory for building the cps IR. |
| 229 /// | 243 /// |
| 230 /// [DartIrBuilder] and [JsIrBuilder] implement nested functions and captured | 244 /// [DartIrBuilder] and [JsIrBuilder] implement nested functions and captured |
| 231 /// variables in different ways. | 245 /// variables in different ways. |
| 232 abstract class IrBuilder { | 246 abstract class IrBuilder { |
| 233 IrBuilder _makeInstance(); | 247 IrBuilder _makeInstance(); |
| 234 | 248 |
| 235 // TODO(johnniwinther): Remove this from the [IrBuilder]. | 249 // TODO(johnniwinther): Remove this from the [IrBuilder]. |
| 236 /// A map from TryStatements in the AST to their analysis information. | 250 /// A map from TryStatements in the AST to their analysis information. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 void _enterForLoopBody(ClosureScope scope, | 303 void _enterForLoopBody(ClosureScope scope, |
| 290 List<LocalElement> loopVariables); | 304 List<LocalElement> loopVariables); |
| 291 | 305 |
| 292 /// Called before building the update of a for-loop. | 306 /// Called before building the update of a for-loop. |
| 293 void _enterForLoopUpdate(ClosureScope scope, | 307 void _enterForLoopUpdate(ClosureScope scope, |
| 294 List<LocalElement> loopVariables); | 308 List<LocalElement> loopVariables); |
| 295 | 309 |
| 296 /// Add the given function parameter to the IR, and bind it in the environment | 310 /// Add the given function parameter to the IR, and bind it in the environment |
| 297 /// or put it in its box, if necessary. | 311 /// or put it in its box, if necessary. |
| 298 void _createFunctionParameter(ParameterElement parameterElement); | 312 void _createFunctionParameter(ParameterElement parameterElement); |
| 313 void _createThisParameter(); | |
| 299 | 314 |
| 300 /// Creates an access to the receiver from the current (or enclosing) method. | 315 /// Creates an access to the receiver from the current (or enclosing) method. |
| 301 /// | 316 /// |
| 302 /// If inside a closure class, [buildThis] will redirect access through | 317 /// If inside a closure class, [buildThis] will redirect access through |
| 303 /// closure fields in order to access the receiver from the enclosing method. | 318 /// closure fields in order to access the receiver from the enclosing method. |
| 304 ir.Primitive buildThis(); | 319 ir.Primitive buildThis(); |
| 305 | 320 |
| 306 // TODO(johnniwinther): Make these field final and remove the default values | 321 // TODO(johnniwinther): Make these field final and remove the default values |
| 307 // when [IrBuilder] is a property of [IrBuilderVisitor] instead of a mixin. | 322 // when [IrBuilder] is a property of [IrBuilderVisitor] instead of a mixin. |
| 308 | 323 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 | 412 |
| 398 void buildFieldInitializerHeader({ClosureScope closureScope}) { | 413 void buildFieldInitializerHeader({ClosureScope closureScope}) { |
| 399 _enterScope(closureScope); | 414 _enterScope(closureScope); |
| 400 } | 415 } |
| 401 | 416 |
| 402 List<ir.Primitive> buildFunctionHeader(Iterable<ParameterElement> parameters, | 417 List<ir.Primitive> buildFunctionHeader(Iterable<ParameterElement> parameters, |
| 403 {ClosureScope closureScope, | 418 {ClosureScope closureScope, |
| 404 ClosureEnvironment env}) { | 419 ClosureEnvironment env}) { |
| 405 _enterClosureEnvironment(env); | 420 _enterClosureEnvironment(env); |
| 406 _enterScope(closureScope); | 421 _enterScope(closureScope); |
| 422 _createThisParameter(); | |
| 407 parameters.forEach(_createFunctionParameter); | 423 parameters.forEach(_createFunctionParameter); |
| 408 return _parameters; | 424 return _parameters; |
| 409 } | 425 } |
| 410 | 426 |
| 411 /// Creates a parameter for [local] and adds it to the current environment. | 427 /// Creates a parameter for [local] and adds it to the current environment. |
| 412 ir.Parameter createLocalParameter(Local local) { | 428 ir.Parameter createLocalParameter(Local local) { |
| 413 ir.Parameter parameter = new ir.Parameter(local); | 429 ir.Parameter parameter = new ir.Parameter(local); |
| 414 _parameters.add(parameter); | 430 _parameters.add(parameter); |
| 415 environment.extend(local, parameter); | 431 environment.extend(local, parameter); |
| 416 return parameter; | 432 return parameter; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 ir.FunctionDefinition makeFunctionDefinition( | 667 ir.FunctionDefinition makeFunctionDefinition( |
| 652 List<ConstantExpression> defaults) { | 668 List<ConstantExpression> defaults) { |
| 653 FunctionElement element = state.currentElement; | 669 FunctionElement element = state.currentElement; |
| 654 if (element.isAbstract || element.isExternal) { | 670 if (element.isAbstract || element.isExternal) { |
| 655 assert(invariant(element, _root == null, | 671 assert(invariant(element, _root == null, |
| 656 message: "Non-empty body for abstract method $element: $_root")); | 672 message: "Non-empty body for abstract method $element: $_root")); |
| 657 assert(invariant(element, state.localConstants.isEmpty, | 673 assert(invariant(element, state.localConstants.isEmpty, |
| 658 message: "Local constants for abstract method $element: " | 674 message: "Local constants for abstract method $element: " |
| 659 "${state.localConstants}")); | 675 "${state.localConstants}")); |
| 660 return new ir.FunctionDefinition.abstract( | 676 return new ir.FunctionDefinition.abstract( |
| 661 element, state.functionParameters, defaults); | 677 element, state.thisParameter, state.functionParameters, defaults); |
| 662 } else { | 678 } else { |
| 663 ir.RunnableBody body = makeRunnableBody(); | 679 ir.RunnableBody body = makeRunnableBody(); |
| 664 return new ir.FunctionDefinition( | 680 return new ir.FunctionDefinition( |
| 665 element, state.functionParameters, body, | 681 element, state.thisParameter, state.functionParameters, body, |
| 666 state.localConstants, defaults); | 682 state.localConstants, defaults); |
| 667 } | 683 } |
| 668 } | 684 } |
| 669 | 685 |
| 670 /// Create a constructor definition without a body, for representing | 686 /// Create a constructor definition without a body, for representing |
| 671 /// external constructors declarations. | 687 /// external constructors declarations. |
| 672 ir.ConstructorDefinition makeAbstractConstructorDefinition( | 688 ir.ConstructorDefinition makeAbstractConstructorDefinition( |
| 673 List<ConstantExpression> defaults) { | 689 List<ConstantExpression> defaults) { |
| 674 FunctionElement element = state.currentElement; | 690 FunctionElement element = state.currentElement; |
| 675 assert(invariant(element, _root == null, | 691 assert(invariant(element, _root == null, |
| 676 message: "Non-empty body for external constructor $element: $_root")); | 692 message: "Non-empty body for external constructor $element: $_root")); |
| 677 assert(invariant(element, state.localConstants.isEmpty, | 693 assert(invariant(element, state.localConstants.isEmpty, |
| 678 message: "Local constants for external constructor $element: " | 694 message: "Local constants for external constructor $element: " |
| 679 "${state.localConstants}")); | 695 "${state.localConstants}")); |
| 680 return new ir.ConstructorDefinition.abstract( | 696 return new ir.ConstructorDefinition.abstract( |
| 681 element, state.functionParameters, defaults); | 697 element, state.functionParameters, defaults); |
| 682 } | 698 } |
| 683 | 699 |
| 684 ir.ConstructorDefinition makeConstructorDefinition( | 700 ir.ConstructorDefinition makeConstructorDefinition( |
| 685 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { | 701 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { |
| 686 FunctionElement element = state.currentElement; | 702 FunctionElement element = state.currentElement; |
| 687 ir.RunnableBody body = makeRunnableBody(); | 703 ir.RunnableBody body = makeRunnableBody(); |
| 688 return new ir.ConstructorDefinition( | 704 return new ir.ConstructorDefinition( |
| 689 element, state.functionParameters, body, initializers, | 705 element, state.thisParameter, state.functionParameters, body, initialize rs, |
| 690 state.localConstants, defaults); | 706 state.localConstants, defaults); |
| 691 } | 707 } |
| 692 | 708 |
| 693 /// Create a super invocation where the method name and the argument structure | 709 /// Create a super invocation where the method name and the argument structure |
| 694 /// are defined by [selector] and the argument values are defined by | 710 /// are defined by [selector] and the argument values are defined by |
| 695 /// [arguments]. | 711 /// [arguments]. |
| 696 ir.Primitive buildSuperInvocation(Element target, | 712 ir.Primitive buildSuperInvocation(Element target, |
| 697 Selector selector, | 713 Selector selector, |
| 698 List<ir.Primitive> arguments); | 714 List<ir.Primitive> arguments); |
| 699 | 715 |
| (...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2030 ir.Parameter parameter = new ir.Parameter(parameterElement); | 2046 ir.Parameter parameter = new ir.Parameter(parameterElement); |
| 2031 _parameters.add(parameter); | 2047 _parameters.add(parameter); |
| 2032 if (isInMutableVariable(parameterElement)) { | 2048 if (isInMutableVariable(parameterElement)) { |
| 2033 state.functionParameters.add(getMutableVariable(parameterElement)); | 2049 state.functionParameters.add(getMutableVariable(parameterElement)); |
| 2034 } else { | 2050 } else { |
| 2035 state.functionParameters.add(parameter); | 2051 state.functionParameters.add(parameter); |
| 2036 environment.extend(parameterElement, parameter); | 2052 environment.extend(parameterElement, parameter); |
| 2037 } | 2053 } |
| 2038 } | 2054 } |
| 2039 | 2055 |
| 2056 void _createThisParameter() { | |
| 2057 if (state.currentElement.isGenerativeConstructor || | |
| 2058 !Elements.isStaticOrTopLevel(state.currentElement)) { | |
|
asgerf
2015/03/18 13:28:25
I think this will also create a this parameter for
sra1
2015/03/19 10:42:51
Done.
| |
| 2059 state.thisParameter = | |
| 2060 new ir.Parameter(new ThisLocal(state.currentElement)); | |
| 2061 } | |
| 2062 } | |
| 2063 | |
| 2040 void declareLocalVariable(LocalVariableElement variableElement, | 2064 void declareLocalVariable(LocalVariableElement variableElement, |
| 2041 {ir.Primitive initialValue}) { | 2065 {ir.Primitive initialValue}) { |
| 2042 assert(isOpen); | 2066 assert(isOpen); |
| 2043 if (initialValue == null) { | 2067 if (initialValue == null) { |
| 2044 initialValue = buildNullLiteral(); | 2068 initialValue = buildNullLiteral(); |
| 2045 } | 2069 } |
| 2046 if (isInMutableVariable(variableElement)) { | 2070 if (isInMutableVariable(variableElement)) { |
| 2047 add(new ir.LetMutable(getMutableVariable(variableElement), | 2071 add(new ir.LetMutable(getMutableVariable(variableElement), |
| 2048 initialValue)); | 2072 initialValue)); |
| 2049 } else { | 2073 } else { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2095 if (isInMutableVariable(local)) { | 2119 if (isInMutableVariable(local)) { |
| 2096 add(new ir.SetMutableVariable(getMutableVariable(local), value)); | 2120 add(new ir.SetMutableVariable(getMutableVariable(local), value)); |
| 2097 } else { | 2121 } else { |
| 2098 value.useElementAsHint(local); | 2122 value.useElementAsHint(local); |
| 2099 environment.update(local, value); | 2123 environment.update(local, value); |
| 2100 } | 2124 } |
| 2101 return value; | 2125 return value; |
| 2102 } | 2126 } |
| 2103 | 2127 |
| 2104 ir.Primitive buildThis() { | 2128 ir.Primitive buildThis() { |
| 2105 ir.Primitive thisPrim = new ir.This(); | 2129 return state.thisParameter; |
| 2106 add(new ir.LetPrim(thisPrim)); | |
| 2107 return thisPrim; | |
| 2108 } | 2130 } |
| 2109 | 2131 |
| 2110 ir.Primitive buildSuperInvocation(Element target, | 2132 ir.Primitive buildSuperInvocation(Element target, |
| 2111 Selector selector, | 2133 Selector selector, |
| 2112 List<ir.Primitive> arguments) { | 2134 List<ir.Primitive> arguments) { |
| 2113 return _buildInvokeSuper(target, selector, arguments); | 2135 return _buildInvokeSuper(target, selector, arguments); |
| 2114 } | 2136 } |
| 2115 | 2137 |
| 2116 } | 2138 } |
| 2117 | 2139 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2145 Map<ast.TryStatement, TryStatementInfo> get tryStatements => null; | 2167 Map<ast.TryStatement, TryStatementInfo> get tryStatements => null; |
| 2146 Set<Local> get mutableCapturedVariables => null; | 2168 Set<Local> get mutableCapturedVariables => null; |
| 2147 bool isInMutableVariable(Local local) => false; | 2169 bool isInMutableVariable(Local local) => false; |
| 2148 void makeMutableVariable(Local local) {} | 2170 void makeMutableVariable(Local local) {} |
| 2149 void removeMutableVariable(Local local) {} | 2171 void removeMutableVariable(Local local) {} |
| 2150 | 2172 |
| 2151 void _enterClosureEnvironment(ClosureEnvironment env) { | 2173 void _enterClosureEnvironment(ClosureEnvironment env) { |
| 2152 if (env == null) return; | 2174 if (env == null) return; |
| 2153 | 2175 |
| 2154 // Obtain a reference to the function object (this). | 2176 // Obtain a reference to the function object (this). |
| 2155 ir.Primitive thisPrim = new ir.This(); | 2177 ir.Parameter thisPrim = state.thisParameter; |
| 2156 add(new ir.LetPrim(thisPrim)); | |
| 2157 | 2178 |
| 2158 // Obtain access to the free variables. | 2179 // Obtain access to the free variables. |
| 2159 env.freeVariables.forEach((Local local, ClosureLocation location) { | 2180 env.freeVariables.forEach((Local local, ClosureLocation location) { |
| 2160 if (location.isBox) { | 2181 if (location.isBox) { |
| 2161 // Boxed variables are loaded from their box on-demand. | 2182 // Boxed variables are loaded from their box on-demand. |
| 2162 jsState.boxedVariables[local] = location; | 2183 jsState.boxedVariables[local] = location; |
| 2163 } else { | 2184 } else { |
| 2164 // Unboxed variables are loaded from the function object immediately. | 2185 // Unboxed variables are loaded from the function object immediately. |
| 2165 // This includes BoxLocals which are themselves unboxed variables. | 2186 // This includes BoxLocals which are themselves unboxed variables. |
| 2166 ir.Primitive load = new ir.GetField(thisPrim, location.field); | 2187 ir.Primitive load = new ir.GetField(thisPrim, location.field); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2209 ClosureLocation location = jsState.boxedVariables[parameterElement]; | 2230 ClosureLocation location = jsState.boxedVariables[parameterElement]; |
| 2210 if (location != null) { | 2231 if (location != null) { |
| 2211 add(new ir.SetField(environment.lookup(location.box), | 2232 add(new ir.SetField(environment.lookup(location.box), |
| 2212 location.field, | 2233 location.field, |
| 2213 parameter)); | 2234 parameter)); |
| 2214 } else { | 2235 } else { |
| 2215 environment.extend(parameterElement, parameter); | 2236 environment.extend(parameterElement, parameter); |
| 2216 } | 2237 } |
| 2217 } | 2238 } |
| 2218 | 2239 |
| 2240 void _createThisParameter() { | |
| 2241 if (!Elements.isStaticOrTopLevel(state.currentElement)) { | |
| 2242 state.thisParameter = | |
| 2243 new ir.Parameter(new ThisLocal(state.currentElement)); | |
| 2244 } | |
| 2245 } | |
| 2246 | |
| 2219 void declareLocalVariable(LocalElement variableElement, | 2247 void declareLocalVariable(LocalElement variableElement, |
| 2220 {ir.Primitive initialValue}) { | 2248 {ir.Primitive initialValue}) { |
| 2221 assert(isOpen); | 2249 assert(isOpen); |
| 2222 if (initialValue == null) { | 2250 if (initialValue == null) { |
| 2223 initialValue = buildNullLiteral(); | 2251 initialValue = buildNullLiteral(); |
| 2224 } | 2252 } |
| 2225 ClosureLocation location = jsState.boxedVariables[variableElement]; | 2253 ClosureLocation location = jsState.boxedVariables[variableElement]; |
| 2226 if (location != null) { | 2254 if (location != null) { |
| 2227 add(new ir.SetField(environment.lookup(location.box), | 2255 add(new ir.SetField(environment.lookup(location.box), |
| 2228 location.field, | 2256 location.field, |
| 2229 initialValue)); | 2257 initialValue)); |
| 2230 } else { | 2258 } else { |
| 2231 initialValue.useElementAsHint(variableElement); | 2259 initialValue.useElementAsHint(variableElement); |
| 2232 environment.extend(variableElement, initialValue); | 2260 environment.extend(variableElement, initialValue); |
| 2233 } | 2261 } |
| 2234 } | 2262 } |
| 2235 | 2263 |
| 2236 /// Add [functionElement] to the environment with provided [definition]. | 2264 /// Add [functionElement] to the environment with provided [definition]. |
| 2237 void declareLocalFunction(LocalFunctionElement functionElement, | 2265 void declareLocalFunction(LocalFunctionElement functionElement, |
| 2238 ClosureClassElement classElement) { | 2266 ClosureClassElement classElement) { |
| 2239 ir.Primitive closure = buildFunctionExpression(classElement); | 2267 ir.Primitive closure = buildFunctionExpression(classElement); |
| 2240 declareLocalVariable(functionElement, initialValue: closure); | 2268 declareLocalVariable(functionElement, initialValue: closure); |
| 2241 } | 2269 } |
| 2242 | 2270 |
| 2243 ir.Primitive buildFunctionExpression(ClosureClassElement classElement) { | 2271 ir.Primitive buildFunctionExpression(ClosureClassElement classElement) { |
| 2244 List<ir.Primitive> arguments = <ir.Primitive>[]; | 2272 List<ir.Primitive> arguments = <ir.Primitive>[]; |
| 2245 for (ClosureFieldElement field in classElement.closureFields) { | 2273 for (ClosureFieldElement field in classElement.closureFields) { |
| 2246 // Captured 'this' is not available as a local in the current environment, | 2274 // Captured 'this' is not available as a local in the current environment, |
| 2247 // so treat that specially. | 2275 // so treat that specially. |
| 2248 ir.Primitive value = field.local is ThisLocal | 2276 ir.Primitive value = field.local is ThisLocal |
|
asgerf
2015/03/18 13:28:25
I suspect this doesn't work anymore because of the
sra1
2015/03/19 10:42:51
Good catch. I just debugged that :-)
| |
| 2249 ? buildThis() | 2277 ? buildThis() |
| 2250 : environment.lookup(field.local); | 2278 : environment.lookup(field.local); |
| 2251 arguments.add(value); | 2279 arguments.add(value); |
| 2252 } | 2280 } |
| 2253 ir.Primitive closure = new ir.CreateInstance(classElement, arguments); | 2281 ir.Primitive closure = new ir.CreateInstance(classElement, arguments); |
| 2254 add(new ir.LetPrim(closure)); | 2282 add(new ir.LetPrim(closure)); |
| 2255 return closure; | 2283 return closure; |
| 2256 } | 2284 } |
| 2257 | 2285 |
| 2258 /// Create a read access of [local]. | 2286 /// Create a read access of [local]. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2317 ClosureLocation location = scope.capturedVariables[loopVar]; | 2345 ClosureLocation location = scope.capturedVariables[loopVar]; |
| 2318 ir.Primitive get = new ir.GetField(box, location.field); | 2346 ir.Primitive get = new ir.GetField(box, location.field); |
| 2319 add(new ir.LetPrim(get)); | 2347 add(new ir.LetPrim(get)); |
| 2320 add(new ir.SetField(newBox, location.field, get)); | 2348 add(new ir.SetField(newBox, location.field, get)); |
| 2321 } | 2349 } |
| 2322 environment.update(scope.box, newBox); | 2350 environment.update(scope.box, newBox); |
| 2323 } | 2351 } |
| 2324 | 2352 |
| 2325 ir.Primitive buildThis() { | 2353 ir.Primitive buildThis() { |
| 2326 if (jsState.receiver != null) return jsState.receiver; | 2354 if (jsState.receiver != null) return jsState.receiver; |
| 2327 ir.Primitive thisPrim = new ir.This(); | 2355 return state.thisParameter; |
| 2328 add(new ir.LetPrim(thisPrim)); | |
| 2329 return thisPrim; | |
| 2330 } | 2356 } |
| 2331 | 2357 |
| 2332 ir.Primitive buildSuperInvocation(Element target, | 2358 ir.Primitive buildSuperInvocation(Element target, |
| 2333 Selector selector, | 2359 Selector selector, |
| 2334 List<ir.Primitive> arguments) { | 2360 List<ir.Primitive> arguments) { |
| 2335 // Direct calls to FieldElements are currently problematic because the | 2361 // Direct calls to FieldElements are currently problematic because the |
| 2336 // backend will not issue a getter for the field unless it finds a dynamic | 2362 // backend will not issue a getter for the field unless it finds a dynamic |
| 2337 // access that matches its getter. | 2363 // access that matches its getter. |
| 2338 // As a workaround, we generate GetField for this case, although ideally | 2364 // As a workaround, we generate GetField for this case, although ideally |
| 2339 // this should be the result of inlining the field's getter. | 2365 // this should be the result of inlining the field's getter. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2363 receiver, target, selector, k, arguments)); | 2389 receiver, target, selector, k, arguments)); |
| 2364 } | 2390 } |
| 2365 | 2391 |
| 2366 /// Loads parameters to a constructor body into the environment. | 2392 /// Loads parameters to a constructor body into the environment. |
| 2367 /// | 2393 /// |
| 2368 /// The header for a constructor body differs from other functions in that | 2394 /// The header for a constructor body differs from other functions in that |
| 2369 /// some parameters are already boxed, and the box is passed as an argument | 2395 /// some parameters are already boxed, and the box is passed as an argument |
| 2370 /// instead of being created in the header. | 2396 /// instead of being created in the header. |
| 2371 void buildConstructorBodyHeader(Iterable<Local> parameters, | 2397 void buildConstructorBodyHeader(Iterable<Local> parameters, |
| 2372 ClosureScope closureScope) { | 2398 ClosureScope closureScope) { |
| 2399 _createThisParameter(); | |
| 2373 for (Local param in parameters) { | 2400 for (Local param in parameters) { |
| 2374 ir.Parameter parameter = createLocalParameter(param); | 2401 ir.Parameter parameter = createLocalParameter(param); |
| 2375 state.functionParameters.add(parameter); | 2402 state.functionParameters.add(parameter); |
| 2376 } | 2403 } |
| 2377 if (closureScope != null) { | 2404 if (closureScope != null) { |
| 2378 jsState.boxedVariables.addAll(closureScope.capturedVariables); | 2405 jsState.boxedVariables.addAll(closureScope.capturedVariables); |
| 2379 } | 2406 } |
| 2380 } | 2407 } |
| 2381 } | 2408 } |
| 2382 | 2409 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2442 // TODO(johnniwinther): Support passing of [DartType] for the exception. | 2469 // TODO(johnniwinther): Support passing of [DartType] for the exception. |
| 2443 class CatchClauseInfo { | 2470 class CatchClauseInfo { |
| 2444 final LocalVariableElement exceptionVariable; | 2471 final LocalVariableElement exceptionVariable; |
| 2445 final LocalVariableElement stackTraceVariable; | 2472 final LocalVariableElement stackTraceVariable; |
| 2446 final SubbuildFunction buildCatchBlock; | 2473 final SubbuildFunction buildCatchBlock; |
| 2447 | 2474 |
| 2448 CatchClauseInfo({this.exceptionVariable, | 2475 CatchClauseInfo({this.exceptionVariable, |
| 2449 this.stackTraceVariable, | 2476 this.stackTraceVariable, |
| 2450 this.buildCatchBlock}); | 2477 this.buildCatchBlock}); |
| 2451 } | 2478 } |
| OLD | NEW |