equal
deleted
inserted
replaced
114 if (ti.type == null) { |
114 if (ti.type == null) { |
115 throw new IllegalStateException("Type not provided!"); |
115 throw new IllegalStateException("Type not provided!"); |
116 } |
116 } |
117 VariableImpl vi = new VariableImpl(ti.type, name); |
117 VariableImpl vi = new VariableImpl(ti.type, name); |
118 field.accept(vi); |
118 field.accept(vi); |
119 result.defs = result.defs.prepend(vi.result); |
119 result.defs = result.defs.append(vi.result); |
120 return this; |
120 return this; |
121 } |
121 } |
122 |
122 |
123 @Override |
123 @Override |
124 public Class method(String name, Consumer<Type> restype, Consumer<Method> method) { |
124 public Class method(String name, Consumer<Type> restype, Consumer<Method> method) { |
182 result = make.VarDef(make.Modifiers(0), names.fromString(name), type, null); |
182 result = make.VarDef(make.Modifiers(0), names.fromString(name), type, null); |
183 } |
183 } |
184 |
184 |
185 @Override |
185 @Override |
186 public Variable init(Consumer<Expression> init) { |
186 public Variable init(Consumer<Expression> init) { |
187 throw new UnsupportedOperationException("Not supported yet."); |
187 ExpressionImpl expr = new ExpressionImpl(); |
|
188 |
|
189 init.accept(expr); |
|
190 |
|
191 if (expr.expr == null) { |
|
192 throw new IllegalStateException("Expression not provided!"); |
|
193 } |
|
194 |
|
195 result.init = expr.expr; |
|
196 |
|
197 return this; |
188 } |
198 } |
189 |
199 |
190 @Override |
200 @Override |
191 public Variable modifiers(Consumer<Modifiers> modifiers) { |
201 public Variable modifiers(Consumer<Modifiers> modifiers) { |
192 throw new UnsupportedOperationException("Not supported yet."); |
202 throw new UnsupportedOperationException("Not supported yet."); |
201 public Variable javadoc(String doc) { |
211 public Variable javadoc(String doc) { |
202 throw new UnsupportedOperationException("Not supported yet."); |
212 throw new UnsupportedOperationException("Not supported yet."); |
203 } |
213 } |
204 |
214 |
205 } |
215 } |
|
216 |
|
217 private final class ExpressionImpl implements Expression { |
|
218 |
|
219 private JCExpression expr; |
|
220 |
|
221 @Override |
|
222 public void minusminus(Consumer<Expression> expr) { |
|
223 throw new UnsupportedOperationException("Not supported yet."); |
|
224 } |
|
225 |
|
226 @Override |
|
227 public void plus(Consumer<Expression> lhs, Consumer<Expression> rhs) { |
|
228 ExpressionImpl left = new ExpressionImpl(); |
|
229 lhs.accept(left); |
|
230 ExpressionImpl right = new ExpressionImpl(); |
|
231 rhs.accept(right); |
|
232 expr = make.Binary(Tag.PLUS, left.expr, right.expr); //XXX: check exprs filled! |
|
233 } |
|
234 |
|
235 @Override |
|
236 public void cond(Consumer<Expression> cond, Consumer<Expression> truePart, Consumer<Expression> falsePart) { |
|
237 throw new UnsupportedOperationException("Not supported yet."); |
|
238 } |
|
239 |
|
240 @Override |
|
241 public void ident(String... qnames) { |
|
242 expr = make.Ident(names.fromString(qnames[0])); //XXX |
|
243 } |
|
244 |
|
245 @Override |
|
246 public void literal(Object value) { |
|
247 expr = make.Literal(value); |
|
248 } |
|
249 } |
206 } |
250 } |