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.jjs.ast.js;
17:
18: import com.google.gwt.dev.jjs.SourceInfo;
19: import com.google.gwt.dev.jjs.ast.Context;
20: import com.google.gwt.dev.jjs.ast.JAbstractMethodBody;
21: import com.google.gwt.dev.jjs.ast.JProgram;
22: import com.google.gwt.dev.jjs.ast.JVisitor;
23: import com.google.gwt.dev.js.ast.JsFunction;
24:
25: import java.util.ArrayList;
26: import java.util.List;
27:
28: /**
29: * Represents a the body of a method. Can be Java or JSNI.
30: */
31: public class JsniMethodBody extends JAbstractMethodBody {
32:
33: public final List<JsniFieldRef> jsniFieldRefs = new ArrayList<JsniFieldRef>();
34:
35: public final List<JsniMethodRef> jsniMethodRefs = new ArrayList<JsniMethodRef>();
36:
37: private JsFunction jsFunction = null;
38:
39: public JsniMethodBody(JProgram program, SourceInfo info) {
40: super (program, info);
41: }
42:
43: public JsFunction getFunc() {
44: assert (this .jsFunction != null);
45: return jsFunction;
46: }
47:
48: public boolean isNative() {
49: return true;
50: }
51:
52: public void setFunc(JsFunction jsFunction) {
53: assert (this .jsFunction == null);
54: this .jsFunction = jsFunction;
55: }
56:
57: public void traverse(JVisitor visitor, Context ctx) {
58: if (visitor.visit(this, ctx)) {
59: visitor.accept(jsniFieldRefs);
60: visitor.accept(jsniMethodRefs);
61: }
62: visitor.endVisit(this, ctx);
63: }
64: }
|