1
3 package jminusminus;
4
5 import java.util.ArrayList;
6
7
10 class JInterfaceDeclaration extends JAST implements JTypeDecl {
11 private ArrayList<String> mods;
13
14 private String name;
16
17 private Type thisType;
19
20 private Type superType;
22
23 private ArrayList<TypeName> superInterfaces;
25
26 private ArrayList<JMember> interfaceBlock;
28
29 private ClassContext context;
31
32
41 public JInterfaceDeclaration(int line, ArrayList<String> mods, String name,
42 ArrayList<TypeName> superInterfaces,
43 ArrayList<JMember> interfaceBlock) {
44 super(line);
45 this.mods = mods;
46 this.name = name;
47 this.superType = Type.OBJECT;
48 this.superInterfaces = superInterfaces;
49 this.interfaceBlock = interfaceBlock;
50 }
51
52
55 public void declareThisType(Context context) {
56 }
58
59
62 public void preAnalyze(Context context) {
63 }
65
66
69 public String name() {
70 return name;
71 }
72
73
76 public Type superType() {
77 return superType;
78 }
79
80
83 public ArrayList<TypeName> superInterfaces() {
84 return superInterfaces;
85 }
86
87
90 public Type thisType() {
91 return null;
93 }
94
95
98 public JAST analyze(Context context) {
99 return this;
101 }
102
103
106 public void codegen(CLEmitter output) {
107 }
109
110
113 public void toJSON(JSONElement json) {
114 JSONElement e = new JSONElement();
115 json.addChild("JInterfaceDeclaration:" + line, e);
116 if (mods != null) {
117 ArrayList<String> value = new ArrayList<String>();
118 for (String mod : mods) {
119 value.add(String.format("\"%s\"", mod));
120 }
121 e.addAttribute("modifiers", value);
122 }
123 e.addAttribute("name", name);
124 e.addAttribute("super", superType == null ? "" : superType.toString());
125 if (superInterfaces != null) {
126 ArrayList<String> value = new ArrayList<String>();
127 for (TypeName impl : superInterfaces) {
128 value.add(String.format("\"%s\"", impl.toString()));
129 }
130 e.addAttribute("extends", value);
131 }
132 if (context != null) {
133 context.toJSON(e);
134 }
135 if (interfaceBlock != null) {
136 for (JMember member : interfaceBlock) {
137 ((JAST) member).toJSON(e);
138 }
139 }
140 }
141 }
142