OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.serialization.resolved_ast; | 5 library dart2js.serialization.resolved_ast; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/resolution.dart'; | 8 import '../common/resolution.dart'; |
9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 valueBuilder.literalInt(enumConstant.index), | 422 valueBuilder.literalInt(enumConstant.index), |
423 valueBuilder | 423 valueBuilder |
424 .literalString('${enumClass.name}.${name.source}'))); | 424 .literalString('${enumClass.name}.${name.source}'))); |
425 } | 425 } |
426 | 426 |
427 // TODO(johnniwinther): Support return type. Note `String` might be | 427 // TODO(johnniwinther): Support return type. Note `String` might be |
428 // prefixed or not imported within the current library. | 428 // prefixed or not imported within the current library. |
429 FunctionExpression toStringNode = builder.functionExpression( | 429 FunctionExpression toStringNode = builder.functionExpression( |
430 Modifiers.EMPTY, | 430 Modifiers.EMPTY, |
431 'toString', | 431 'toString', |
| 432 null, |
432 builder.argumentList([]), | 433 builder.argumentList([]), |
433 builder.returnStatement(builder.indexGet( | 434 builder.returnStatement(builder.indexGet( |
434 builder.mapLiteral(mapEntries, isConst: true), | 435 builder.mapLiteral(mapEntries, isConst: true), |
435 builder.reference(builder.identifier('index'))))); | 436 builder.reference(builder.identifier('index'))))); |
436 return toStringNode; | 437 return toStringNode; |
437 case AstKind.ENUM_CONSTRUCTOR: | 438 case AstKind.ENUM_CONSTRUCTOR: |
438 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); | 439 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); |
439 VariableDefinitions indexDefinition = | 440 VariableDefinitions indexDefinition = |
440 builder.initializingFormal('index'); | 441 builder.initializingFormal('index'); |
441 FunctionExpression constructorNode = builder.functionExpression( | 442 FunctionExpression constructorNode = builder.functionExpression( |
442 builder.modifiers(isConst: true), | 443 builder.modifiers(isConst: true), |
443 element.enclosingClass.name, | 444 element.enclosingClass.name, |
| 445 null, |
444 builder.argumentList([indexDefinition]), | 446 builder.argumentList([indexDefinition]), |
445 builder.emptyStatement()); | 447 builder.emptyStatement()); |
446 return constructorNode; | 448 return constructorNode; |
447 case AstKind.ENUM_CONSTANT: | 449 case AstKind.ENUM_CONSTANT: |
448 EnumConstantElement enumConstant = element; | 450 EnumConstantElement enumConstant = element; |
449 EnumClassElement enumClass = element.enclosingClass; | 451 EnumClassElement enumClass = element.enclosingClass; |
450 int index = enumConstant.index; | 452 int index = enumConstant.index; |
451 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); | 453 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); |
452 Identifier name = builder.identifier(element.name); | 454 Identifier name = builder.identifier(element.name); |
453 | 455 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 var nativeData = nativeDataDeserializer.onData(nativeDataDecoder); | 623 var nativeData = nativeDataDeserializer.onData(nativeDataDecoder); |
622 if (nativeData != null) { | 624 if (nativeData != null) { |
623 elements.registerNativeData(node, nativeData); | 625 elements.registerNativeData(node, nativeData); |
624 } | 626 } |
625 } | 627 } |
626 } | 628 } |
627 } | 629 } |
628 return new ParsedResolvedAst(element, root, body, elements); | 630 return new ParsedResolvedAst(element, root, body, elements); |
629 } | 631 } |
630 } | 632 } |
OLD | NEW |