| 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 '../compile_time_constants.dart' show | 7 import '../compile_time_constants.dart' show |
| 8 BackendConstantEnvironment; | 8 BackendConstantEnvironment; |
| 9 import '../constants/constant_system.dart'; | 9 import '../constants/constant_system.dart'; |
| 10 import '../constants/values.dart' show | 10 import '../constants/values.dart' show |
| (...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2361 SourceInformation sourceInformation) { | 2361 SourceInformation sourceInformation) { |
| 2362 ir.Primitive closure = | 2362 ir.Primitive closure = |
| 2363 buildFunctionExpression(classElement, sourceInformation); | 2363 buildFunctionExpression(classElement, sourceInformation); |
| 2364 declareLocalVariable(functionElement, initialValue: closure); | 2364 declareLocalVariable(functionElement, initialValue: closure); |
| 2365 } | 2365 } |
| 2366 | 2366 |
| 2367 ir.Primitive buildFunctionExpression(ClosureClassElement classElement, | 2367 ir.Primitive buildFunctionExpression(ClosureClassElement classElement, |
| 2368 SourceInformation sourceInformation) { | 2368 SourceInformation sourceInformation) { |
| 2369 List<ir.Primitive> arguments = <ir.Primitive>[]; | 2369 List<ir.Primitive> arguments = <ir.Primitive>[]; |
| 2370 for (ClosureFieldElement field in classElement.closureFields) { | 2370 for (ClosureFieldElement field in classElement.closureFields) { |
| 2371 // Captured 'this' is not available as a local in the current environment, | 2371 // Captured 'this' and type variables are not always available as locals |
| 2372 // so treat that specially. | 2372 // in the environment, so treat those specially. |
| 2373 ir.Primitive value = field.local is ThisLocal | 2373 ir.Primitive value; |
| 2374 ? buildThis() | 2374 if (field.local is ThisLocal) { |
| 2375 : environment.lookup(field.local); | 2375 value = buildThis(); |
| 2376 } else if (field.local is TypeVariableLocal) { |
| 2377 TypeVariableLocal variable = field.local; |
| 2378 value = buildTypeVariableAccess(variable.typeVariable); |
| 2379 } else { |
| 2380 value = environment.lookup(field.local); |
| 2381 } |
| 2376 arguments.add(value); | 2382 arguments.add(value); |
| 2377 } | 2383 } |
| 2378 return addPrimitive(new ir.CreateInstance( | 2384 return addPrimitive(new ir.CreateInstance( |
| 2379 classElement, arguments, const <ir.Primitive>[], sourceInformation)); | 2385 classElement, arguments, const <ir.Primitive>[], sourceInformation)); |
| 2380 } | 2386 } |
| 2381 | 2387 |
| 2382 /// Create a read access of [local] variable or parameter. | 2388 /// Create a read access of [local] variable or parameter. |
| 2383 ir.Primitive _buildLocalGet(LocalElement local) { | 2389 ir.Primitive _buildLocalGet(LocalElement local) { |
| 2384 assert(isOpen); | 2390 assert(isOpen); |
| 2385 ClosureLocation location = state.boxedVariables[local]; | 2391 ClosureLocation location = state.boxedVariables[local]; |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2795 } | 2801 } |
| 2796 | 2802 |
| 2797 class SwitchCaseInfo { | 2803 class SwitchCaseInfo { |
| 2798 final List<ir.Primitive> constants = <ir.Primitive>[]; | 2804 final List<ir.Primitive> constants = <ir.Primitive>[]; |
| 2799 final SubbuildFunction buildBody; | 2805 final SubbuildFunction buildBody; |
| 2800 | 2806 |
| 2801 SwitchCaseInfo(this.buildBody); | 2807 SwitchCaseInfo(this.buildBody); |
| 2802 | 2808 |
| 2803 void addConstant(ir.Primitive constant) => constants.add(constant); | 2809 void addConstant(ir.Primitive constant) => constants.add(constant); |
| 2804 } | 2810 } |
| OLD | NEW |