Chromium Code Reviews| Index: lib/compiler/implementation/ssa/ssa.dart |
| diff --git a/lib/compiler/implementation/ssa/ssa.dart b/lib/compiler/implementation/ssa/ssa.dart |
| index 7eaec79d40738eed6174894cb48c30da875f33e7..00c3abd7c334c177716123eab32f2c7b21e41c26 100644 |
| --- a/lib/compiler/implementation/ssa/ssa.dart |
| +++ b/lib/compiler/implementation/ssa/ssa.dart |
| @@ -39,4 +39,58 @@ class RuntimeTypeInformation { |
| } |
| return false; |
| } |
| + |
| + static void foreach(Link collection, |
|
kasperl
2012/09/14 12:35:37
forEach?
karlklose
2012/09/17 14:50:37
Changed the name.
|
| + int numberOfInputs, |
| + f(bool isFirst, bool hasValue, |
| + TypeVariableType variable)) { |
| + int currentVariable = 0; |
| + bool isFirst = true; |
| + collection.forEach((TypeVariableType variable) { |
| + f(isFirst, currentVariable < numberOfInputs, variable); |
| + isFirst = false; |
| + currentVariable++; |
| + }); |
| + } |
| + |
| + /** |
| + * Generate a string representation template for this element, using '#' to |
| + * denote the place for the type argument input. If there are more type |
| + * variables than [numberOfInputs], 'Dynamic' is used as the value for these |
| + * arguments. |
| + */ |
| + static String generateRuntimeTypeString(ClassElement element, |
| + int numberOfInputs) { |
| + StringBuffer buffer = new StringBuffer(element.name.slowToString()); |
| + foreach(element.typeVariables, numberOfInputs, |
| + (bool isFirst, bool hasValue, _) { |
| + String value = hasValue ? "' + # + '" : "Dynamic"; |
| + buffer.add(isFirst ? "<$value" : ", $value"); |
|
kasperl
2012/09/14 12:35:37
If you remove the < here and move it out so you do
karlklose
2012/09/17 14:50:37
Done.
|
| + }); |
| + if (!element.typeVariables.isEmpty()) { |
| + buffer.add(">"); |
| + } |
| + return "'${buffer}'"; |
| + } |
| + |
| + /** |
| + * Generate a string template for the runtime type fields that contain the |
| + * type descriptions of the reified type arguments, using '#' to denote the |
| + * place for the type argument value, or [:null:] if there are more than |
| + * [numberOfInputs] type variables. |
| + */ |
| + static String generateTypeVariableString(ClassElement element, |
| + int numberOfInputs) { |
| + int currentVariable = 0; |
|
kasperl
2012/09/14 12:35:37
Unused?
karlklose
2012/09/17 14:50:37
Done.
|
| + StringBuffer buffer = new StringBuffer(); |
| + foreach(element.typeVariables, numberOfInputs, |
| + (bool isFirst, bool hasValue, variable) { |
| + if (!isFirst) { |
| + buffer.add(', '); |
| + } |
| + String value = hasValue ? "#" : "null"; |
| + buffer.add("'${variable.name.slowToString()}': $value"); |
| + }); |
| + return buffer.toString(); |
| + } |
| } |