Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 1018403002: Revert "Use an explicit 'this' parameter instead of 'This' nodes." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
223 ir.Parameter enclosingMethodThisParameter;
224 222
225 final List<ir.Definition> functionParameters = <ir.Definition>[]; 223 final List<ir.Definition> functionParameters = <ir.Definition>[];
226 224
227 IrBuilderDelimitedState(this.constantSystem, this.currentElement); 225 IrBuilderDelimitedState(this.constantSystem, this.currentElement);
228
229 ir.Parameter get thisParameter => _thisParameter;
230 void set thisParameter(ir.Parameter value) {
231 assert(_thisParameter == null);
232 _thisParameter = value;
233 }
234 }
235
236 class ThisParameterLocal implements Local {
237 final ExecutableElement executableContext;
238 ThisParameterLocal(this.executableContext);
239 String get name => 'this';
240 toString() => 'ThisParameterLocal($executableContext)';
241 } 226 }
242 227
243 /// A factory for building the cps IR. 228 /// A factory for building the cps IR.
244 /// 229 ///
245 /// [DartIrBuilder] and [JsIrBuilder] implement nested functions and captured 230 /// [DartIrBuilder] and [JsIrBuilder] implement nested functions and captured
246 /// variables in different ways. 231 /// variables in different ways.
247 abstract class IrBuilder { 232 abstract class IrBuilder {
248 IrBuilder _makeInstance(); 233 IrBuilder _makeInstance();
249 234
250 // TODO(johnniwinther): Remove this from the [IrBuilder]. 235 // TODO(johnniwinther): Remove this from the [IrBuilder].
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 void _enterForLoopBody(ClosureScope scope, 289 void _enterForLoopBody(ClosureScope scope,
305 List<LocalElement> loopVariables); 290 List<LocalElement> loopVariables);
306 291
307 /// Called before building the update of a for-loop. 292 /// Called before building the update of a for-loop.
308 void _enterForLoopUpdate(ClosureScope scope, 293 void _enterForLoopUpdate(ClosureScope scope,
309 List<LocalElement> loopVariables); 294 List<LocalElement> loopVariables);
310 295
311 /// Add the given function parameter to the IR, and bind it in the environment 296 /// Add the given function parameter to the IR, and bind it in the environment
312 /// or put it in its box, if necessary. 297 /// or put it in its box, if necessary.
313 void _createFunctionParameter(ParameterElement parameterElement); 298 void _createFunctionParameter(ParameterElement parameterElement);
314 void _createThisParameter();
315 299
316 /// Creates an access to the receiver from the current (or enclosing) method. 300 /// Creates an access to the receiver from the current (or enclosing) method.
317 /// 301 ///
318 /// If inside a closure class, [buildThis] will redirect access through 302 /// If inside a closure class, [buildThis] will redirect access through
319 /// closure fields in order to access the receiver from the enclosing method. 303 /// closure fields in order to access the receiver from the enclosing method.
320 ir.Primitive buildThis(); 304 ir.Primitive buildThis();
321 305
322 // TODO(johnniwinther): Make these field final and remove the default values 306 // TODO(johnniwinther): Make these field final and remove the default values
323 // when [IrBuilder] is a property of [IrBuilderVisitor] instead of a mixin. 307 // when [IrBuilder] is a property of [IrBuilderVisitor] instead of a mixin.
324 308
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 IrBuilder makeRecursiveBuilder() { 380 IrBuilder makeRecursiveBuilder() {
397 IrBuilder inner = _makeInstance() 381 IrBuilder inner = _makeInstance()
398 ..state = state 382 ..state = state
399 ..environment = new Environment.empty(); 383 ..environment = new Environment.empty();
400 environment.index2variable.forEach(inner.createLocalParameter); 384 environment.index2variable.forEach(inner.createLocalParameter);
401 return inner; 385 return inner;
402 } 386 }
403 387
404 /// Construct a builder for an inner function. 388 /// Construct a builder for an inner function.
405 IrBuilder makeInnerFunctionBuilder(ExecutableElement currentElement) { 389 IrBuilder makeInnerFunctionBuilder(ExecutableElement currentElement) {
406 IrBuilderDelimitedState innerState =
407 new IrBuilderDelimitedState(state.constantSystem, currentElement)
408 ..enclosingMethodThisParameter = state.enclosingMethodThisParameter;
409 return _makeInstance() 390 return _makeInstance()
410 ..state = innerState 391 ..state = new IrBuilderDelimitedState(state.constantSystem, currentEleme nt)
411 ..environment = new Environment.empty(); 392 ..environment = new Environment.empty();
412 } 393 }
413 394
414 bool get isOpen => _root == null || _current != null; 395 bool get isOpen => _root == null || _current != null;
415 396
416 397
417 void buildFieldInitializerHeader({ClosureScope closureScope}) { 398 void buildFieldInitializerHeader({ClosureScope closureScope}) {
418 _enterScope(closureScope); 399 _enterScope(closureScope);
419 } 400 }
420 401
421 List<ir.Primitive> buildFunctionHeader(Iterable<ParameterElement> parameters, 402 List<ir.Primitive> buildFunctionHeader(Iterable<ParameterElement> parameters,
422 {ClosureScope closureScope, 403 {ClosureScope closureScope,
423 ClosureEnvironment env}) { 404 ClosureEnvironment env}) {
424 _createThisParameter();
425 _enterClosureEnvironment(env); 405 _enterClosureEnvironment(env);
426 _enterScope(closureScope); 406 _enterScope(closureScope);
427 parameters.forEach(_createFunctionParameter); 407 parameters.forEach(_createFunctionParameter);
428 return _parameters; 408 return _parameters;
429 } 409 }
430 410
431 /// Creates a parameter for [local] and adds it to the current environment. 411 /// Creates a parameter for [local] and adds it to the current environment.
432 ir.Parameter createLocalParameter(Local local) { 412 ir.Parameter createLocalParameter(Local local) {
433 ir.Parameter parameter = new ir.Parameter(local); 413 ir.Parameter parameter = new ir.Parameter(local);
434 _parameters.add(parameter); 414 _parameters.add(parameter);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 ir.FunctionDefinition makeFunctionDefinition( 651 ir.FunctionDefinition makeFunctionDefinition(
672 List<ConstantExpression> defaults) { 652 List<ConstantExpression> defaults) {
673 FunctionElement element = state.currentElement; 653 FunctionElement element = state.currentElement;
674 if (element.isAbstract || element.isExternal) { 654 if (element.isAbstract || element.isExternal) {
675 assert(invariant(element, _root == null, 655 assert(invariant(element, _root == null,
676 message: "Non-empty body for abstract method $element: $_root")); 656 message: "Non-empty body for abstract method $element: $_root"));
677 assert(invariant(element, state.localConstants.isEmpty, 657 assert(invariant(element, state.localConstants.isEmpty,
678 message: "Local constants for abstract method $element: " 658 message: "Local constants for abstract method $element: "
679 "${state.localConstants}")); 659 "${state.localConstants}"));
680 return new ir.FunctionDefinition.abstract( 660 return new ir.FunctionDefinition.abstract(
681 element, state.thisParameter, state.functionParameters, defaults); 661 element, state.functionParameters, defaults);
682 } else { 662 } else {
683 ir.RunnableBody body = makeRunnableBody(); 663 ir.RunnableBody body = makeRunnableBody();
684 return new ir.FunctionDefinition( 664 return new ir.FunctionDefinition(
685 element, state.thisParameter, state.functionParameters, body, 665 element, state.functionParameters, body,
686 state.localConstants, defaults); 666 state.localConstants, defaults);
687 } 667 }
688 } 668 }
689 669
690 /// Create a constructor definition without a body, for representing 670 /// Create a constructor definition without a body, for representing
691 /// external constructors declarations. 671 /// external constructors declarations.
692 ir.ConstructorDefinition makeAbstractConstructorDefinition( 672 ir.ConstructorDefinition makeAbstractConstructorDefinition(
693 List<ConstantExpression> defaults) { 673 List<ConstantExpression> defaults) {
694 FunctionElement element = state.currentElement; 674 FunctionElement element = state.currentElement;
695 assert(invariant(element, _root == null, 675 assert(invariant(element, _root == null,
696 message: "Non-empty body for external constructor $element: $_root")); 676 message: "Non-empty body for external constructor $element: $_root"));
697 assert(invariant(element, state.localConstants.isEmpty, 677 assert(invariant(element, state.localConstants.isEmpty,
698 message: "Local constants for external constructor $element: " 678 message: "Local constants for external constructor $element: "
699 "${state.localConstants}")); 679 "${state.localConstants}"));
700 return new ir.ConstructorDefinition.abstract( 680 return new ir.ConstructorDefinition.abstract(
701 element, state.functionParameters, defaults); 681 element, state.functionParameters, defaults);
702 } 682 }
703 683
704 ir.ConstructorDefinition makeConstructorDefinition( 684 ir.ConstructorDefinition makeConstructorDefinition(
705 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { 685 List<ConstantExpression> defaults, List<ir.Initializer> initializers) {
706 FunctionElement element = state.currentElement; 686 FunctionElement element = state.currentElement;
707 ir.RunnableBody body = makeRunnableBody(); 687 ir.RunnableBody body = makeRunnableBody();
708 return new ir.ConstructorDefinition( 688 return new ir.ConstructorDefinition(
709 element, state.thisParameter, state.functionParameters, body, initialize rs, 689 element, state.functionParameters, body, initializers,
710 state.localConstants, defaults); 690 state.localConstants, defaults);
711 } 691 }
712 692
713 /// Create a super invocation where the method name and the argument structure 693 /// Create a super invocation where the method name and the argument structure
714 /// are defined by [selector] and the argument values are defined by 694 /// are defined by [selector] and the argument values are defined by
715 /// [arguments]. 695 /// [arguments].
716 ir.Primitive buildSuperInvocation(Element target, 696 ir.Primitive buildSuperInvocation(Element target,
717 Selector selector, 697 Selector selector,
718 List<ir.Primitive> arguments); 698 List<ir.Primitive> arguments);
719 699
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 bodyBuilder._enterScope(closureScope); 1140 bodyBuilder._enterScope(closureScope);
1161 if (buildVariableDeclaration != null) { 1141 if (buildVariableDeclaration != null) {
1162 buildVariableDeclaration(bodyBuilder); 1142 buildVariableDeclaration(bodyBuilder);
1163 } 1143 }
1164 1144
1165 ir.Parameter currentValue = new ir.Parameter(null); 1145 ir.Parameter currentValue = new ir.Parameter(null);
1166 ir.Continuation currentInvoked = new ir.Continuation([currentValue]); 1146 ir.Continuation currentInvoked = new ir.Continuation([currentValue]);
1167 bodyBuilder.add(new ir.LetCont(currentInvoked, 1147 bodyBuilder.add(new ir.LetCont(currentInvoked,
1168 new ir.InvokeMethod(iterator, new Selector.getter("current", null), 1148 new ir.InvokeMethod(iterator, new Selector.getter("current", null),
1169 currentInvoked, emptyArguments))); 1149 currentInvoked, emptyArguments)));
1170 // TODO(sra): Does this cover all cases? The general setter case include
1171 // super.
1172 if (Elements.isLocal(variableElement)) { 1150 if (Elements.isLocal(variableElement)) {
1173 bodyBuilder.buildLocalSet(variableElement, currentValue); 1151 bodyBuilder.buildLocalSet(variableElement, currentValue);
1174 } else if (Elements.isStaticOrTopLevel(variableElement) || 1152 } else if (Elements.isStaticOrTopLevel(variableElement)) {
1175 Elements.isErroneous(variableElement)) {
1176 bodyBuilder.buildStaticSet( 1153 bodyBuilder.buildStaticSet(
1177 variableElement, variableSelector, currentValue); 1154 variableElement, variableSelector, currentValue);
1178 } else { 1155 } else {
1179 ir.Primitive receiver = bodyBuilder.buildThis(); 1156 ir.Primitive receiver = bodyBuilder.buildThis();
1180 assert(receiver != null);
1181 bodyBuilder.buildDynamicSet(receiver, variableSelector, currentValue); 1157 bodyBuilder.buildDynamicSet(receiver, variableSelector, currentValue);
1182 } 1158 }
1183 1159
1184 buildBody(bodyBuilder); 1160 buildBody(bodyBuilder);
1185 assert(state.breakCollectors.last == breakCollector); 1161 assert(state.breakCollectors.last == breakCollector);
1186 assert(state.continueCollectors.last == continueCollector); 1162 assert(state.continueCollectors.last == continueCollector);
1187 state.breakCollectors.removeLast(); 1163 state.breakCollectors.removeLast();
1188 state.continueCollectors.removeLast(); 1164 state.continueCollectors.removeLast();
1189 1165
1190 // Create body entry and loop exit continuations and a branch to them. 1166 // Create body entry and loop exit continuations and a branch to them.
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 ir.Parameter parameter = new ir.Parameter(parameterElement); 2030 ir.Parameter parameter = new ir.Parameter(parameterElement);
2055 _parameters.add(parameter); 2031 _parameters.add(parameter);
2056 if (isInMutableVariable(parameterElement)) { 2032 if (isInMutableVariable(parameterElement)) {
2057 state.functionParameters.add(getMutableVariable(parameterElement)); 2033 state.functionParameters.add(getMutableVariable(parameterElement));
2058 } else { 2034 } else {
2059 state.functionParameters.add(parameter); 2035 state.functionParameters.add(parameter);
2060 environment.extend(parameterElement, parameter); 2036 environment.extend(parameterElement, parameter);
2061 } 2037 }
2062 } 2038 }
2063 2039
2064 void _createThisParameter() {
2065 if (state.currentElement.isGenerativeConstructor ||
2066 !(Elements.isStaticOrTopLevel(state.currentElement) ||
2067 state.currentElement.isLocal)) {
2068 ir.Parameter thisParameter =
2069 new ir.Parameter(new ThisParameterLocal(state.currentElement));
2070 state.thisParameter = thisParameter;
2071 state.enclosingMethodThisParameter = thisParameter;
2072 }
2073 }
2074
2075 void declareLocalVariable(LocalVariableElement variableElement, 2040 void declareLocalVariable(LocalVariableElement variableElement,
2076 {ir.Primitive initialValue}) { 2041 {ir.Primitive initialValue}) {
2077 assert(isOpen); 2042 assert(isOpen);
2078 if (initialValue == null) { 2043 if (initialValue == null) {
2079 initialValue = buildNullLiteral(); 2044 initialValue = buildNullLiteral();
2080 } 2045 }
2081 if (isInMutableVariable(variableElement)) { 2046 if (isInMutableVariable(variableElement)) {
2082 add(new ir.LetMutable(getMutableVariable(variableElement), 2047 add(new ir.LetMutable(getMutableVariable(variableElement),
2083 initialValue)); 2048 initialValue));
2084 } else { 2049 } else {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 assert(isOpen); 2088 assert(isOpen);
2124 if (isInMutableVariable(local)) { 2089 if (isInMutableVariable(local)) {
2125 add(new ir.SetMutableVariable(getMutableVariable(local), value)); 2090 add(new ir.SetMutableVariable(getMutableVariable(local), value));
2126 } else { 2091 } else {
2127 value.useElementAsHint(local); 2092 value.useElementAsHint(local);
2128 environment.update(local, value); 2093 environment.update(local, value);
2129 } 2094 }
2130 return value; 2095 return value;
2131 } 2096 }
2132 2097
2133 ir.Primitive buildThis() { 2098 ir.Primitive buildThis() => addPrimitive(new ir.This());
2134 return state.enclosingMethodThisParameter;
2135 }
2136 2099
2137 ir.Primitive buildSuperInvocation(Element target, 2100 ir.Primitive buildSuperInvocation(Element target,
2138 Selector selector, 2101 Selector selector,
2139 List<ir.Primitive> arguments) { 2102 List<ir.Primitive> arguments) {
2140 return _buildInvokeSuper(target, selector, arguments); 2103 return _buildInvokeSuper(target, selector, arguments);
2141 } 2104 }
2142 2105
2143 } 2106 }
2144 2107
2145 /// State shared between JsIrBuilders within the same function. 2108 /// State shared between JsIrBuilders within the same function.
(...skipping 26 matching lines...) Expand all
2172 Map<ast.TryStatement, TryStatementInfo> get tryStatements => null; 2135 Map<ast.TryStatement, TryStatementInfo> get tryStatements => null;
2173 Set<Local> get mutableCapturedVariables => null; 2136 Set<Local> get mutableCapturedVariables => null;
2174 bool isInMutableVariable(Local local) => false; 2137 bool isInMutableVariable(Local local) => false;
2175 void makeMutableVariable(Local local) {} 2138 void makeMutableVariable(Local local) {}
2176 void removeMutableVariable(Local local) {} 2139 void removeMutableVariable(Local local) {}
2177 2140
2178 void _enterClosureEnvironment(ClosureEnvironment env) { 2141 void _enterClosureEnvironment(ClosureEnvironment env) {
2179 if (env == null) return; 2142 if (env == null) return;
2180 2143
2181 // Obtain a reference to the function object (this). 2144 // Obtain a reference to the function object (this).
2182 ir.Parameter thisPrim = state.thisParameter; 2145 ir.Primitive thisPrim = addPrimitive(new ir.This());
2183 2146
2184 // Obtain access to the free variables. 2147 // Obtain access to the free variables.
2185 env.freeVariables.forEach((Local local, ClosureLocation location) { 2148 env.freeVariables.forEach((Local local, ClosureLocation location) {
2186 if (location.isBox) { 2149 if (location.isBox) {
2187 // Boxed variables are loaded from their box on-demand. 2150 // Boxed variables are loaded from their box on-demand.
2188 jsState.boxedVariables[local] = location; 2151 jsState.boxedVariables[local] = location;
2189 } else { 2152 } else {
2190 // Unboxed variables are loaded from the function object immediately. 2153 // Unboxed variables are loaded from the function object immediately.
2191 // This includes BoxLocals which are themselves unboxed variables. 2154 // This includes BoxLocals which are themselves unboxed variables.
2192 environment.extend(local, 2155 environment.extend(local,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 ClosureLocation location = jsState.boxedVariables[parameterElement]; 2196 ClosureLocation location = jsState.boxedVariables[parameterElement];
2234 if (location != null) { 2197 if (location != null) {
2235 add(new ir.SetField(environment.lookup(location.box), 2198 add(new ir.SetField(environment.lookup(location.box),
2236 location.field, 2199 location.field,
2237 parameter)); 2200 parameter));
2238 } else { 2201 } else {
2239 environment.extend(parameterElement, parameter); 2202 environment.extend(parameterElement, parameter);
2240 } 2203 }
2241 } 2204 }
2242 2205
2243 void _createThisParameter() {
2244 if (Elements.isStaticOrTopLevel(state.currentElement)) return;
2245 if (state.currentElement.isLocal) return;
2246 state.thisParameter =
2247 new ir.Parameter(new ThisParameterLocal(state.currentElement));
2248 }
2249
2250 void declareLocalVariable(LocalElement variableElement, 2206 void declareLocalVariable(LocalElement variableElement,
2251 {ir.Primitive initialValue}) { 2207 {ir.Primitive initialValue}) {
2252 assert(isOpen); 2208 assert(isOpen);
2253 if (initialValue == null) { 2209 if (initialValue == null) {
2254 initialValue = buildNullLiteral(); 2210 initialValue = buildNullLiteral();
2255 } 2211 }
2256 ClosureLocation location = jsState.boxedVariables[variableElement]; 2212 ClosureLocation location = jsState.boxedVariables[variableElement];
2257 if (location != null) { 2213 if (location != null) {
2258 add(new ir.SetField(environment.lookup(location.box), 2214 add(new ir.SetField(environment.lookup(location.box),
2259 location.field, 2215 location.field,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 for (VariableElement loopVar in scope.boxedLoopVariables) { 2299 for (VariableElement loopVar in scope.boxedLoopVariables) {
2344 ClosureLocation location = scope.capturedVariables[loopVar]; 2300 ClosureLocation location = scope.capturedVariables[loopVar];
2345 ir.Primitive value = addPrimitive(new ir.GetField(box, location.field)); 2301 ir.Primitive value = addPrimitive(new ir.GetField(box, location.field));
2346 add(new ir.SetField(newBox, location.field, value)); 2302 add(new ir.SetField(newBox, location.field, value));
2347 } 2303 }
2348 environment.update(scope.box, newBox); 2304 environment.update(scope.box, newBox);
2349 } 2305 }
2350 2306
2351 ir.Primitive buildThis() { 2307 ir.Primitive buildThis() {
2352 if (jsState.receiver != null) return jsState.receiver; 2308 if (jsState.receiver != null) return jsState.receiver;
2353 return state.thisParameter; 2309 return addPrimitive(new ir.This());
2354 } 2310 }
2355 2311
2356 ir.Primitive buildSuperInvocation(Element target, 2312 ir.Primitive buildSuperInvocation(Element target,
2357 Selector selector, 2313 Selector selector,
2358 List<ir.Primitive> arguments) { 2314 List<ir.Primitive> arguments) {
2359 // Direct calls to FieldElements are currently problematic because the 2315 // Direct calls to FieldElements are currently problematic because the
2360 // backend will not issue a getter for the field unless it finds a dynamic 2316 // backend will not issue a getter for the field unless it finds a dynamic
2361 // access that matches its getter. 2317 // access that matches its getter.
2362 // As a workaround, we generate GetField for this case, although ideally 2318 // As a workaround, we generate GetField for this case, although ideally
2363 // this should be the result of inlining the field's getter. 2319 // this should be the result of inlining the field's getter.
(...skipping 21 matching lines...) Expand all
2385 receiver, target, selector, k, arguments)); 2341 receiver, target, selector, k, arguments));
2386 } 2342 }
2387 2343
2388 /// Loads parameters to a constructor body into the environment. 2344 /// Loads parameters to a constructor body into the environment.
2389 /// 2345 ///
2390 /// The header for a constructor body differs from other functions in that 2346 /// The header for a constructor body differs from other functions in that
2391 /// some parameters are already boxed, and the box is passed as an argument 2347 /// some parameters are already boxed, and the box is passed as an argument
2392 /// instead of being created in the header. 2348 /// instead of being created in the header.
2393 void buildConstructorBodyHeader(Iterable<Local> parameters, 2349 void buildConstructorBodyHeader(Iterable<Local> parameters,
2394 ClosureScope closureScope) { 2350 ClosureScope closureScope) {
2395 _createThisParameter();
2396 for (Local param in parameters) { 2351 for (Local param in parameters) {
2397 ir.Parameter parameter = createLocalParameter(param); 2352 ir.Parameter parameter = createLocalParameter(param);
2398 state.functionParameters.add(parameter); 2353 state.functionParameters.add(parameter);
2399 } 2354 }
2400 if (closureScope != null) { 2355 if (closureScope != null) {
2401 jsState.boxedVariables.addAll(closureScope.capturedVariables); 2356 jsState.boxedVariables.addAll(closureScope.capturedVariables);
2402 } 2357 }
2403 } 2358 }
2404 } 2359 }
2405 2360
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 // TODO(johnniwinther): Support passing of [DartType] for the exception. 2420 // TODO(johnniwinther): Support passing of [DartType] for the exception.
2466 class CatchClauseInfo { 2421 class CatchClauseInfo {
2467 final LocalVariableElement exceptionVariable; 2422 final LocalVariableElement exceptionVariable;
2468 final LocalVariableElement stackTraceVariable; 2423 final LocalVariableElement stackTraceVariable;
2469 final SubbuildFunction buildCatchBlock; 2424 final SubbuildFunction buildCatchBlock;
2470 2425
2471 CatchClauseInfo({this.exceptionVariable, 2426 CatchClauseInfo({this.exceptionVariable,
2472 this.stackTraceVariable, 2427 this.stackTraceVariable,
2473 this.buildCatchBlock}); 2428 this.buildCatchBlock});
2474 } 2429 }
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/test/sexpr_data.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698