1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
package com.sun.tools.javafx.tree; |
27 | |
|
28 | |
import com.sun.javafx.api.tree.JavaFXTree.JavaFXKind; |
29 | |
import com.sun.javafx.api.tree.JavaFXTreeVisitor; |
30 | |
import com.sun.javafx.api.tree.FunctionDefinitionTree; |
31 | |
import com.sun.tools.javac.code.Symbol.MethodSymbol; |
32 | |
import com.sun.tools.javac.tree.JCTree.JCModifiers; |
33 | |
import com.sun.tools.javac.util.List; |
34 | |
import com.sun.tools.javac.util.Name; |
35 | |
import com.sun.tools.javac.tree.Pretty; |
36 | |
import com.sun.tools.javac.tree.JCTree.*; |
37 | |
import com.sun.tools.javafx.code.JavafxFlags; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | 16 | public class JFXFunctionDefinition extends JFXStatement implements FunctionDefinitionTree { |
43 | |
public final JCModifiers mods; |
44 | |
public final Name name; |
45 | |
public final JFXFunctionValue operation; |
46 | |
public MethodSymbol sym; |
47 | |
|
48 | |
public JFXFunctionDefinition( |
49 | |
JCModifiers mods, |
50 | |
Name name, |
51 | 174 | JFXFunctionValue operation) { |
52 | 174 | this.mods = mods; |
53 | 174 | this.name = name; |
54 | 174 | this.operation = operation; |
55 | 174 | } |
56 | |
|
57 | |
protected JFXFunctionDefinition( |
58 | |
JCModifiers mods, |
59 | |
Name name, |
60 | |
JFXType rettype, |
61 | |
List<JFXVar> funParams, |
62 | 1073 | JFXBlockExpression bodyExpression) { |
63 | 1073 | this.mods = mods; |
64 | 1073 | this.name = name; |
65 | 1073 | this.operation = new JFXFunctionValue(rettype, funParams, bodyExpression); |
66 | 1073 | } |
67 | |
|
68 | |
public JFXBlockExpression getBodyExpression() { |
69 | 2769 | return operation.getBodyExpression(); |
70 | |
} |
71 | 2813 | public JCModifiers getModifiers() { return mods; } |
72 | 0 | public boolean isBound() { return (mods.flags & JavafxFlags.BOUND) != 0; } |
73 | 345 | public Name getName() { return name; } |
74 | 3549 | public JFXType getJFXReturnType() { return operation.rettype; } |
75 | 3681 | public List<JFXVar> getParameters() { return operation.funParams; } |
76 | |
public JFXFunctionValue getFunctionValue() { |
77 | 1068 | return operation; |
78 | |
} |
79 | |
|
80 | |
public void accept(JavafxVisitor v) { |
81 | 7485 | v.visitFunctionDefinition(this); |
82 | 7482 | } |
83 | |
|
84 | |
@Override |
85 | |
public void accept(Visitor v) { |
86 | 7485 | if (v instanceof JavafxVisitor) { |
87 | 7485 | this.accept((JavafxVisitor)v); |
88 | 0 | } else if (v instanceof Pretty) { |
89 | 0 | JavafxPretty.visitFunctionDefinition((Pretty) v, this); |
90 | |
} else { |
91 | 0 | assert false; |
92 | |
} |
93 | 7482 | } |
94 | |
|
95 | |
@Override |
96 | |
public int getTag() { |
97 | 14737 | return JavafxTag.FUNCTION_DEF; |
98 | |
} |
99 | |
|
100 | |
public JavaFXKind getJavaFXKind() { |
101 | 0 | return JavaFXKind.FUNCTION_DEFINITION; |
102 | |
} |
103 | |
|
104 | |
public <R, D> R accept(JavaFXTreeVisitor<R, D> visitor, D data) { |
105 | 3 | return visitor.visitFunctionDefinition(this, data); |
106 | |
} |
107 | |
} |