01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.dev.generator.ast;
17:
18: import java.util.List;
19:
20: /**
21: * An {@link Expression} that represents a method call, for example,
22: * <code>foo( a, b, c )</code>.
23: */
24: public class MethodCall extends Expression {
25:
26: private final List<String> arguments;
27:
28: private final String name;
29:
30: /**
31: * Creates a new MethodCall Expression.
32: *
33: * @param name The name of the method. This must contain the qualified target
34: * expression if it is not implicitly this. For example, "foo.bar".
35: *
36: * @param arguments The list of Expressions that are the arguments for the
37: * call.
38: */
39: public MethodCall(String name, List<String> arguments) {
40: this .name = name;
41: this .arguments = arguments;
42:
43: StringBuffer call = new StringBuffer(name + "(");
44:
45: if (arguments != null) {
46: call.append(" ");
47: for (int i = 0; i < arguments.size(); ++i) {
48: call.append(arguments.get(i));
49: if (i < arguments.size() - 1) {
50: call.append(", ");
51: }
52: }
53: call.append(" ");
54: }
55:
56: call.append(")");
57: super.code = call.toString();
58: }
59: }
|