001: // ===========================================================================
002: // This file has been generated by
003: // xtc Factory Factory, version 1.13.0,
004: // (C) 2004-2007 Robert Grimm,
005: // on Wednesday, September 5, 2007 at 3:03:08 PM.
006: // Edit at your own risk.
007: // ===========================================================================
008:
009: package xtc.lang.jeannie;
010:
011: import java.util.List;
012:
013: import xtc.tree.Node;
014: import xtc.tree.GNode;
015:
016: /**
017: * Node factory <code>xtc.lang.jeannie.JeannieJavaFactory</code>.
018: *
019: * <p />This class has been generated by
020: * the xtc Factory Factory, version 1.13.0,
021: * (C) 2004-2007 Robert Grimm.
022: */
023: public class JeannieJavaFactory {
024:
025: /** Create a new node factory. */
026: public JeannieJavaFactory() {
027: // Nothing to do.
028: }
029:
030: /**
031: * Create a block.
032: *
033: * @param statements The statements.
034: * @return The generic node.
035: */
036: public Node block(List<Node> statements) {
037: Node v$1 = GNode.create("Block", statements.size()).addAll(
038: statements);
039: return v$1;
040: }
041:
042: /**
043: * Create a call expression.
044: *
045: * @param nativeMethod The nativeMethod.
046: * @return The generic node.
047: */
048: public Node cInJavaExpressionWithCEnv(String nativeMethod) {
049: Node v$1 = GNode.create("ThisExpression", null);
050: Node v$2 = GNode.create("PrimaryIdentifier", "cEnv");
051: Node v$3 = GNode.create("Arguments", v$2);
052: Node v$4 = GNode.create("CallExpression", v$1, null,
053: nativeMethod, v$3);
054: return v$4;
055: }
056:
057: /**
058: * Create a call expression.
059: *
060: * @param nativeMethod The nativeMethod.
061: * @return The generic node.
062: */
063: public Node cInJavaExpressionWithoutCEnv(String nativeMethod) {
064: Node v$1 = GNode.create("ThisExpression", null);
065: Node v$2 = GNode.create("Arguments", false);
066: Node v$3 = GNode.create("CallExpression", v$1, null,
067: nativeMethod, v$2);
068: return v$3;
069: }
070:
071: /**
072: * Create a block.
073: *
074: * @param nativeMethod The nativeMethod.
075: * @param returnAbrupt The returnAbrupt.
076: * @return The generic node.
077: */
078: public Node cInJavaStatementWithCEnv(String nativeMethod,
079: String returnAbrupt) {
080: Node v$1 = GNode.create("ThisExpression", null);
081: Node v$2 = GNode.create("PrimaryIdentifier", "cEnv");
082: Node v$3 = GNode.create("Arguments", v$2);
083: Node v$4 = GNode.create("CallExpression", v$1, null,
084: nativeMethod, v$3);
085: Node v$5 = GNode.create("ExpressionStatement", v$4);
086: Node v$6 = GNode.create("ThisExpression", null);
087: Node v$7 = GNode.create("SelectionExpression", v$6,
088: returnAbrupt);
089: Node v$8 = GNode.create("ReturnStatement", null);
090: Node v$9 = GNode.create("ConditionalStatement", v$7, v$8, null);
091: Node v$10 = GNode.create("Block", v$5, v$9);
092: return v$10;
093: }
094:
095: /**
096: * Create a block.
097: *
098: * @param nativeMethod The nativeMethod.
099: * @param returnAbrupt The returnAbrupt.
100: * @return The generic node.
101: */
102: public Node cInJavaStatementWithoutCEnv(String nativeMethod,
103: String returnAbrupt) {
104: Node v$1 = GNode.create("ThisExpression", null);
105: Node v$2 = GNode.create("Arguments", false);
106: Node v$3 = GNode.create("CallExpression", v$1, null,
107: nativeMethod, v$2);
108: Node v$4 = GNode.create("ExpressionStatement", v$3);
109: Node v$5 = GNode.create("ThisExpression", null);
110: Node v$6 = GNode.create("SelectionExpression", v$5,
111: returnAbrupt);
112: Node v$7 = GNode.create("ReturnStatement", null);
113: Node v$8 = GNode.create("ConditionalStatement", v$6, v$7, null);
114: Node v$9 = GNode.create("Block", v$4, v$8);
115: return v$9;
116: }
117:
118: /**
119: * Create a method declaration.
120: *
121: * @param returnType The returnType.
122: * @param name The name.
123: * @param envType The envType.
124: * @return The generic node.
125: */
126: public Node cInJavaCodeWithCEnv(Node returnType, String name,
127: Node envType) {
128: Node v$1 = GNode.create("Modifier", "private");
129: Node v$2 = GNode.create("Modifier", "native");
130: Node v$3 = GNode.create("Modifiers", v$1, v$2);
131: Node v$4 = GNode.create("Type", returnType, null);
132: Node v$5 = GNode.create("Modifier", "final");
133: Node v$6 = GNode.create("Modifiers", v$5);
134: Node v$7 = GNode.create("Type", envType, null);
135: Node v$8 = GNode.create("FormalParameter", v$6, v$7, null,
136: "cEnv", null);
137: Node v$9 = GNode.create("FormalParameters", v$8);
138: Node v$10 = GNode.create("MethodDeclaration", v$3, null, v$4,
139: name, v$9, null, null, null);
140: return v$10;
141: }
142:
143: /**
144: * Create a method declaration.
145: *
146: * @param returnType The returnType.
147: * @param name The name.
148: * @return The generic node.
149: */
150: public Node cInJavaCodeWithoutCEnv(Node returnType, String name) {
151: Node v$1 = GNode.create("Modifier", "private");
152: Node v$2 = GNode.create("Modifier", "native");
153: Node v$3 = GNode.create("Modifiers", v$1, v$2);
154: Node v$4 = GNode.create("Type", returnType, null);
155: Node v$5 = GNode.create("FormalParameters", false);
156: Node v$6 = GNode.create("MethodDeclaration", v$3, null, v$4,
157: name, v$5, null, null, null);
158: return v$6;
159: }
160:
161: /**
162: * Create a block.
163: *
164: * @param clazz The clazz.
165: * @param actuals The actuals.
166: * @param result The result.
167: * @return The generic node.
168: */
169: public Node closureExpression(Node clazz, List<Node> actuals,
170: String result) {
171: Node v$1 = GNode.create("Modifiers", false);
172: Node v$2 = GNode.create("Type", clazz, null);
173: Node v$3 = GNode.create("Arguments", actuals.size()).addAll(
174: actuals);
175: Node v$4 = GNode.create("NewClassExpression", null, null,
176: clazz, v$3, null);
177: Node v$5 = GNode.create("Declarator", "jEnv", null, v$4);
178: Node v$6 = GNode.create("Declarators", v$5);
179: Node v$7 = GNode.create("FieldDeclaration", v$1, v$2, v$6);
180: Node v$8 = GNode.create("PrimaryIdentifier", "jEnv");
181: Node v$9 = GNode.create("SelectionExpression", v$8, result);
182: Node v$10 = GNode.create("ReturnStatement", v$9);
183: Node v$11 = GNode.create("Block", v$7, v$10);
184: return v$11;
185: }
186:
187: /**
188: * Create a block.
189: *
190: * @param clazz The clazz.
191: * @param actuals The actuals.
192: * @return The generic node.
193: */
194: public Node closureStatement(Node clazz, List<Node> actuals) {
195: Node v$1 = GNode.create("Modifiers", false);
196: Node v$2 = GNode.create("Type", clazz, null);
197: Node v$3 = GNode.create("Arguments", actuals.size()).addAll(
198: actuals);
199: Node v$4 = GNode.create("NewClassExpression", null, null,
200: clazz, v$3, null);
201: Node v$5 = GNode.create("Declarator", "jEnv", null, v$4);
202: Node v$6 = GNode.create("Declarators", v$5);
203: Node v$7 = GNode.create("FieldDeclaration", v$1, v$2, v$6);
204: Node v$8 = GNode.create("Block", v$7);
205: return v$8;
206: }
207:
208: /**
209: * Create a field declaration.
210: *
211: * @param type The type.
212: * @param name The name.
213: * @return The generic node.
214: */
215: public Node declareField(Node type, String name) {
216: Node v$1 = GNode.create("Modifiers", false);
217: Node v$2 = GNode.create("Type", type, null);
218: Node v$3 = GNode.create("Declarator", name, null, null);
219: Node v$4 = GNode.create("Declarators", v$3);
220: Node v$5 = GNode.create("FieldDeclaration", v$1, v$2, v$4);
221: return v$5;
222: }
223:
224: /**
225: * Create a selection expression.
226: *
227: * @param name The name.
228: * @return The generic node.
229: */
230: public Node getThisDotField(String name) {
231: Node v$1 = GNode.create("ThisExpression", null);
232: Node v$2 = GNode.create("SelectionExpression", v$1, name);
233: return v$2;
234: }
235:
236: /**
237: * Create a method declaration.
238: *
239: * @param returnType The returnType.
240: * @param name The name.
241: * @param envType The envType.
242: * @param expr The expr.
243: * @return The generic node.
244: */
245: public Node javaInCExpression(Node returnType, String name,
246: Node envType, Node expr) {
247: Node v$1 = GNode.create("Modifier", "private");
248: Node v$2 = GNode.create("Modifiers", v$1);
249: Node v$3 = GNode.create("Type", returnType, null);
250: Node v$4 = GNode.create("Modifier", "final");
251: Node v$5 = GNode.create("Modifiers", v$4);
252: Node v$6 = GNode.create("Type", envType, null);
253: Node v$7 = GNode.create("FormalParameter", v$5, v$6, null,
254: "cEnv", null);
255: Node v$8 = GNode.create("FormalParameters", v$7);
256: Node v$9 = GNode.create("QualifiedIdentifier", "Exception");
257: Node v$10 = GNode.create("ThrowsClause", v$9);
258: Node v$11 = GNode.create("ReturnStatement", expr);
259: Node v$12 = GNode.create("Block", v$11);
260: Node v$13 = GNode.create("MethodDeclaration", v$2, null, v$3,
261: name, v$8, null, v$10, v$12);
262: return v$13;
263: }
264:
265: /**
266: * Create a method declaration.
267: *
268: * @param name The name.
269: * @param envType The envType.
270: * @param expr The expr.
271: * @return The generic node.
272: */
273: public Node javaInCExpressionVoid(String name, Node envType,
274: Node expr) {
275: Node v$1 = GNode.create("Modifier", "private");
276: Node v$2 = GNode.create("Modifiers", v$1);
277: Node v$3 = GNode.create("VoidType", false);
278: Node v$4 = GNode.create("Modifier", "final");
279: Node v$5 = GNode.create("Modifiers", v$4);
280: Node v$6 = GNode.create("Type", envType, null);
281: Node v$7 = GNode.create("FormalParameter", v$5, v$6, null,
282: "cEnv", null);
283: Node v$8 = GNode.create("FormalParameters", v$7);
284: Node v$9 = GNode.create("QualifiedIdentifier", "Exception");
285: Node v$10 = GNode.create("ThrowsClause", v$9);
286: Node v$11 = GNode.create("ExpressionStatement", expr);
287: Node v$12 = GNode.create("Block", v$11);
288: Node v$13 = GNode.create("MethodDeclaration", v$2, null, v$3,
289: name, v$8, null, v$10, v$12);
290: return v$13;
291: }
292:
293: /**
294: * Create a method declaration.
295: *
296: * @param name The name.
297: * @param envType The envType.
298: * @param stmt The stmt.
299: * @return The generic node.
300: */
301: public Node javaInCStatement(String name, Node envType, Node stmt) {
302: Node v$1 = GNode.create("Modifier", "private");
303: Node v$2 = GNode.create("Modifiers", v$1);
304: Node v$3 = GNode.create("VoidType", false);
305: Node v$4 = GNode.create("Modifier", "final");
306: Node v$5 = GNode.create("Modifiers", v$4);
307: Node v$6 = GNode.create("Type", envType, null);
308: Node v$7 = GNode.create("FormalParameter", v$5, v$6, null,
309: "cEnv", null);
310: Node v$8 = GNode.create("FormalParameters", v$7);
311: Node v$9 = GNode.create("QualifiedIdentifier", "Exception");
312: Node v$10 = GNode.create("ThrowsClause", v$9);
313: Node v$11 = GNode.create("Block", stmt);
314: Node v$12 = GNode.create("MethodDeclaration", v$2, null, v$3,
315: name, v$8, null, v$10, v$11);
316: return v$12;
317: }
318:
319: /**
320: * Create a block.
321: *
322: * @param name The name.
323: * @return The generic node.
324: */
325: public Node loadLibrary(Node name) {
326: Node v$1 = GNode.create("PrimaryIdentifier", "System");
327: Node v$2 = GNode.create("Arguments", name);
328: Node v$3 = GNode.create("CallExpression", v$1, null,
329: "loadLibrary", v$2);
330: Node v$4 = GNode.create("ExpressionStatement", v$3);
331: Node v$5 = GNode.create("Block", v$4);
332: return v$5;
333: }
334:
335: /**
336: * Create a block.
337: *
338: * @param result The result.
339: * @param value The value.
340: * @param abrupt The abrupt.
341: * @return The generic node.
342: */
343: public Node returnResult(String result, Node value, String abrupt) {
344: Node v$1 = GNode.create("ThisExpression", null);
345: Node v$2 = GNode.create("SelectionExpression", v$1, result);
346: Node v$3 = GNode.create("Expression", v$2, "=", value);
347: Node v$4 = GNode.create("ExpressionStatement", v$3);
348: Node v$5 = GNode.create("ThisExpression", null);
349: Node v$6 = GNode.create("SelectionExpression", v$5, abrupt);
350: Node v$7 = GNode.create("BooleanLiteral", "true");
351: Node v$8 = GNode.create("Expression", v$6, "=", v$7);
352: Node v$9 = GNode.create("ExpressionStatement", v$8);
353: Node v$10 = GNode.create("ReturnStatement", null);
354: Node v$11 = GNode.create("Block", v$4, v$9, v$10);
355: return v$11;
356: }
357:
358: /**
359: * Create a block.
360: *
361: * @param abrupt The abrupt.
362: * @return The generic node.
363: */
364: public Node returnVoid(String abrupt) {
365: Node v$1 = GNode.create("ThisExpression", null);
366: Node v$2 = GNode.create("SelectionExpression", v$1, abrupt);
367: Node v$3 = GNode.create("BooleanLiteral", "true");
368: Node v$4 = GNode.create("Expression", v$2, "=", v$3);
369: Node v$5 = GNode.create("ExpressionStatement", v$4);
370: Node v$6 = GNode.create("ReturnStatement", null);
371: Node v$7 = GNode.create("Block", v$5, v$6);
372: return v$7;
373: }
374:
375: /**
376: * Create an expression.
377: *
378: * @param name The name.
379: * @param value The value.
380: * @return The generic node.
381: */
382: public Node setThisDotField(String name, Node value) {
383: Node v$1 = GNode.create("ThisExpression", null);
384: Node v$2 = GNode.create("SelectionExpression", v$1, name);
385: Node v$3 = GNode.create("Expression", v$2, "=", value);
386: return v$3;
387: }
388:
389: }
|