| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import '../mock_compiler.dart'; | 6 import '../mock_compiler.dart'; |
| 7 import 'sexpr_unstringifier.dart'; | 7 import 'sexpr_unstringifier.dart'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 import 'package:compiler/src/cps_ir/cps_ir_nodes_sexpr.dart'; | 10 import 'package:compiler/src/cps_ir/cps_ir_nodes_sexpr.dart'; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 (InvokeContinuation k0 v0)) | 388 (InvokeContinuation k0 v0)) |
| 389 """; | 389 """; |
| 390 String CP10_OUT = CP10_IN; | 390 String CP10_OUT = CP10_IN; |
| 391 | 391 |
| 392 /// Normalizes whitespace by replacing all whitespace sequences by a single | 392 /// Normalizes whitespace by replacing all whitespace sequences by a single |
| 393 /// space and trimming leading and trailing whitespace. | 393 /// space and trimming leading and trailing whitespace. |
| 394 String normalizeSExpr(String input) { | 394 String normalizeSExpr(String input) { |
| 395 return input.replaceAll(new RegExp(r'[ \n\t]+'), ' ').trim(); | 395 return input.replaceAll(new RegExp(r'[ \n\t]+'), ' ').trim(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 class UnitTypeSystem implements TypeSystem<String> { | |
| 399 static const String UNIT = 'unit'; | |
| 400 | |
| 401 get boolType => UNIT; | |
| 402 get dynamicType => UNIT; | |
| 403 get functionType => UNIT; | |
| 404 get intType => UNIT; | |
| 405 get listType => UNIT; | |
| 406 get mapType => UNIT; | |
| 407 get stringType => UNIT; | |
| 408 get typeType => UNIT; | |
| 409 | |
| 410 bool areAssignable(a, b) => true; | |
| 411 getParameterType(_) => UNIT; | |
| 412 getReturnType(_) => UNIT; | |
| 413 join(a, b) => UNIT; | |
| 414 typeOf(_) => UNIT; | |
| 415 } | |
| 416 | |
| 417 /// Parses the given input IR, runs an optimization pass over it, and compares | 398 /// Parses the given input IR, runs an optimization pass over it, and compares |
| 418 /// the stringification of the result against the expected output. | 399 /// the stringification of the result against the expected output. |
| 419 Future testConstantPropagator(String input, String expectedOutput) { | 400 Future testConstantPropagator(String input, String expectedOutput) { |
| 420 final compiler = new MockCompiler.internal( | 401 final compiler = new MockCompiler.internal( |
| 421 emitJavaScript: false, | 402 emitJavaScript: false, |
| 422 enableMinification: false); | 403 enableMinification: false); |
| 423 return compiler.init().then((_) { | 404 return compiler.init().then((_) { |
| 424 final unstringifier = new SExpressionUnstringifier(); | 405 final unstringifier = new SExpressionUnstringifier(); |
| 425 final stringifier = new SExpressionStringifier(); | 406 final stringifier = new SExpressionStringifier(); |
| 426 final optimizer = new TypePropagator( | 407 final optimizer = new TypePropagator( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 444 asyncTest(() => testConstantPropagator(CP2_IN, CP2_OUT)); | 425 asyncTest(() => testConstantPropagator(CP2_IN, CP2_OUT)); |
| 445 asyncTest(() => testConstantPropagator(CP3_IN, CP3_OUT)); | 426 asyncTest(() => testConstantPropagator(CP3_IN, CP3_OUT)); |
| 446 asyncTest(() => testConstantPropagator(CP4_IN, CP4_OUT)); | 427 asyncTest(() => testConstantPropagator(CP4_IN, CP4_OUT)); |
| 447 asyncTest(() => testConstantPropagator(CP5_IN, CP5_OUT)); | 428 asyncTest(() => testConstantPropagator(CP5_IN, CP5_OUT)); |
| 448 asyncTest(() => testConstantPropagator(CP6_IN, CP6_OUT)); | 429 asyncTest(() => testConstantPropagator(CP6_IN, CP6_OUT)); |
| 449 asyncTest(() => testConstantPropagator(CP7_IN, CP7_OUT)); | 430 asyncTest(() => testConstantPropagator(CP7_IN, CP7_OUT)); |
| 450 asyncTest(() => testConstantPropagator(CP8_IN, CP8_OUT)); | 431 asyncTest(() => testConstantPropagator(CP8_IN, CP8_OUT)); |
| 451 asyncTest(() => testConstantPropagator(CP9_IN, CP9_OUT)); | 432 asyncTest(() => testConstantPropagator(CP9_IN, CP9_OUT)); |
| 452 asyncTest(() => testConstantPropagator(CP10_IN, CP10_OUT)); | 433 asyncTest(() => testConstantPropagator(CP10_IN, CP10_OUT)); |
| 453 } | 434 } |
| OLD | NEW |