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, | |
429 builder.argumentList([]), | 428 builder.argumentList([]), |
430 builder.returnStatement(builder.indexGet( | 429 builder.returnStatement(builder.indexGet( |
431 builder.mapLiteral(mapEntries, isConst: true), | 430 builder.mapLiteral(mapEntries, isConst: true), |
432 builder.reference(builder.identifier('index'))))); | 431 builder.reference(builder.identifier('index'))))); |
433 return toStringNode; | 432 return toStringNode; |
434 case AstKind.ENUM_CONSTRUCTOR: | 433 case AstKind.ENUM_CONSTRUCTOR: |
435 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); | 434 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); |
436 VariableDefinitions indexDefinition = | 435 VariableDefinitions indexDefinition = |
437 builder.initializingFormal('index'); | 436 builder.initializingFormal('index'); |
438 FunctionExpression constructorNode = builder.functionExpression( | 437 FunctionExpression constructorNode = builder.functionExpression( |
439 builder.modifiers(isConst: true), | 438 builder.modifiers(isConst: true), |
440 element.enclosingClass.name, | 439 element.enclosingClass.name, |
441 null, | |
442 builder.argumentList([indexDefinition]), | 440 builder.argumentList([indexDefinition]), |
443 builder.emptyStatement()); | 441 builder.emptyStatement()); |
444 return constructorNode; | 442 return constructorNode; |
445 case AstKind.ENUM_CONSTANT: | 443 case AstKind.ENUM_CONSTANT: |
446 EnumConstantElement enumConstant = element; | 444 EnumConstantElement enumConstant = element; |
447 EnumClassElement enumClass = element.enclosingClass; | 445 EnumClassElement enumClass = element.enclosingClass; |
448 int index = enumConstant.index; | 446 int index = enumConstant.index; |
449 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); | 447 AstBuilder builder = new AstBuilder(element.sourcePosition.begin); |
450 Identifier name = builder.identifier(element.name); | 448 Identifier name = builder.identifier(element.name); |
451 | 449 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 var nativeData = nativeDataDeserializer.onData(nativeDataDecoder); | 614 var nativeData = nativeDataDeserializer.onData(nativeDataDecoder); |
617 if (nativeData != null) { | 615 if (nativeData != null) { |
618 elements.registerNativeData(node, nativeData); | 616 elements.registerNativeData(node, nativeData); |
619 } | 617 } |
620 } | 618 } |
621 } | 619 } |
622 } | 620 } |
623 return new ParsedResolvedAst(element, root, body, elements); | 621 return new ParsedResolvedAst(element, root, body, elements); |
624 } | 622 } |
625 } | 623 } |
OLD | NEW |