| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 package com.google.dart.compiler.ast; | 5 package com.google.dart.compiler.ast; |
| 6 | 6 |
| 7 import java.util.List; | 7 import java.util.List; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Represents a Dart function. | 10 * Represents a Dart function. |
| 11 */ | 11 */ |
| 12 public class DartFunction extends DartNode { | 12 public class DartFunction extends DartNode { |
| 13 | 13 |
| 14 private final NodeList<DartParameter> parameters = NodeList.create(this); | 14 private final NodeList<DartParameter> parameters = NodeList.create(this); |
| 15 private final int parametersOptionalOpen; | 15 private final int parametersOptionalOpen; |
| 16 private final int parametersOptionalClose; | 16 private final int parametersOptionalClose; |
| 17 private final int parametersCloseParen; | 17 private final int parametersCloseParen; |
| 18 private DartBlock body; | 18 private DartBlock body; |
| 19 private DartTypeNode returnTypeNode; | 19 private DartTypeNode returnTypeNode; |
| 20 | 20 |
| 21 public DartFunction(List<DartParameter> parameters, int parametersOptionalOpen
, | 21 public DartFunction(List<DartParameter> parameters, int parametersOptionalOpen
, |
| 22 int parametersOptionalClose, int parametersCloseParen, DartBlock body, | 22 int parametersOptionalClose, int parametersCloseParen, DartBlock body, |
| 23 DartTypeNode returnTypeNode) { | 23 DartTypeNode returnTypeNode) { |
| 24 this.parametersOptionalOpen = parametersOptionalOpen; | 24 this.parametersOptionalOpen = parametersOptionalOpen; |
| 25 this.parametersOptionalClose = parametersOptionalClose; | 25 this.parametersOptionalClose = parametersOptionalClose; |
| 26 this.parameters.addAll(parameters); | 26 if (parameters != null && !parameters.isEmpty()) { |
| 27 this.parameters.addAll(parameters); |
| 28 } |
| 27 this.parametersCloseParen = parametersCloseParen; | 29 this.parametersCloseParen = parametersCloseParen; |
| 28 this.body = becomeParentOf(body); | 30 this.body = becomeParentOf(body); |
| 29 this.returnTypeNode = becomeParentOf(returnTypeNode); | 31 this.returnTypeNode = becomeParentOf(returnTypeNode); |
| 30 } | 32 } |
| 31 | 33 |
| 32 public DartBlock getBody() { | 34 public DartBlock getBody() { |
| 33 return body; | 35 return body; |
| 34 } | 36 } |
| 35 | 37 |
| 36 public List<DartParameter> getParameters() { | 38 public List<DartParameter> getParameters() { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 parameters.accept(visitor); | 60 parameters.accept(visitor); |
| 59 safelyVisitChild(body, visitor); | 61 safelyVisitChild(body, visitor); |
| 60 safelyVisitChild(returnTypeNode, visitor); | 62 safelyVisitChild(returnTypeNode, visitor); |
| 61 } | 63 } |
| 62 | 64 |
| 63 @Override | 65 @Override |
| 64 public <R> R accept(ASTVisitor<R> visitor) { | 66 public <R> R accept(ASTVisitor<R> visitor) { |
| 65 return visitor.visitFunction(this); | 67 return visitor.visitFunction(this); |
| 66 } | 68 } |
| 67 } | 69 } |
| OLD | NEW |