| 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 valueBuilder.literalInt(enumConstant.index), | 418 valueBuilder.literalInt(enumConstant.index), |
| 419 valueBuilder | 419 valueBuilder |
| 420 .literalString('${enumClass.name}.${name.source}'))); | 420 .literalString('${enumClass.name}.${name.source}'))); |
| 421 } | 421 } |
| 422 | 422 |
| 423 // TODO(johnniwinther): Support return type. Note `String` might be | 423 // TODO(johnniwinther): Support return type. Note `String` might be |
| 424 // prefixed or not imported within the current library. | 424 // prefixed or not imported within the current library. |
| 425 FunctionExpression toStringNode = builder.functionExpression( | 425 FunctionExpression toStringNode = builder.functionExpression( |
| 426 Modifiers.EMPTY, | 426 Modifiers.EMPTY, |
| 427 'toString', | 427 'toString', |
| 428 null, |
| 428 builder.argumentList([]), | 429 builder.argumentList([]), |
| 429 builder.returnStatement(builder.indexGet( | 430 builder.returnStatement(builder.indexGet( |
| 430 builder.mapLiteral(mapEntries, isConst: true), | 431 builder.mapLiteral(mapEntries, isConst: true), |
| 431 builder.reference(builder.identifier('index'))))); | 432 builder.reference(builder.identifier('index'))))); |
| 432 return toStringNode; | 433 return toStringNode; |
| 433 case AstKind.ENUM_CONSTRUCTOR: | 434 case AstKind.ENUM_CONSTRUCTOR: |
| 434 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); | 435 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); |
| 435 VariableDefinitions indexDefinition = | 436 VariableDefinitions indexDefinition = |
| 436 builder.initializingFormal('index'); | 437 builder.initializingFormal('index'); |
| 437 FunctionExpression constructorNode = builder.functionExpression( | 438 FunctionExpression constructorNode = builder.functionExpression( |
| 438 builder.modifiers(isConst: true), | 439 builder.modifiers(isConst: true), |
| 439 element.enclosingClass.name, | 440 element.enclosingClass.name, |
| 441 null, |
| 440 builder.argumentList([indexDefinition]), | 442 builder.argumentList([indexDefinition]), |
| 441 builder.emptyStatement()); | 443 builder.emptyStatement()); |
| 442 return constructorNode; | 444 return constructorNode; |
| 443 case AstKind.ENUM_CONSTANT: | 445 case AstKind.ENUM_CONSTANT: |
| 444 EnumConstantElement enumConstant = element; | 446 EnumConstantElement enumConstant = element; |
| 445 EnumClassElement enumClass = element.enclosingClass; | 447 EnumClassElement enumClass = element.enclosingClass; |
| 446 int index = enumConstant.index; | 448 int index = enumConstant.index; |
| 447 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); | 449 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); |
| 448 Identifier name = builder.identifier(element.name); | 450 Identifier name = builder.identifier(element.name); |
| 449 | 451 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 var nativeData = nativeDataDeserializer.onData(nativeDataDecoder); | 616 var nativeData = nativeDataDeserializer.onData(nativeDataDecoder); |
| 615 if (nativeData != null) { | 617 if (nativeData != null) { |
| 616 elements.registerNativeData(node, nativeData); | 618 elements.registerNativeData(node, nativeData); |
| 617 } | 619 } |
| 618 } | 620 } |
| 619 } | 621 } |
| 620 } | 622 } |
| 621 return new ParsedResolvedAst(element, root, body, elements); | 623 return new ParsedResolvedAst(element, root, body, elements); |
| 622 } | 624 } |
| 623 } | 625 } |
| OLD | NEW |