| 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 library dart2js.ir_nodes_sexpr; | 5 library dart2js.ir_nodes_sexpr; |
| 6 | 6 |
| 7 import '../constants/values.dart'; | 7 import '../constants/values.dart'; |
| 8 import '../util/util.dart'; | 8 import '../util/util.dart'; |
| 9 import 'cps_ir_nodes.dart'; | 9 import 'cps_ir_nodes.dart'; |
| 10 import '../universe/universe.dart' show Selector, CallStructure; | 10 import '../universe/universe.dart' show Selector, CallStructure; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 String function = | 211 String function = |
| 212 indentBlock(() => indentBlock(() => visit(node.definition))); | 212 indentBlock(() => indentBlock(() => visit(node.definition))); |
| 213 return '(CreateFunction\n$function)'; | 213 return '(CreateFunction\n$function)'; |
| 214 } | 214 } |
| 215 | 215 |
| 216 String visitContinuation(Continuation node) { | 216 String visitContinuation(Continuation node) { |
| 217 // Continuations are visited directly in visitLetCont. | 217 // Continuations are visited directly in visitLetCont. |
| 218 return '(Unexpected Continuation)'; | 218 return '(Unexpected Continuation)'; |
| 219 } | 219 } |
| 220 | 220 |
| 221 String visitGetMutableVariable(GetMutableVariable node) { | 221 String visitGetMutable(GetMutable node) { |
| 222 return '(GetMutableVariable ${access(node.variable)})'; | 222 return '(GetMutable ${access(node.variable)})'; |
| 223 } | 223 } |
| 224 | 224 |
| 225 String visitSetMutableVariable(SetMutableVariable node) { | 225 String visitSetMutable(SetMutable node) { |
| 226 String value = access(node.value); | 226 String value = access(node.value); |
| 227 String body = indentBlock(() => visit(node.body)); | 227 return '(SetMutable ${access(node.variable)} $value)'; |
| 228 return '$indentation(SetMutableVariable ${access(node.variable)} ' | |
| 229 '$value\n$body)'; | |
| 230 } | 228 } |
| 231 | 229 |
| 232 String visitTypeCast(TypeCast node) { | 230 String visitTypeCast(TypeCast node) { |
| 233 String value = access(node.value); | 231 String value = access(node.value); |
| 234 String cont = access(node.continuation); | 232 String cont = access(node.continuation); |
| 235 String typeArguments = node.typeArguments.map(access).join(' '); | 233 String typeArguments = node.typeArguments.map(access).join(' '); |
| 236 return '$indentation(TypeCast $value ${node.type} ($typeArguments) $cont)'; | 234 return '$indentation(TypeCast $value ${node.type} ($typeArguments) $cont)'; |
| 237 } | 235 } |
| 238 | 236 |
| 239 String visitTypeTest(TypeTest node) { | 237 String visitTypeTest(TypeTest node) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 255 | 253 |
| 256 String visitIsTrue(IsTrue node) { | 254 String visitIsTrue(IsTrue node) { |
| 257 String value = access(node.value); | 255 String value = access(node.value); |
| 258 return '(IsTrue $value)'; | 256 return '(IsTrue $value)'; |
| 259 } | 257 } |
| 260 | 258 |
| 261 String visitSetField(SetField node) { | 259 String visitSetField(SetField node) { |
| 262 String object = access(node.object); | 260 String object = access(node.object); |
| 263 String field = node.field.name; | 261 String field = node.field.name; |
| 264 String value = access(node.value); | 262 String value = access(node.value); |
| 265 String body = indentBlock(() => visit(node.body)); | 263 return '(SetField $object $field $value)'; |
| 266 return '$indentation(SetField $object $field $value)\n$body'; | |
| 267 } | 264 } |
| 268 | 265 |
| 269 String visitGetField(GetField node) { | 266 String visitGetField(GetField node) { |
| 270 String object = access(node.object); | 267 String object = access(node.object); |
| 271 String field = node.field.name; | 268 String field = node.field.name; |
| 272 return '(GetField $object $field)'; | 269 return '(GetField $object $field)'; |
| 273 } | 270 } |
| 274 | 271 |
| 275 String visitGetStatic(GetStatic node) { | 272 String visitGetStatic(GetStatic node) { |
| 276 String element = node.element.name; | 273 String element = node.element.name; |
| 277 return '(GetStatic $element)'; | 274 return '(GetStatic $element)'; |
| 278 } | 275 } |
| 279 | 276 |
| 280 String visitSetStatic(SetStatic node) { | 277 String visitSetStatic(SetStatic node) { |
| 281 String element = node.element.name; | 278 String element = node.element.name; |
| 282 String value = access(node.value); | 279 String value = access(node.value); |
| 283 String body = indentBlock(() => visit(node.body)); | 280 return '(SetStatic $element $value)'; |
| 284 return '$indentation(SetStatic $element $value\n$body)'; | |
| 285 } | 281 } |
| 286 | 282 |
| 287 String visitGetLazyStatic(GetLazyStatic node) { | 283 String visitGetLazyStatic(GetLazyStatic node) { |
| 288 String element = node.element.name; | 284 String element = node.element.name; |
| 289 String cont = access(node.continuation); | 285 String cont = access(node.continuation); |
| 290 return '$indentation(GetLazyStatic $element $cont)'; | 286 return '$indentation(GetLazyStatic $element $cont)'; |
| 291 } | 287 } |
| 292 | 288 |
| 293 String visitCreateBox(CreateBox node) { | 289 String visitCreateBox(CreateBox node) { |
| 294 return '(CreateBox)'; | 290 return '(CreateBox)'; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 String args = node.arguments.map(access).join(' '); | 324 String args = node.arguments.map(access).join(' '); |
| 329 return '(CreateInvocationMirror $selector ($args))'; | 325 return '(CreateInvocationMirror $selector ($args))'; |
| 330 } | 326 } |
| 331 | 327 |
| 332 String visitApplyBuiltinOperator(ApplyBuiltinOperator node) { | 328 String visitApplyBuiltinOperator(ApplyBuiltinOperator node) { |
| 333 String operator = node.operator.toString(); | 329 String operator = node.operator.toString(); |
| 334 String args = node.arguments.map(access).join(' '); | 330 String args = node.arguments.map(access).join(' '); |
| 335 return '(ApplyBuiltinOperator $operator ($args))'; | 331 return '(ApplyBuiltinOperator $operator ($args))'; |
| 336 } | 332 } |
| 337 | 333 |
| 338 @override | |
| 339 String visitForeignCode(ForeignCode node) { | 334 String visitForeignCode(ForeignCode node) { |
| 340 String arguments = node.arguments.map(access).join(' '); | 335 String arguments = node.arguments.map(access).join(' '); |
| 341 String continuation = node.continuation == null ? '' | 336 String continuation = node.continuation == null ? '' |
| 342 : ' ${access(node.continuation)}'; | 337 : ' ${access(node.continuation)}'; |
| 343 return '(JS ${node.type} ${node.codeTemplate} ($arguments)$continuation)'; | 338 return '(JS ${node.type} ${node.codeTemplate} ($arguments)$continuation)'; |
| 344 } | 339 } |
| 345 | 340 |
| 346 @override | |
| 347 String visitGetLength(GetLength node) { | 341 String visitGetLength(GetLength node) { |
| 348 String object = access(node.object); | 342 String object = access(node.object); |
| 349 return '(GetLength $object)'; | 343 return '(GetLength $object)'; |
| 350 } | 344 } |
| 351 | 345 |
| 352 @override | |
| 353 String visitGetIndex(GetIndex node) { | 346 String visitGetIndex(GetIndex node) { |
| 354 String object = access(node.object); | 347 String object = access(node.object); |
| 355 String index = access(node.index); | 348 String index = access(node.index); |
| 356 return '(GetIndex $object $index)'; | 349 return '(GetIndex $object $index)'; |
| 357 } | 350 } |
| 358 | 351 |
| 359 @override | |
| 360 String visitSetIndex(SetIndex node) { | 352 String visitSetIndex(SetIndex node) { |
| 361 String object = access(node.object); | 353 String object = access(node.object); |
| 362 String index = access(node.index); | 354 String index = access(node.index); |
| 363 String value = access(node.value); | 355 String value = access(node.value); |
| 364 return '(SetIndex $object $index $value)'; | 356 return '(SetIndex $object $index $value)'; |
| 365 } | 357 } |
| 366 } | 358 } |
| 367 | 359 |
| 368 class ConstantStringifier extends ConstantValueVisitor<String, Null> { | 360 class ConstantStringifier extends ConstantValueVisitor<String, Null> { |
| 369 // Some of these methods are unimplemented because we haven't had a need | 361 // Some of these methods are unimplemented because we haven't had a need |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 void setReturnContinuation(Continuation node) { | 462 void setReturnContinuation(Continuation node) { |
| 471 assert(!_names.containsKey(node) || _names[node] == 'return'); | 463 assert(!_names.containsKey(node) || _names[node] == 'return'); |
| 472 _names[node] = 'return'; | 464 _names[node] = 'return'; |
| 473 } | 465 } |
| 474 | 466 |
| 475 String getName(Node node) { | 467 String getName(Node node) { |
| 476 if (!_names.containsKey(node)) return 'MISSING_NAME'; | 468 if (!_names.containsKey(node)) return 'MISSING_NAME'; |
| 477 return _names[node]; | 469 return _names[node]; |
| 478 } | 470 } |
| 479 } | 471 } |
| OLD | NEW |