| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 List<DartParameter> params; | 14 private final NodeList<DartParameter> parameters = NodeList.create(this); |
| 15 private DartBlock body; | 15 private DartBlock body; |
| 16 private DartTypeNode returnTypeNode; | 16 private DartTypeNode returnTypeNode; |
| 17 | 17 |
| 18 public DartFunction(List<DartParameter> arguments, DartBlock body, DartTypeNod
e returnTypeNode) { | 18 public DartFunction(List<DartParameter> parameters, DartBlock body, DartTypeNo
de returnTypeNode) { |
| 19 this.params = becomeParentOf(arguments); | 19 this.parameters.addAll(parameters); |
| 20 this.body = becomeParentOf(body); | 20 this.body = becomeParentOf(body); |
| 21 this.returnTypeNode = becomeParentOf(returnTypeNode); | 21 this.returnTypeNode = becomeParentOf(returnTypeNode); |
| 22 } | 22 } |
| 23 | 23 |
| 24 public void addParam(DartParameter param) { | |
| 25 params.add(param); | |
| 26 } | |
| 27 | |
| 28 public DartBlock getBody() { | 24 public DartBlock getBody() { |
| 29 return body; | 25 return body; |
| 30 } | 26 } |
| 31 | 27 |
| 32 public List<DartParameter> getParams() { | 28 public List<DartParameter> getParameters() { |
| 33 return params; | 29 return parameters; |
| 34 } | 30 } |
| 35 | 31 |
| 36 public DartTypeNode getReturnTypeNode() { | 32 public DartTypeNode getReturnTypeNode() { |
| 37 return returnTypeNode; | 33 return returnTypeNode; |
| 38 } | 34 } |
| 39 | 35 |
| 40 @Override | 36 @Override |
| 41 public void visitChildren(ASTVisitor<?> visitor) { | 37 public void visitChildren(ASTVisitor<?> visitor) { |
| 42 visitor.visit(params); | 38 parameters.accept(visitor); |
| 43 if (body != null) { | 39 if (body != null) { |
| 44 body.accept(visitor); | 40 body.accept(visitor); |
| 45 } | 41 } |
| 46 if (returnTypeNode != null) { | 42 if (returnTypeNode != null) { |
| 47 returnTypeNode.accept(visitor); | 43 returnTypeNode.accept(visitor); |
| 48 } | 44 } |
| 49 } | 45 } |
| 50 | 46 |
| 51 @Override | 47 @Override |
| 52 public <R> R accept(ASTVisitor<R> visitor) { | 48 public <R> R accept(ASTVisitor<R> visitor) { |
| 53 return visitor.visitFunction(this); | 49 return visitor.visitFunction(this); |
| 54 } | 50 } |
| 55 } | 51 } |
| OLD | NEW |