| 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 /** | 5 /** |
| 6 * Code generation for the file "matchers.dart". | 6 * Code generation for the file "matchers.dart". |
| 7 */ | 7 */ |
| 8 library codegen.matchers; | 8 library codegen.matchers; |
| 9 | 9 |
| 10 import 'dart:convert'; | 10 import 'dart:convert'; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 commaNeeded = true; | 152 commaNeeded = true; |
| 153 } | 153 } |
| 154 writeln(); | 154 writeln(); |
| 155 }); | 155 }); |
| 156 write('}'); | 156 write('}'); |
| 157 } | 157 } |
| 158 | 158 |
| 159 @override | 159 @override |
| 160 void visitTypeReference(TypeReference typeReference) { | 160 void visitTypeReference(TypeReference typeReference) { |
| 161 write(camelJoin(['is', typeReference.typeName])); | 161 String typeName = typeReference.typeName; |
| 162 if (typeName == 'long') { |
| 163 typeName = 'int'; |
| 164 } |
| 165 write(camelJoin(['is', typeName])); |
| 162 } | 166 } |
| 163 | 167 |
| 164 @override | 168 @override |
| 165 void visitTypeUnion(TypeUnion typeUnion) { | 169 void visitTypeUnion(TypeUnion typeUnion) { |
| 166 bool commaNeeded = false; | 170 bool commaNeeded = false; |
| 167 write('isOneOf(['); | 171 write('isOneOf(['); |
| 168 for (TypeDecl choice in typeUnion.choices) { | 172 for (TypeDecl choice in typeUnion.choices) { |
| 169 if (commaNeeded) { | 173 if (commaNeeded) { |
| 170 write(', '); | 174 write(', '); |
| 171 } | 175 } |
| 172 visitTypeDecl(choice); | 176 visitTypeDecl(choice); |
| 173 commaNeeded = true; | 177 commaNeeded = true; |
| 174 } | 178 } |
| 175 write('])'); | 179 write('])'); |
| 176 } | 180 } |
| 177 } | 181 } |
| 178 | 182 |
| 179 final GeneratedFile target = new GeneratedFile( | 183 final GeneratedFile target = new GeneratedFile( |
| 180 '../../test/integration/protocol_matchers.dart', () { | 184 '../../test/integration/protocol_matchers.dart', () { |
| 181 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); | 185 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); |
| 182 return visitor.collectCode(visitor.visitApi); | 186 return visitor.collectCode(visitor.visitApi); |
| 183 }); | 187 }); |
| 184 | 188 |
| 185 /** | 189 /** |
| 186 * Translate spec_input.html into protocol_matchers.dart. | 190 * Translate spec_input.html into protocol_matchers.dart. |
| 187 */ | 191 */ |
| 188 main() { | 192 main() { |
| 189 target.generate(); | 193 target.generate(); |
| 190 } | 194 } |
| OLD | NEW |