source: to-imperative/trunk/compiler/refal/org/refal/plus/compiler/rfp_asail_jbc.rf @ 3731

Last change on this file since 3731 was 3731, checked in by yura, 13 years ago
  • Static function Expr.create(Comparable) instead of constructor.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 56.5 KB
Line 
1$use Access Apply Arithm Box Class Compare Convert File JavaMangle List StdIO Table Java;
2
3$use "org.refal.plus.compiler.rfpc";
4$use "org.refal.plus.compiler.rfp_helper";
5$use "org.refal.plus.compiler.rfp_vars";
6$use "org.refal.plus.compiler.NativeJava";
7
8//$use "org.refal.plus.wrappers.org.objectweb.asm.AnnotationVisitor";
9//$use "org.refal.plus.wrappers.org.objectweb.asm.ClassWriter";
10//$use "org.refal.plus.wrappers.org.objectweb.asm.FieldVisitor";
11//$use "org.refal.plus.wrappers.org.objectweb.asm.Label";
12//$use "org.refal.plus.wrappers.org.objectweb.asm.MethodVisitor";
13//$use "org.refal.plus.wrappers.org.objectweb.asm.Opcodes";
14
15// Begin NATIVE
16$func Integer s = s;
17$native Integer = "java.lang.Integer (int)";
18
19$func "IIAVvisit" s s s = ;
20$native "IIAVvisit" = "void org.objectweb.asm.AnnotationVisitor.visit (java.lang.String, java.lang.Object)";
21
22$func "IIAVvisitEnd" s = ;
23$native "IIAVvisitEnd" = "void org.objectweb.asm.AnnotationVisitor.visitEnd ()";
24
25$func "ClassWriter" s = s;
26$native "ClassWriter" = "org.objectweb.asm.ClassWriter (int)";
27
28$func "CWvisit" s s s s s s (e) = ;
29$native "CWvisit" = "void org.objectweb.asm.ClassWriter.visit (int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])";
30
31$func "CWvisitSource" s s s = ;
32$native "CWvisitSource" = "void org.objectweb.asm.ClassWriter.visitSource (java.lang.String, java.lang.String)";
33
34//$func "CWvisitOuterClass" s s s s = ;
35//$native "CWvisitOuterClass" = "void org.objectweb.asm.ClassWriter.visitOuterClass (java.lang.String, java.lang.String, java.lang.String)";
36//
37//$func "CWvisitInnerClass" s s s s s = ;
38//$native "CWvisitInnerClass" = "void org.objectweb.asm.ClassWriter.visitInnerClass (java.lang.String, java.lang.String, java.lang.String, int)";
39
40$func "CWvisitField" s s s s s s = s;
41$native "CWvisitField" = "org.objectweb.asm.FieldVisitor org.objectweb.asm.ClassWriter.visitField (int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)";
42
43$func "CWvisitMethod" s s s s s (e) = s;
44$native "CWvisitMethod" = "org.objectweb.asm.MethodVisitor org.objectweb.asm.ClassWriter.visitMethod (int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])";
45
46$func "CWvisitEnd" s = ;
47$native "CWvisitEnd" = "void org.objectweb.asm.ClassWriter.visitEnd ()";
48
49$func "CWtoByteArray" s = s;
50$native "CWtoByteArray" = "byte[] org.objectweb.asm.ClassWriter.toByteArray ()";
51
52$func IIFVvisitAnnotation s s s = s;
53$native IIFVvisitAnnotation = "org.objectweb.asm.AnnotationVisitor org.objectweb.asm.FieldVisitor.visitAnnotation (java.lang.String, boolean)";
54
55$func IIFVvisitEnd s = ;
56$native IIFVvisitEnd = "void org.objectweb.asm.FieldVisitor.visitEnd ()";
57
58$func "Label" = s;
59$native "Label" = "org.objectweb.asm.Label ()";
60
61$func "IIMVvisitAnnotation" s s s = s;
62$native "IIMVvisitAnnotation" = "org.objectweb.asm.AnnotationVisitor org.objectweb.asm.MethodVisitor.visitAnnotation (java.lang.String, boolean)";
63
64$func "IIMVvisitCode" s = ;
65$native "IIMVvisitCode" = "void org.objectweb.asm.MethodVisitor.visitCode ()";
66
67$func "IIMVvisitFrame" s s s (e) s (e) = ;
68$native "IIMVvisitFrame" = "void org.objectweb.asm.MethodVisitor.visitFrame (int, int, java.lang.Object[], int, java.lang.Object[])";
69
70$func "IIMVvisitInsn" s s = ;
71$native "IIMVvisitInsn" = "void org.objectweb.asm.MethodVisitor.visitInsn (int)";
72
73$func "IIMVvisitIntInsn" s s s = ;
74$native "IIMVvisitIntInsn" = "void org.objectweb.asm.MethodVisitor.visitIntInsn (int, int)";
75
76$func "IIMVvisitVarInsn" s s s = ;
77$native "IIMVvisitVarInsn" = "void org.objectweb.asm.MethodVisitor.visitVarInsn (int, int)";
78
79$func "IIMVvisitTypeInsn" s s s = ;
80$native "IIMVvisitTypeInsn" = "void org.objectweb.asm.MethodVisitor.visitTypeInsn (int, java.lang.String)";
81
82$func "IIMVvisitFieldInsn" s s s s s = ;
83$native "IIMVvisitFieldInsn" = "void org.objectweb.asm.MethodVisitor.visitFieldInsn (int, java.lang.String, java.lang.String, java.lang.String)";
84
85$func "IIMVvisitMethodInsn" s s s s s = ;
86$native "IIMVvisitMethodInsn" = "void org.objectweb.asm.MethodVisitor.visitMethodInsn (int, java.lang.String, java.lang.String, java.lang.String)";
87
88$func "IIMVvisitJumpInsn" s s s = ;
89$native "IIMVvisitJumpInsn" = "void org.objectweb.asm.MethodVisitor.visitJumpInsn (int, org.objectweb.asm.Label)";
90
91$func "IIMVvisitLabel" s s = ;
92$native "IIMVvisitLabel" = "void org.objectweb.asm.MethodVisitor.visitLabel (org.objectweb.asm.Label)";
93
94$func "IIMVvisitLdcInsn" s s = ;
95$native "IIMVvisitLdcInsn" = "void org.objectweb.asm.MethodVisitor.visitLdcInsn (java.lang.Object)";
96
97$func "IIMVvisitIincInsn" s s s = ;
98$native "IIMVvisitIincInsn" = "void org.objectweb.asm.MethodVisitor.visitIincInsn (int, int)";
99
100$func "IIMVvisitTryCatchBlock" s s s s s = ;
101$native "IIMVvisitTryCatchBlock" = "void org.objectweb.asm.MethodVisitor.visitTryCatchBlock (org.objectweb.asm.Label, org.objectweb.asm.Label, org.objectweb.asm.Label, java.lang.String)";
102
103$func "IIMVvisitLocalVariable" s s s s s s s = ;
104$native "IIMVvisitLocalVariable" = "void org.objectweb.asm.MethodVisitor.visitLocalVariable (java.lang.String, java.lang.String, java.lang.String, org.objectweb.asm.Label, org.objectweb.asm.Label, int)";
105
106$func "IIMVvisitLineNumber" s s s = ;
107$native "IIMVvisitLineNumber" = "void org.objectweb.asm.MethodVisitor.visitLineNumber (int, org.objectweb.asm.Label)";
108
109$func "IIMVvisitMaxs" s s s = ;
110$native "IIMVvisitMaxs" = "void org.objectweb.asm.MethodVisitor.visitMaxs (int, int)";
111
112$func "IIMVvisitEnd" s = ;
113$native "IIMVvisitEnd" = "void org.objectweb.asm.MethodVisitor.visitEnd ()";
114
115
116$func COMPUTE_MAXS = s;
117$native COMPUTE_MAXS = "static int org.objectweb.asm.ClassWriter.COMPUTE_MAXS";
118
119$func V1_5 = s;
120$native V1_5 = "static int org.objectweb.asm.Opcodes.V1_5";
121
122$func ACC_PUBLIC = s;
123$native ACC_PUBLIC = "static int org.objectweb.asm.Opcodes.ACC_PUBLIC";
124
125$func ACC_PRIVATE = s;
126$native ACC_PRIVATE = "static int org.objectweb.asm.Opcodes.ACC_PRIVATE";
127
128$func ACC_PROTECTED = s;
129$native ACC_PROTECTED = "static int org.objectweb.asm.Opcodes.ACC_PROTECTED";
130
131$func ACC_STATIC = s;
132$native ACC_STATIC = "static int org.objectweb.asm.Opcodes.ACC_STATIC";
133
134$func ACC_FINAL = s;
135$native ACC_FINAL = "static int org.objectweb.asm.Opcodes.ACC_FINAL";
136
137$func ACC_SUPER = s;
138$native ACC_SUPER = "static int org.objectweb.asm.Opcodes.ACC_SUPER";
139
140$func ACC_SYNCHRONIZED = s;
141$native ACC_SYNCHRONIZED = "static int org.objectweb.asm.Opcodes.ACC_SYNCHRONIZED";
142
143$func ACC_VOLATILE = s;
144$native ACC_VOLATILE = "static int org.objectweb.asm.Opcodes.ACC_VOLATILE";
145
146$func ACC_BRIDGE = s;
147$native ACC_BRIDGE = "static int org.objectweb.asm.Opcodes.ACC_BRIDGE";
148
149$func ACC_VARARGS = s;
150$native ACC_VARARGS = "static int org.objectweb.asm.Opcodes.ACC_VARARGS";
151
152$func ACC_TRANSIENT = s;
153$native ACC_TRANSIENT = "static int org.objectweb.asm.Opcodes.ACC_TRANSIENT";
154
155$func ACC_NATIVE = s;
156$native ACC_NATIVE = "static int org.objectweb.asm.Opcodes.ACC_NATIVE";
157
158$func ACC_INTERFACE = s;
159$native ACC_INTERFACE = "static int org.objectweb.asm.Opcodes.ACC_INTERFACE";
160
161$func ACC_ABSTRACT = s;
162$native ACC_ABSTRACT = "static int org.objectweb.asm.Opcodes.ACC_ABSTRACT";
163
164$func ACC_STRICT = s;
165$native ACC_STRICT = "static int org.objectweb.asm.Opcodes.ACC_STRICT";
166
167$func ACC_SYNTHETIC = s;
168$native ACC_SYNTHETIC = "static int org.objectweb.asm.Opcodes.ACC_SYNTHETIC";
169
170$func ACC_ANNOTATION = s;
171$native ACC_ANNOTATION = "static int org.objectweb.asm.Opcodes.ACC_ANNOTATION";
172
173$func ACC_ENUM = s;
174$native ACC_ENUM = "static int org.objectweb.asm.Opcodes.ACC_ENUM";
175
176$func ACC_DEPRECATED = s;
177$native ACC_DEPRECATED = "static int org.objectweb.asm.Opcodes.ACC_DEPRECATED";
178
179$func T_BOOLEAN = s;
180$native T_BOOLEAN = "static int org.objectweb.asm.Opcodes.T_BOOLEAN";
181
182$func T_CHAR = s;
183$native T_CHAR = "static int org.objectweb.asm.Opcodes.T_CHAR";
184
185$func T_FLOAT = s;
186$native T_FLOAT = "static int org.objectweb.asm.Opcodes.T_FLOAT";
187
188$func T_DOUBLE = s;
189$native T_DOUBLE = "static int org.objectweb.asm.Opcodes.T_DOUBLE";
190
191$func T_BYTE = s;
192$native T_BYTE = "static int org.objectweb.asm.Opcodes.T_BYTE";
193
194$func T_SHORT = s;
195$native T_SHORT = "static int org.objectweb.asm.Opcodes.T_SHORT";
196
197$func T_INT = s;
198$native T_INT = "static int org.objectweb.asm.Opcodes.T_INT";
199
200$func T_LONG = s;
201$native T_LONG = "static int org.objectweb.asm.Opcodes.T_LONG";
202
203$func F_NEW = s;
204$native F_NEW = "static int org.objectweb.asm.Opcodes.F_NEW";
205
206$func F_FULL = s;
207$native F_FULL = "static int org.objectweb.asm.Opcodes.F_FULL";
208
209$func F_APPEND = s;
210$native F_APPEND = "static int org.objectweb.asm.Opcodes.F_APPEND";
211
212$func F_CHOP = s;
213$native F_CHOP = "static int org.objectweb.asm.Opcodes.F_CHOP";
214
215$func F_SAME = s;
216$native F_SAME = "static int org.objectweb.asm.Opcodes.F_SAME";
217
218$func F_SAME1 = s;
219$native F_SAME1 = "static int org.objectweb.asm.Opcodes.F_SAME1";
220
221$func NOP = s;
222$native NOP = "static int org.objectweb.asm.Opcodes.NOP";
223
224$func ACONST_NULL = s;
225$native ACONST_NULL = "static int org.objectweb.asm.Opcodes.ACONST_NULL";
226
227$func ICONST_M1 = s;
228$native ICONST_M1 = "static int org.objectweb.asm.Opcodes.ICONST_M1";
229
230$func ICONST_0 = s;
231$native ICONST_0 = "static int org.objectweb.asm.Opcodes.ICONST_0";
232
233$func ICONST_1 = s;
234$native ICONST_1 = "static int org.objectweb.asm.Opcodes.ICONST_1";
235
236$func ICONST_2 = s;
237$native ICONST_2 = "static int org.objectweb.asm.Opcodes.ICONST_2";
238
239$func ICONST_3 = s;
240$native ICONST_3 = "static int org.objectweb.asm.Opcodes.ICONST_3";
241
242$func ICONST_4 = s;
243$native ICONST_4 = "static int org.objectweb.asm.Opcodes.ICONST_4";
244
245$func ICONST_5 = s;
246$native ICONST_5 = "static int org.objectweb.asm.Opcodes.ICONST_5";
247
248$func LCONST_0 = s;
249$native LCONST_0 = "static int org.objectweb.asm.Opcodes.LCONST_0";
250
251$func LCONST_1 = s;
252$native LCONST_1 = "static int org.objectweb.asm.Opcodes.LCONST_1";
253
254$func FCONST_0 = s;
255$native FCONST_0 = "static int org.objectweb.asm.Opcodes.FCONST_0";
256
257$func FCONST_1 = s;
258$native FCONST_1 = "static int org.objectweb.asm.Opcodes.FCONST_1";
259
260$func FCONST_2 = s;
261$native FCONST_2 = "static int org.objectweb.asm.Opcodes.FCONST_2";
262
263$func DCONST_0 = s;
264$native DCONST_0 = "static int org.objectweb.asm.Opcodes.DCONST_0";
265
266$func DCONST_1 = s;
267$native DCONST_1 = "static int org.objectweb.asm.Opcodes.DCONST_1";
268
269$func BIPUSH = s;
270$native BIPUSH = "static int org.objectweb.asm.Opcodes.BIPUSH";
271
272$func SIPUSH = s;
273$native SIPUSH = "static int org.objectweb.asm.Opcodes.SIPUSH";
274
275$func LDC = s;
276$native LDC = "static int org.objectweb.asm.Opcodes.LDC";
277
278$func ILOAD = s;
279$native ILOAD = "static int org.objectweb.asm.Opcodes.ILOAD";
280
281$func LLOAD = s;
282$native LLOAD = "static int org.objectweb.asm.Opcodes.LLOAD";
283
284$func FLOAD = s;
285$native FLOAD = "static int org.objectweb.asm.Opcodes.FLOAD";
286
287$func DLOAD = s;
288$native DLOAD = "static int org.objectweb.asm.Opcodes.DLOAD";
289
290$func ALOAD = s;
291$native ALOAD = "static int org.objectweb.asm.Opcodes.ALOAD";
292
293$func IALOAD = s;
294$native IALOAD = "static int org.objectweb.asm.Opcodes.IALOAD";
295
296$func LALOAD = s;
297$native LALOAD = "static int org.objectweb.asm.Opcodes.LALOAD";
298
299$func FALOAD = s;
300$native FALOAD = "static int org.objectweb.asm.Opcodes.FALOAD";
301
302$func DALOAD = s;
303$native DALOAD = "static int org.objectweb.asm.Opcodes.DALOAD";
304
305$func AALOAD = s;
306$native AALOAD = "static int org.objectweb.asm.Opcodes.AALOAD";
307
308$func BALOAD = s;
309$native BALOAD = "static int org.objectweb.asm.Opcodes.BALOAD";
310
311$func CALOAD = s;
312$native CALOAD = "static int org.objectweb.asm.Opcodes.CALOAD";
313
314$func SALOAD = s;
315$native SALOAD = "static int org.objectweb.asm.Opcodes.SALOAD";
316
317$func ISTORE = s;
318$native ISTORE = "static int org.objectweb.asm.Opcodes.ISTORE";
319
320$func LSTORE = s;
321$native LSTORE = "static int org.objectweb.asm.Opcodes.LSTORE";
322
323$func FSTORE = s;
324$native FSTORE = "static int org.objectweb.asm.Opcodes.FSTORE";
325
326$func DSTORE = s;
327$native DSTORE = "static int org.objectweb.asm.Opcodes.DSTORE";
328
329$func ASTORE = s;
330$native ASTORE = "static int org.objectweb.asm.Opcodes.ASTORE";
331
332$func IASTORE = s;
333$native IASTORE = "static int org.objectweb.asm.Opcodes.IASTORE";
334
335$func LASTORE = s;
336$native LASTORE = "static int org.objectweb.asm.Opcodes.LASTORE";
337
338$func FASTORE = s;
339$native FASTORE = "static int org.objectweb.asm.Opcodes.FASTORE";
340
341$func DASTORE = s;
342$native DASTORE = "static int org.objectweb.asm.Opcodes.DASTORE";
343
344$func AASTORE = s;
345$native AASTORE = "static int org.objectweb.asm.Opcodes.AASTORE";
346
347$func BASTORE = s;
348$native BASTORE = "static int org.objectweb.asm.Opcodes.BASTORE";
349
350$func CASTORE = s;
351$native CASTORE = "static int org.objectweb.asm.Opcodes.CASTORE";
352
353$func SASTORE = s;
354$native SASTORE = "static int org.objectweb.asm.Opcodes.SASTORE";
355
356$func POP = s;
357$native POP = "static int org.objectweb.asm.Opcodes.POP";
358
359$func POP2 = s;
360$native POP2 = "static int org.objectweb.asm.Opcodes.POP2";
361
362$func DUP = s;
363$native DUP = "static int org.objectweb.asm.Opcodes.DUP";
364
365$func DUP_X1 = s;
366$native DUP_X1 = "static int org.objectweb.asm.Opcodes.DUP_X1";
367
368$func DUP_X2 = s;
369$native DUP_X2 = "static int org.objectweb.asm.Opcodes.DUP_X2";
370
371$func DUP2 = s;
372$native DUP2 = "static int org.objectweb.asm.Opcodes.DUP2";
373
374$func DUP2_X1 = s;
375$native DUP2_X1 = "static int org.objectweb.asm.Opcodes.DUP2_X1";
376
377$func DUP2_X2 = s;
378$native DUP2_X2 = "static int org.objectweb.asm.Opcodes.DUP2_X2";
379
380$func SWAP = s;
381$native SWAP = "static int org.objectweb.asm.Opcodes.SWAP";
382
383$func IADD = s;
384$native IADD = "static int org.objectweb.asm.Opcodes.IADD";
385
386$func LADD = s;
387$native LADD = "static int org.objectweb.asm.Opcodes.LADD";
388
389$func FADD = s;
390$native FADD = "static int org.objectweb.asm.Opcodes.FADD";
391
392$func DADD = s;
393$native DADD = "static int org.objectweb.asm.Opcodes.DADD";
394
395$func ISUB = s;
396$native ISUB = "static int org.objectweb.asm.Opcodes.ISUB";
397
398$func LSUB = s;
399$native LSUB = "static int org.objectweb.asm.Opcodes.LSUB";
400
401$func FSUB = s;
402$native FSUB = "static int org.objectweb.asm.Opcodes.FSUB";
403
404$func DSUB = s;
405$native DSUB = "static int org.objectweb.asm.Opcodes.DSUB";
406
407$func IMUL = s;
408$native IMUL = "static int org.objectweb.asm.Opcodes.IMUL";
409
410$func LMUL = s;
411$native LMUL = "static int org.objectweb.asm.Opcodes.LMUL";
412
413$func FMUL = s;
414$native FMUL = "static int org.objectweb.asm.Opcodes.FMUL";
415
416$func DMUL = s;
417$native DMUL = "static int org.objectweb.asm.Opcodes.DMUL";
418
419$func IDIV = s;
420$native IDIV = "static int org.objectweb.asm.Opcodes.IDIV";
421
422$func LDIV = s;
423$native LDIV = "static int org.objectweb.asm.Opcodes.LDIV";
424
425$func FDIV = s;
426$native FDIV = "static int org.objectweb.asm.Opcodes.FDIV";
427
428$func DDIV = s;
429$native DDIV = "static int org.objectweb.asm.Opcodes.DDIV";
430
431$func IREM = s;
432$native IREM = "static int org.objectweb.asm.Opcodes.IREM";
433
434$func LREM = s;
435$native LREM = "static int org.objectweb.asm.Opcodes.LREM";
436
437$func FREM = s;
438$native FREM = "static int org.objectweb.asm.Opcodes.FREM";
439
440$func DREM = s;
441$native DREM = "static int org.objectweb.asm.Opcodes.DREM";
442
443$func INEG = s;
444$native INEG = "static int org.objectweb.asm.Opcodes.INEG";
445
446$func LNEG = s;
447$native LNEG = "static int org.objectweb.asm.Opcodes.LNEG";
448
449$func FNEG = s;
450$native FNEG = "static int org.objectweb.asm.Opcodes.FNEG";
451
452$func DNEG = s;
453$native DNEG = "static int org.objectweb.asm.Opcodes.DNEG";
454
455$func ISHL = s;
456$native ISHL = "static int org.objectweb.asm.Opcodes.ISHL";
457
458$func LSHL = s;
459$native LSHL = "static int org.objectweb.asm.Opcodes.LSHL";
460
461$func ISHR = s;
462$native ISHR = "static int org.objectweb.asm.Opcodes.ISHR";
463
464$func LSHR = s;
465$native LSHR = "static int org.objectweb.asm.Opcodes.LSHR";
466
467$func IUSHR = s;
468$native IUSHR = "static int org.objectweb.asm.Opcodes.IUSHR";
469
470$func LUSHR = s;
471$native LUSHR = "static int org.objectweb.asm.Opcodes.LUSHR";
472
473$func IAND = s;
474$native IAND = "static int org.objectweb.asm.Opcodes.IAND";
475
476$func LAND = s;
477$native LAND = "static int org.objectweb.asm.Opcodes.LAND";
478
479$func IOR = s;
480$native IOR = "static int org.objectweb.asm.Opcodes.IOR";
481
482$func LOR = s;
483$native LOR = "static int org.objectweb.asm.Opcodes.LOR";
484
485$func IXOR = s;
486$native IXOR = "static int org.objectweb.asm.Opcodes.IXOR";
487
488$func LXOR = s;
489$native LXOR = "static int org.objectweb.asm.Opcodes.LXOR";
490
491$func IINC = s;
492$native IINC = "static int org.objectweb.asm.Opcodes.IINC";
493
494$func I2L = s;
495$native I2L = "static int org.objectweb.asm.Opcodes.I2L";
496
497$func I2F = s;
498$native I2F = "static int org.objectweb.asm.Opcodes.I2F";
499
500$func I2D = s;
501$native I2D = "static int org.objectweb.asm.Opcodes.I2D";
502
503$func L2I = s;
504$native L2I = "static int org.objectweb.asm.Opcodes.L2I";
505
506$func L2F = s;
507$native L2F = "static int org.objectweb.asm.Opcodes.L2F";
508
509$func L2D = s;
510$native L2D = "static int org.objectweb.asm.Opcodes.L2D";
511
512$func F2I = s;
513$native F2I = "static int org.objectweb.asm.Opcodes.F2I";
514
515$func F2L = s;
516$native F2L = "static int org.objectweb.asm.Opcodes.F2L";
517
518$func F2D = s;
519$native F2D = "static int org.objectweb.asm.Opcodes.F2D";
520
521$func D2I = s;
522$native D2I = "static int org.objectweb.asm.Opcodes.D2I";
523
524$func D2L = s;
525$native D2L = "static int org.objectweb.asm.Opcodes.D2L";
526
527$func D2F = s;
528$native D2F = "static int org.objectweb.asm.Opcodes.D2F";
529
530$func I2B = s;
531$native I2B = "static int org.objectweb.asm.Opcodes.I2B";
532
533$func I2C = s;
534$native I2C = "static int org.objectweb.asm.Opcodes.I2C";
535
536$func I2S = s;
537$native I2S = "static int org.objectweb.asm.Opcodes.I2S";
538
539$func LCMP = s;
540$native LCMP = "static int org.objectweb.asm.Opcodes.LCMP";
541
542$func FCMPL = s;
543$native FCMPL = "static int org.objectweb.asm.Opcodes.FCMPL";
544
545$func FCMPG = s;
546$native FCMPG = "static int org.objectweb.asm.Opcodes.FCMPG";
547
548$func DCMPL = s;
549$native DCMPL = "static int org.objectweb.asm.Opcodes.DCMPL";
550
551$func DCMPG = s;
552$native DCMPG = "static int org.objectweb.asm.Opcodes.DCMPG";
553
554$func IFEQ = s;
555$native IFEQ = "static int org.objectweb.asm.Opcodes.IFEQ";
556
557$func IFNE = s;
558$native IFNE = "static int org.objectweb.asm.Opcodes.IFNE";
559
560$func IFLT = s;
561$native IFLT = "static int org.objectweb.asm.Opcodes.IFLT";
562
563$func IFGE = s;
564$native IFGE = "static int org.objectweb.asm.Opcodes.IFGE";
565
566$func IFGT = s;
567$native IFGT = "static int org.objectweb.asm.Opcodes.IFGT";
568
569$func IFLE = s;
570$native IFLE = "static int org.objectweb.asm.Opcodes.IFLE";
571
572$func IF_ICMPEQ = s;
573$native IF_ICMPEQ = "static int org.objectweb.asm.Opcodes.IF_ICMPEQ";
574
575$func IF_ICMPNE = s;
576$native IF_ICMPNE = "static int org.objectweb.asm.Opcodes.IF_ICMPNE";
577
578$func IF_ICMPLT = s;
579$native IF_ICMPLT = "static int org.objectweb.asm.Opcodes.IF_ICMPLT";
580
581$func IF_ICMPGE = s;
582$native IF_ICMPGE = "static int org.objectweb.asm.Opcodes.IF_ICMPGE";
583
584$func IF_ICMPGT = s;
585$native IF_ICMPGT = "static int org.objectweb.asm.Opcodes.IF_ICMPGT";
586
587$func IF_ICMPLE = s;
588$native IF_ICMPLE = "static int org.objectweb.asm.Opcodes.IF_ICMPLE";
589
590$func IF_ACMPEQ = s;
591$native IF_ACMPEQ = "static int org.objectweb.asm.Opcodes.IF_ACMPEQ";
592
593$func IF_ACMPNE = s;
594$native IF_ACMPNE = "static int org.objectweb.asm.Opcodes.IF_ACMPNE";
595
596$func GOTO = s;
597$native GOTO = "static int org.objectweb.asm.Opcodes.GOTO";
598
599$func JSR = s;
600$native JSR = "static int org.objectweb.asm.Opcodes.JSR";
601
602$func RET = s;
603$native RET = "static int org.objectweb.asm.Opcodes.RET";
604
605$func TABLESWITCH = s;
606$native TABLESWITCH = "static int org.objectweb.asm.Opcodes.TABLESWITCH";
607
608$func LOOKUPSWITCH = s;
609$native LOOKUPSWITCH = "static int org.objectweb.asm.Opcodes.LOOKUPSWITCH";
610
611$func IRETURN = s;
612$native IRETURN = "static int org.objectweb.asm.Opcodes.IRETURN";
613
614$func LRETURN = s;
615$native LRETURN = "static int org.objectweb.asm.Opcodes.LRETURN";
616
617$func FRETURN = s;
618$native FRETURN = "static int org.objectweb.asm.Opcodes.FRETURN";
619
620$func DRETURN = s;
621$native DRETURN = "static int org.objectweb.asm.Opcodes.DRETURN";
622
623$func ARETURN = s;
624$native ARETURN = "static int org.objectweb.asm.Opcodes.ARETURN";
625
626$func RETURN = s;
627$native RETURN = "static int org.objectweb.asm.Opcodes.RETURN";
628
629$func GETSTATIC = s;
630$native GETSTATIC = "static int org.objectweb.asm.Opcodes.GETSTATIC";
631
632$func PUTSTATIC = s;
633$native PUTSTATIC = "static int org.objectweb.asm.Opcodes.PUTSTATIC";
634
635$func GETFIELD = s;
636$native GETFIELD = "static int org.objectweb.asm.Opcodes.GETFIELD";
637
638$func PUTFIELD = s;
639$native PUTFIELD = "static int org.objectweb.asm.Opcodes.PUTFIELD";
640
641$func INVOKEVIRTUAL = s;
642$native INVOKEVIRTUAL = "static int org.objectweb.asm.Opcodes.INVOKEVIRTUAL";
643
644$func INVOKESPECIAL = s;
645$native INVOKESPECIAL = "static int org.objectweb.asm.Opcodes.INVOKESPECIAL";
646
647$func INVOKESTATIC = s;
648$native INVOKESTATIC = "static int org.objectweb.asm.Opcodes.INVOKESTATIC";
649
650$func INVOKEINTERFACE = s;
651$native INVOKEINTERFACE = "static int org.objectweb.asm.Opcodes.INVOKEINTERFACE";
652
653$func NEW = s;
654$native NEW = "static int org.objectweb.asm.Opcodes.NEW";
655
656$func NEWARRAY = s;
657$native NEWARRAY = "static int org.objectweb.asm.Opcodes.NEWARRAY";
658
659$func ANEWARRAY = s;
660$native ANEWARRAY = "static int org.objectweb.asm.Opcodes.ANEWARRAY";
661
662$func ARRAYLENGTH = s;
663$native ARRAYLENGTH = "static int org.objectweb.asm.Opcodes.ARRAYLENGTH";
664
665$func ATHROW = s;
666$native ATHROW = "static int org.objectweb.asm.Opcodes.ATHROW";
667
668$func CHECKCAST = s;
669$native CHECKCAST = "static int org.objectweb.asm.Opcodes.CHECKCAST";
670
671$func INSTANCEOF = s;
672$native INSTANCEOF = "static int org.objectweb.asm.Opcodes.INSTANCEOF";
673
674$func MONITORENTER = s;
675$native MONITORENTER = "static int org.objectweb.asm.Opcodes.MONITORENTER";
676
677$func MONITOREXIT = s;
678$native MONITOREXIT = "static int org.objectweb.asm.Opcodes.MONITOREXIT";
679
680$func MULTIANEWARRAY = s;
681$native MULTIANEWARRAY = "static int org.objectweb.asm.Opcodes.MULTIANEWARRAY";
682
683$func IFNULL = s;
684$native IFNULL = "static int org.objectweb.asm.Opcodes.IFNULL";
685
686$func IFNONNULL = s;
687$native IFNONNULL = "static int org.objectweb.asm.Opcodes.IFNONNULL";
688
689
690// End NATIVE
691
692$box Module_Name;
693$box Refal_Module_Name;
694$box Class_Name;
695
696$box Entry;
697$box EntryName;
698
699$box FuncName;
700
701$func Module_To_JBC e.module = ;
702
703$func Module_Item_To_JBC t.item = ;
704
705$func Body_To_JBC e.body = ;
706
707$func Body_Item_To_JBC t.item = ;
708
709$func Expr_Ref_To_JBC e.ASAIL_Expr_Ref = ;
710
711$func Expr_Int_To_JBC e.ASAIL_Expr_Int = ;
712
713$func Step_To_JBC e.step_operators = ;
714
715$func Const_Expr_To_JBC e.ASAIL_const_expr = ;
716
717$func Var_To_JBC t.var = ;
718
719$func Cond_To_JBC t.cond = s.if;
720
721$func Infix_To_JBC s.func_for_converting_args_to_java s.op e.args = ;
722
723$func Access_Mode s.linkage = s.jbc_access_mode;
724$func WrapGen s.linkage s.tag t.qname (e.in) (e.out) e.native = ;
725
726$box Objects;
727$box Constants;
728$box Func_Refs;
729
730$func GetJBCName t.name = s.jbcName;
731
732GetJBCName  {
733  s.name = s.name;
734  t.name = <ToWord <Rfp2Java t.name>>;
735};
736
737$func GetJBCQName e.moduleName t.name = s.jbcModuleName s.jbcName;
738
739GetJBCQName e.moduleName t.name =
740  <ToWord <Intersperse ('/') e.moduleName>> <GetJBCName t.name>;
741
742$box MVbox;
743$func MV = s;
744MV, <Get &MVbox> : s.mv = s.mv;
745
746$box CWbox;
747$func CW = s;
748CW, <Get &CWbox> : s.cv = s.cv;
749
750RFP_ASAIL_To_JBC (MODULE (e.moduleName) e.module) =
751  <Store &Objects>,
752  <Store &Constants>,
753  <Store &Func_Refs>,
754  {
755    <Store &Entry <Lookup &RFP_Options ENTRIES>>;
756    <Store &Entry (e.moduleName Main)>;
757  },
758  <Store &EntryName /*empty*/>,
759  <Store &Module_Name e.moduleName>,
760  <ToWord <Intersperse ('.') e.moduleName>> :: s.refal_mod_name,
761  <Store &Refal_Module_Name s.refal_mod_name>,
762  <ToWord <Intersperse ('/') e.moduleName>> :: s.class_name,
763  <Store &Class_Name s.class_name>,
764  <Store &CWbox <ClassWriter <COMPUTE_MAXS>>>,
765  <CWvisit <CW> <V1_5> <Add <ACC_PUBLIC> <ACC_SUPER>> s.class_name <Null> "java/lang/Object" ()>,
766        <CWvisitSource <CW> <ToWord <R 0 e.moduleName> '.rf'> <Null>>,
767  <Module_To_JBC e.module>,
768  {
769    <Get &EntryName> : s.name =
770      /*<ASAIL-To-JBC-Temp <CW> e.module> : e,
771      ()
772          ('public static void main (java.lang.String[] args) {' (
773            ('RefalRuntime.setArgs ("'e.java-module-name'", args);')
774      ('try {' (v.name' (new Result ());') '}')
775            ('catch (RefalException e) {' (
776              ('java.lang.System.out.println ("$error: " + e);')
777              ('java.lang.System.exit (100);')
778            )'}')
779          )'}');;
780      } :: e.entry,*/
781      <Store &MVbox <CWvisitMethod <CW> <Add <Add <ACC_PUBLIC> <ACC_STATIC>> <ACC_SYNTHETIC>> "main" "([Ljava/lang/String;)V" <Null> ()>>,
782      <IIMVvisitLdcInsn <MV> s.refal_mod_name>,
783      <IIMVvisitVarInsn <MV> <ALOAD> 0>,
784      <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/RefalRuntime" "setArgs" "(Ljava/lang/String;[Ljava/lang/String;)V">,
785      {
786          <IIMVvisitTypeInsn <MV> <NEW> "org/refal/plus/Result">,
787          <IIMVvisitInsn <MV> <DUP>>,
788          <IIMVvisitMethodInsn <MV> <INVOKESPECIAL> "org/refal/plus/Result" "<init>" "()V">,
789          <IIMVvisitMethodInsn <MV> <INVOKESTATIC> s.class_name s.name "(Lorg/refal/plus/Result;)V">,
790          <IIMVvisitInsn <MV> <RETURN>>,
791          <IIMVvisitMaxs <MV> 0 0>,
792          <IIMVvisitEnd <MV>>;
793      };;
794  },
795  {
796    <Store &MVbox <CWvisitMethod <CW> <ACC_SYNTHETIC> "<init>" "()V" <Null> ()>>,
797      <IIMVvisitVarInsn <MV> <ALOAD> 0>,
798      <IIMVvisitMethodInsn <MV> <INVOKESPECIAL> "java/lang/Object" "<init>" "()V">,
799      <IIMVvisitInsn <MV> <RETURN>>,
800      <IIMVvisitMaxs <MV> 0 0>,
801      <IIMVvisitEnd <MV>>;
802  },
803  <Store &MVbox <CWvisitMethod <CW> <Add <ACC_STATIC> <ACC_SYNTHETIC>> "<clinit>" "()V" <Null> ()>>,
804  {
805    <Get &Objects> : e (s.tag s.name) e,
806      { <ToChars s.tag> : s1 e2, <ToWord "new" s1 <ToLower e2>>; } :: s.objectType,
807      <IIMVvisitLdcInsn <MV> s.name>,
808      <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Symbol" s.objectType "(Ljava/lang/String;)Ljava/lang/Comparable;">,
809      <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Expr" "create" "(Ljava/lang/Comparable;)Lorg/refal/plus/Expr;">,
810      <IIMVvisitFieldInsn <MV> <PUTSTATIC> s.class_name s.name "Lorg/refal/plus/Expr;">,
811      $fail;;
812  },
813  {
814    <Get &Constants> : e (s.name e.expr) e,
815      <Const_Expr_To_JBC e.expr>,
816      <IIMVvisitFieldInsn <MV> <PUTSTATIC> s.class_name s.name "Lorg/refal/plus/Expr;">,
817      $fail;;
818  },
819  <IIMVvisitInsn <MV> <RETURN>>,
820  <IIMVvisitMaxs <MV> 0 0>,
821  <IIMVvisitEnd <MV>>,
822  //{
823  //  <? &Func-Refs> : e (s.cl-name s.mod-name s.func-name) e,
824  //    <CWvisitInnerClass <CW> s.cl-name <Null> <Null> <ACC_STATIC>>,
825  //    $fail;;
826  //},
827  <CWvisitEnd <CW>>,
828  <Box (<CWtoByteArray <CW>> e.moduleName)> :: s.res,
829  {
830    <Get &Func_Refs> : e (s.cl_name s.mod_name s.func_name s.type) e,
831      <ClassWriter <COMPUTE_MAXS>> :: s.cw,
832      <CWvisit s.cw <V1_5> <ACC_FINAL> <ToWord s.class_name '$' s.cl_name> <Null> "java/lang/Object" ("org/refal/plus/Func")>,
833      <CWvisitMethod s.cw <ACC_SYNTHETIC> "<init>" "()V" <Null> ()> :: s.mv,
834      <IIMVvisitVarInsn s.mv <ALOAD> 0>,
835      <IIMVvisitMethodInsn s.mv <INVOKESPECIAL> "java/lang/Object" "<init>" "()V">,
836      <IIMVvisitInsn s.mv <RETURN>>,
837      <IIMVvisitMaxs s.mv 0 0>,
838      <IIMVvisitEnd s.mv>,
839      <CWvisitMethod s.cw <Add <ACC_PUBLIC> <ACC_SYNTHETIC>> "eval" "(Lorg/refal/plus/Expr;Lorg/refal/plus/Result;)Z" <Null> ("org/refal/plus/RefalException")> :: s.mv,
840      <IIMVvisitVarInsn s.mv <ALOAD> 1>,
841      <IIMVvisitVarInsn s.mv <ALOAD> 2>,
842      s.type : {
843        "FUNC?" =
844          <IIMVvisitMethodInsn s.mv <INVOKESTATIC> s.mod_name s.func_name "(Lorg/refal/plus/Expr;Lorg/refal/plus/Result;)Z">,
845          <IIMVvisitInsn s.mv <IRETURN>>;
846        s.FUNC_or_TFUNC  =
847          <IIMVvisitMethodInsn s.mv <INVOKESTATIC> s.mod_name s.func_name "(Lorg/refal/plus/Expr;Lorg/refal/plus/Result;)V">,
848          <IIMVvisitInsn s.mv <ICONST_1>> <IIMVvisitInsn s.mv <IRETURN>>;
849      },
850      <IIMVvisitMaxs s.mv 0 0>,
851      <IIMVvisitEnd s.mv>,
852      <CWvisitEnd s.cw>,
853      <Put s.res (<CWtoByteArray s.cw>
854        <Middle 0 1 e.moduleName> <ToWord <R 0 e.moduleName> '$' s.cl_name>)>,
855      $fail;;
856  },
857  <Get s.res>;
858
859$box Block_Tables;
860
861$func Init_Block_Table = ;
862$func Push_Block_Table = ;
863$func Pop_Block_Table = ;
864$func Get_Block_Table = s.block_table;
865
866Init_Block_Table =
867  <Table> :: s.block_table,
868  <Bind s.block_table ("VAR-INDEX") (0)>,
869  <Store &Block_Tables s.block_table>;
870
871Push_Block_Table =
872  <Get &Block_Tables> : e.block_tables,
873  e.block_tables : e s.block_table,
874  <TableCopy s.block_table> :: s.copy_block_table,
875  <Label> :: s.start,
876  <IIMVvisitLabel <MV> s.start>,
877  <Bind s.copy_block_table (START) (s.start)>,
878  <Store &Block_Tables e.block_tables s.copy_block_table>;
879
880Pop_Block_Table =
881  <Get &Block_Tables> : e.block_tables s.block_table1 s.block_table2,
882  <Lookup s.block_table2 "VAR-INDEX"> : s.i,
883  <Bind s.block_table1 ("VAR-INDEX") (s.i)>,
884  <Store &Block_Tables e.block_tables s.block_table1>,
885  <Label> :: s.stop,
886  <IIMVvisitLabel <MV> s.stop>,
887  <Lookup s.block_table2 START> : s.start,
888  {
889    <Entries s.block_table2> : e ((VAR t.var) (s.type s.ind)) e,
890      # <IsInTable s.block_table1 VAR t.var>,
891      t.var : \{
892        (SVAR (e.name)) = <ToWord 's_' e.name>;
893        (TVAR (e.name)) = <ToWord 't_' e.name>;
894        (VVAR (e.name)) = <ToWord 'v_' e.name>;
895        (EVAR (e.name)) = <ToWord 'e_' e.name>;
896      } :: s.name,
897      # \{ <ToChars s.name> : e '$' e; },
898      s.type : \{
899        Expr = <IIMVvisitLocalVariable <MV> s.name "Lorg/refal/plus/Expr;" <Null> s.start s.stop sind>;
900        Result = <IIMVvisitLocalVariable <MV> s.name "Lorg/refal/plus/Result;" <Null> s.start s.stop sind>;
901      },
902      $fail;
903    ;
904  };
905
906Get_Block_Table =
907  <Get &Block_Tables> : e s.block_table,
908  s.block_table;
909
910$func Bind_Vars s.type e.vars = ;
911$func Bind_Var s.type t.var = s.i;
912$func Lookup_Var t.var = s.type s.i;
913$func Bind_Iter_Var e.expr t.var1 t.var2 = s.i;
914$func Lookup_Iter_Var e.expr = s.i s.i1 s.i2;
915$func Bind_TMP_Var t.var = s.i;
916$func Lookup_TMP_Var t.var = s.i;
917
918Bind_Vars s.type e.vars =
919  {
920    e.vars : e t.var e,
921      <Bind_Var s.type t.var> : e,
922      $fail;;
923  };
924
925Bind_Var s.type t.var =
926  <Lookup <Get_Block_Table> "VAR-INDEX"> : s.i,
927  <Bind <Get_Block_Table> ("VAR-INDEX") (<Add s.i 1>)>,
928  <Bind <Get_Block_Table> (VAR t.var) (s.type s.i)>,
929  s.i;
930
931Lookup_Var t.var = <Lookup <Get_Block_Table> VAR t.var> : s.type s.i = s.type s.i;
932
933Bind_Iter_Var e.expr t.var1 t.var2 =
934  <Lookup <Get_Block_Table> "VAR-INDEX"> : s.i,
935  <Bind <Get_Block_Table> ("VAR-INDEX") (<Add s.i 1>)>,
936  <Bind_Var Expr t.var1> :: s.i1,
937  <Bind_Var Expr t.var2> :: s.i2,
938  <Bind <Get_Block_Table> (ITER e.expr) (s.i s.i1 s.i2)>,
939  s.i;
940
941Lookup_Iter_Var e.expr = <Lookup <Get_Block_Table> ITER e.expr> : s.i s.i1 s.i2 = s.i s.i1 s.i2;
942
943Bind_TMP_Var t.var =
944  <Lookup <Get_Block_Table> "VAR-INDEX"> : s.i,
945  <Bind <Get_Block_Table> ("VAR-INDEX") (<Add s.i 1>)>,
946  <Bind <Get_Block_Table> (TMP t.var) (s.i)>,
947  s.i;
948
949Lookup_TMP_Var t.var = <Lookup <Get_Block_Table> TMP t.var> : s.i = s.i;
950
951$func Bind_Label t.label = s.l;
952$func Lookup_Label t.label = s.l;
953
954Bind_Label t.label =
955  <Label> :: s.l,
956  <Bind <Get_Block_Table> (LABEL t.label) (s.l)>,
957  s.l;
958
959Lookup_Label t.label = <Lookup <Get_Block_Table> LABEL t.label> : s.l = s.l;
960
961
962$box Traps;
963
964$func Push_Trap s.end s.handler = ;
965$func Get_Trap = s.handler;
966$func Pop_Trap = s.end;
967
968Push_Trap s.end s.handler =
969  <Put &Traps s.end s.handler>;
970
971Get_Trap = <R 0 <Get &Traps>> : s.handler = s.handler;
972
973Pop_Trap =
974  <Get &Traps> : e.traps s.end s,
975  <Store &Traps e.traps>,
976  s.end;
977
978
979
980$func Function_Description (e.args) (e.ress) s.retType = s.desc;
981
982Function_Description (e.args) (e.ress) s.retType =
983  <ToWord '(' <Replicate <Length e.args> "Lorg/refal/plus/Expr;">
984    <Replicate <Length e.ress> "Lorg/refal/plus/Result;">')' s.retType>;
985
986$func Check_Name s.name = ;
987Check_Name s = ;
988
989
990Module_To_JBC e.module, <Map &Module_Item_To_JBC (e.module)> : e;
991
992Module_Item_To_JBC {
993  (s.tag IMPORT e) = /*empty*/;
994  (NATIVE s.linkage s.tag t.qname (e.in) (e.out) e.native) = <WrapGen s.linkage s.tag t.qname (e.in) (e.out) e.native>;
995  (s.tag s.linkage t.qname (e.args) (e.ress) e.body),
996    s.tag : \{
997      FUNC    = 'V';
998      TFUNC   = 'V';
999      "FUNC?" = 'Z';
1000    } : s.retType =
1001    t.qname : (e s.name),
1002    <Check_Name s.name>,
1003    <Add <ACC_STATIC> <Access_Mode s.linkage>> :: s.access,
1004    <Function_Description (e.args) (e.ress) s.retType> :: s.desc,
1005    <Store &MVbox <CWvisitMethod <CW> s.access s.name s.desc <Null> ("org/refal/plus/RefalException")>>,
1006    {
1007      <PrintFunctionFormat t.qname> :: s.format =
1008        <IIMVvisitAnnotation <MV> "Lorg/refal/plus/RefalFormat;" False> :: s.aw,
1009        <IIAVvisit s.aw "value" s.format>,
1010        <IIAVvisitEnd s.aw>;;
1011    },
1012    <Store &FuncName s.name> <Init_Block_Table> <Push_Block_Table> <Bind_Vars Expr e.args> <Bind_Vars Result e.ress>,
1013    <Body_To_JBC e.body>,
1014    <Pop_Block_Table>
1015    s.tag : {
1016      FUNC    = <IIMVvisitInsn <MV> <RETURN>>;
1017      TFUNC   = <IIMVvisitInsn <MV> <RETURN>>;
1018      "FUNC?" = <IIMVvisitInsn <MV> <ICONST_1>> <IIMVvisitInsn <MV> <IRETURN>>;
1019    },
1020    <IIMVvisitMaxs <MV> 0 0>,
1021    <IIMVvisitEnd <MV>>,
1022    { <Get &Entry> : e t.qname e = <Store &EntryName s.name>;; };
1023  (CONSTEXPR s.linkage t.qname (e.comment) e.expr) =
1024    t.qname : {
1025      (STATIC (e)) = <GetJBCName t.qname>;
1026      (e s.name) = s.name;
1027    } :: s.name,
1028    <Check_Name s.name>,
1029    <Add <ACC_FINAL> <Add <ACC_STATIC> <Access_Mode s.linkage>>> :: s.access,
1030    <CWvisitField <CW> s.access s.name "Lorg/refal/plus/Expr;" <Null> <Null>> :: s.fv,
1031    {
1032      <PrintConstDefinition t.qname> :: s.def =
1033        <IIFVvisitAnnotation s.fv "Lorg/refal/plus/RefalFormat;" False> :: s.aw,
1034        <IIAVvisit s.aw "value" s.def>,
1035        <IIAVvisitEnd s.aw>;;
1036    },
1037    <IIFVvisitEnd s.fv>,
1038    <Put &Constants (s.name e.expr)>;
1039  (OBJ s.linkage s.tag t.qname) =
1040    t.qname : (e s.name),
1041    <Check_Name s.name>,
1042    <Add <ACC_FINAL> <Add <ACC_STATIC> <Access_Mode s.linkage>>> :: s.access,
1043    <CWvisitField <CW> s.access s.name "Lorg/refal/plus/Expr;" <Null> <Null>> :: s.fv,
1044    {
1045      <PrintObjectDefinition t.qname> :: s.def =
1046        <IIFVvisitAnnotation s.fv "Lorg/refal/plus/RefalFormat;" False> :: s.aw,
1047        <IIAVvisit s.aw "value" s.def>,
1048        <IIAVvisitEnd s.aw>;;
1049    },
1050    <IIFVvisitEnd s.fv>,
1051    <Put &Objects (s.tag s.name)>;
1052  ("DECL-OBJ" t.name) = ;
1053  ("DECL-FUNC" t.name) = ;
1054  (TRACE t.name) =
1055    <Bind &RFP_Trace (t.name) ()>;
1056};
1057
1058Body_To_JBC e.body, <Map &Body_Item_To_JBC (e.body)> : e;
1059
1060Body_Item_To_JBC {
1061  (LINENUMBER sN) =
1062    <Label> :: s.line,
1063    <IIMVvisitLabel <MV> s.line>,
1064    <IIMVvisitLineNumber <MV> sN s.line>;
1065  (DECL (INT t.var) e.expr) =
1066    <Bind_Var Int t.var> :: s.i,
1067    <Expr_Int_To_JBC e.expr>,
1068    <IIMVvisitVarInsn <MV> <ISTORE> s.i>;
1069  (ASSIGN (INT t.var) e.expr) =
1070    <Lookup_Var t.var> :: s s.i,
1071    <Expr_Int_To_JBC e.expr>,
1072    <IIMVvisitVarInsn <MV> <ISTORE> s.i>;
1073  (DECL s.type t.var e.expr) =
1074    <Bind_Var s.type t.var> :: s.i,
1075    s.type : {
1076      Result =
1077        <IIMVvisitTypeInsn <MV> <NEW> "org/refal/plus/Result">,
1078        <IIMVvisitInsn <MV> <DUP>>,
1079        <Expr_Ref_To_JBC e.expr>,
1080        <IIMVvisitMethodInsn <MV> <INVOKESPECIAL> "org/refal/plus/Result" "<init>" "(Lorg/refal/plus/Expr;)V">,
1081        <IIMVvisitVarInsn <MV> <ASTORE> s.i>;
1082      Expr =
1083        <Expr_Ref_To_JBC e.expr>,
1084        <IIMVvisitVarInsn <MV> <ASTORE> s.i>;
1085    };
1086  (ASSIGN t.var e.expr) =
1087    <Lookup_Var t.var> :: s.type s.i,
1088    s.type : {
1089      Result =
1090        <IIMVvisitVarInsn <MV> <ALOAD> s.i>,
1091        <Expr_Ref_To_JBC e.expr>,
1092        <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Result" "assign" "(Lorg/refal/plus/Expr;)V">;
1093      Expr =
1094        <Expr_Ref_To_JBC e.expr>,
1095        <IIMVvisitVarInsn <MV> <ASTORE> s.i>;
1096    };
1097  ("IF-INT-CMP" s.op (e.arg1) (e.arg2) e.body) =
1098    <Push_Block_Table>,
1099    <Label> :: s.label,
1100    <Expr_Int_To_JBC e.arg1>,
1101    <Expr_Int_To_JBC e.arg2>,
1102    s.op : {
1103      "!=" = <IF_ICMPEQ>;
1104      "<" = <IF_ICMPGE>;
1105      ">" = <IF_ICMPLE>;
1106    } :: s.op,
1107    <IIMVvisitJumpInsn <MV> s.op s.label>,
1108    <Body_To_JBC e.body>,
1109    <IIMVvisitLabel <MV> s.label>,
1110    <Pop_Block_Table>;
1111  (IF t.cond e.body) =
1112    <Push_Block_Table>,
1113    <Label> :: s.label,
1114    <Cond_To_JBC t.cond> :: s.if,
1115    <IIMVvisitJumpInsn <MV> s.if s.label>,
1116    <Body_To_JBC e.body>,
1117    <IIMVvisitLabel <MV> s.label>,
1118    <Pop_Block_Table>;
1119  (LSPLIT t.name (e.min) t.var1 t.var2) =
1120    <Push_Block_Table>,
1121    <Bind_Iter_Var t.name t.var1 t.var2> :: s.i,
1122    <Expr_Ref_To_JBC t.name>,
1123    <Expr_Int_To_JBC e.min>,
1124    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "leftSplit" "(I)Lorg/refal/plus/Expr$SplitIterator;">,
1125    <IIMVvisitVarInsn <MV> <ASTORE> s.i>;
1126  (RSPLIT t.name (e.min) t.var1 t.var2) =
1127    <Push_Block_Table>,
1128    <Bind_Iter_Var t.name t.var1 t.var2> :: s.i,
1129    <Expr_Ref_To_JBC t.name>,
1130    <Expr_Int_To_JBC e.min>,
1131    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "rightSplit" "(I)Lorg/refal/plus/Expr$SplitIterator;">,
1132    <IIMVvisitVarInsn <MV> <ASTORE> s.i>;
1133  (FOR (e.cont_label) (e.break_label) () (e.step) e.body) =
1134    { e.step : /*empty*/, <Push_Block_Table>;; },
1135    {
1136      e.cont_label : t.label = <Bind_Label t.label>;
1137      <Label>;
1138    } :: s.cont_label,
1139    {
1140      e.break_label : t.label = <Bind_Label t.label>;
1141      <Label>;
1142    } :: s.break_label,
1143    <Label> :: s.for_label,
1144    <IIMVvisitLabel <MV> s.for_label>,
1145    {
1146      e.step : (s.tag e.expr), s.tag : \{ "INC-ITER"; "DEC-ITER"; } =
1147        <Lookup_Iter_Var e.expr> : s.i s.i1 s.i2,
1148        <IIMVvisitVarInsn <MV> <ALOAD> s.i>,
1149        <IIMVvisitInsn <MV> <DUP>>,
1150        <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr$SplitIterator" "getLeft" "()Lorg/refal/plus/Expr;">,
1151        <IIMVvisitVarInsn <MV> <ASTORE> s.i1>,
1152        <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr$SplitIterator" "getRight" "()Lorg/refal/plus/Expr;">,
1153        <IIMVvisitVarInsn <MV> <ASTORE> s.i2>;;
1154    },
1155    <Body_To_JBC e.body>,
1156    <IIMVvisitLabel <MV> s.cont_label>,
1157    <Step_To_JBC e.step>,
1158    <IIMVvisitJumpInsn <MV> <GOTO> s.for_label>,
1159    <IIMVvisitLabel <MV> s.break_label>,
1160    <Pop_Block_Table>;
1161  (LABEL (t.label) e.body) =
1162    <Push_Block_Table>,
1163    <Bind_Label t.label> :: s.label,
1164    <Body_To_JBC e.body>,
1165    <IIMVvisitLabel <MV> s.label>,
1166    <Pop_Block_Table>;
1167  (s.tag t.label), s.tag : \{ CONTINUE; BREAK; } =
1168    <IIMVvisitJumpInsn <MV> <GOTO> <Lookup_Label t.label>>;
1169  RETFAIL =
1170    <IIMVvisitInsn <MV> <ICONST_0>> <IIMVvisitInsn <MV> <IRETURN>>;
1171  (TRY e.body) =
1172    <Push_Block_Table>,
1173    <Label> :: s.start,
1174    <Label> :: s.end,
1175    <Label> :: s.real_end,
1176    <Label> :: s.handler,
1177    <Push_Trap s.real_end s.handler>,
1178    <IIMVvisitTryCatchBlock <MV> s.start s.end s.handler "org/refal/plus/RefalException">,
1179    <IIMVvisitLabel <MV> s.start>,
1180    <Body_To_JBC e.body>,
1181    <IIMVvisitLabel <MV> s.end>,
1182    <IIMVvisitJumpInsn <MV> <GOTO> s.real_end>,
1183    <Pop_Block_Table>;
1184  ("CATCH-ERROR" e.body) =
1185    <Push_Block_Table>,
1186    <Get_Trap> :: s.label,
1187    <IIMVvisitLabel <MV> s.label>,
1188    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/RefalException" "getExpr" "()Lorg/refal/plus/Expr;">,
1189    <IIMVvisitVarInsn <MV> <ASTORE> <Bind_Var Expr s.label>>,
1190    <Body_To_JBC e.body>,
1191    <IIMVvisitLabel <MV> <Pop_Trap>>,
1192    <Pop_Block_Table>;
1193  FATAL =
1194    <IIMVvisitTypeInsn <MV> <NEW> "org/refal/plus/RefalException">,
1195    <IIMVvisitInsn <MV> <DUP>>,
1196    <Get &Refal_Module_Name> : s.mod_name,
1197    <IIMVvisitLdcInsn <MV> s.mod_name>,
1198    <Get &FuncName> : s.fname,
1199    <IIMVvisitLdcInsn <MV> s.fname>,
1200    <IIMVvisitLdcInsn <MV> "Unexpected fail">,
1201    <IIMVvisitMethodInsn <MV> <INVOKESPECIAL> "org/refal/plus/RefalException" "<init>" "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V">,
1202    <IIMVvisitInsn <MV> <ATHROW>>;
1203  (ERROR e.expr) =
1204    <IIMVvisitTypeInsn <MV> <NEW> "org/refal/plus/RefalException">,
1205    <IIMVvisitInsn <MV> <DUP>>,
1206    <Expr_Ref_To_JBC e.expr>,
1207    <IIMVvisitMethodInsn <MV> <INVOKESPECIAL> "org/refal/plus/RefalException" "<init>" "(Lorg/refal/plus/Expr;)V">,
1208    <IIMVvisitInsn <MV> <ATHROW>>;
1209  (s.call (e.module s.name) (e.args) (e.ress)),
1210    s.call : \{ CALL = V; TAILCALL = V; "TAILCALL?" = Z; } :: s.retType =
1211    <Function_Description (e.args) (e.ress) s.retType> :: s.desc,
1212    {
1213      e.args : e (e.arg) e,
1214        <Expr_Ref_To_JBC e.arg>,
1215        $fail;;
1216    },
1217    {
1218      e.ress : e t.var e, <Lookup_Var t.var> :
1219        {
1220          Expr s =
1221            <Bind_TMP_Var t.var> :: s.j,
1222            <IIMVvisitTypeInsn <MV> <NEW> "org/refal/plus/Result">,
1223            <IIMVvisitInsn <MV> <DUP>>,
1224            <IIMVvisitInsn <MV> <DUP>>,
1225            <IIMVvisitMethodInsn <MV> <INVOKESPECIAL> "org/refal/plus/Result" "<init>" "()V">,
1226            <IIMVvisitVarInsn <MV> <ASTORE> s.j>;
1227          Result s.i =
1228            <IIMVvisitVarInsn <MV> <ALOAD> s.i>;
1229        }, $fail;;
1230    },
1231    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> <GetJBCQName e.module s.name> s.desc>,
1232    {
1233      s.call : "TAILCALL?" =
1234        <Label> :: s.label,
1235        <IIMVvisitJumpInsn <MV> <IFNE> s.label>,
1236        <IIMVvisitInsn <MV> <ICONST_0>>,
1237        <IIMVvisitInsn <MV> <IRETURN>>,
1238        <IIMVvisitLabel <MV> s.label>;;
1239    },
1240    {
1241      e.ress : e t.var e, <Lookup_Var t.var> : Expr s.i,
1242        <Lookup_TMP_Var t.var> :: s.j,
1243        <IIMVvisitVarInsn <MV> <ALOAD> s.j>
1244          <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Result" "getExpr" "()Lorg/refal/plus/Expr;">,
1245        <IIMVvisitVarInsn <MV> <ASTORE> s.i>,
1246        $fail;;
1247    };
1248};
1249
1250$func Expr_Ref_To_JBC_With_Type e.expr = s.type; // Expr or Comparable
1251$func Term_Ref_To_JBC_With_Type t.term = s.type; // Expr or Comparable
1252
1253Expr_Ref_To_JBC e.expr,
1254  <Expr_Ref_To_JBC_With_Type e.expr> : s.type,
1255  {
1256    s.type : Comparable,
1257      <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Expr" "create" "(Ljava/lang/Comparable;)Lorg/refal/plus/Expr;">;;
1258  };
1259
1260Expr_Ref_To_JBC_With_Type {
1261  /*empty*/ = <IIMVvisitFieldInsn <MV> <GETSTATIC> "org/refal/plus/Expr" "empty" "Lorg/refal/plus/Expr;">, Expr;
1262  t.term = <Term_Ref_To_JBC_With_Type t.term>;
1263  t.term1 t.term2 =
1264    <Term_Ref_To_JBC_With_Type t.term1> :: s.type1,
1265    <Term_Ref_To_JBC_With_Type t.term2> :: s.type2,
1266    { s.type1 : Comparable = "Ljava/lang/Comparable;"; "Lorg/refal/plus/Expr;"; } :: s.type1,
1267    { s.type2 : Comparable = "Ljava/lang/Comparable;"; "Lorg/refal/plus/Expr;"; } :: s.type2,
1268    <ToWord "(" s.type1 s.type2 ")Lorg/refal/plus/Expr;"> :: s.concatType,
1269    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Expr" "concat" s.concatType>, Expr;
1270  e.expr =
1271    <IIMVvisitLdcInsn <MV> <Integer <Length e.expr>>>,
1272    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Expr" "getConcatenator" "(I)Lorg/refal/plus/Expr$Concatenator;">,
1273    {
1274      e.expr : e t.term e,
1275        <Term_Ref_To_JBC_With_Type t.term> :: s.type,
1276        { s.type : Comparable = "Ljava/lang/Comparable;"; "Lorg/refal/plus/Expr;"; } :: s.type,
1277        <ToWord "(" s.type ")Lorg/refal/plus/Expr$Concatenator;"> :: s.toRightType,
1278        <IIMVvisitMethodInsn <MV> <INVOKEINTERFACE> "org/refal/plus/Expr$Concatenator" "toRight" s.toRightType>,
1279        $fail;;
1280    },
1281    <IIMVvisitMethodInsn <MV> <INVOKEINTERFACE> "org/refal/plus/Expr$Concatenator" "yield" "()Lorg/refal/plus/Expr;">, Expr;
1282};
1283
1284Term_Ref_To_JBC_With_Type {
1285  (PAREN e.expr) = <Expr_Ref_To_JBC e.expr>, Comparable;
1286  (DEREF e.expr (e.pos)) =
1287    <Expr_Ref_To_JBC e.expr>,
1288    <Expr_Int_To_JBC e.pos>,
1289    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "at" "(I)Ljava/lang/Comparable;">,
1290    <IIMVvisitTypeInsn <MV> <CHECKCAST> "org/refal/plus/Expr">, Expr;
1291  (SUBEXPR e.expr (e.pos) (e.len)) =
1292    <Expr_Ref_To_JBC e.expr>,
1293    <Expr_Int_To_JBC e.pos>,
1294    <Expr_Int_To_JBC e.len>,
1295    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "subexpr" "(II)Lorg/refal/plus/Expr;">, Expr;
1296  t.term, t.term : \{
1297    (REF (e.module s.name)) = e.module s.name;
1298    (STATIC (e)) = <Get &Module_Name> t.term;
1299  } :: e.module t.name =
1300    <IIMVvisitFieldInsn <MV> <GETSTATIC> <GetJBCQName e.module t.name> "Lorg/refal/plus/Expr;">, Expr;
1301  "ERROR-EXPR" = <Var_To_JBC <Get_Trap>>, Expr;
1302  t.term, t.term : (s.var_tag e),
1303    s.var_tag : \{ VAR; SVAR; TVAR; EVAR; VVAR; } =
1304    <Var_To_JBC t.term>, Expr;
1305};
1306
1307Expr_Int_To_JBC {
1308  s.ObjectSymbol =
1309    {
1310      <IsInt s.ObjectSymbol> =
1311        <IIMVvisitLdcInsn <MV> <Integer s.ObjectSymbol>>;
1312      $error ("Illegal int-symbol: " s.ObjectSymbol);
1313        //FIXME: It is needed to check that s.pos and s.len
1314        //       are in allowable bounds.
1315        //       Set this bounds by options.
1316    };
1317  (LENGTH e.x) =
1318    <Expr_Ref_To_JBC e.x>,
1319    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "length" "()I">;
1320  (s.tag (e.x) (e.y)),
1321    s.tag : \{ MIN = "min"; MAX = "max"; } :: s.fn =
1322    <Expr_Int_To_JBC e.x>,
1323    <Expr_Int_To_JBC e.y>,
1324    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "java/lang/Math" s.fn "(II)I">;
1325  (INFIX s.op e.args) =
1326    <Infix_To_JBC &Expr_Int_To_JBC s.op e.args>;
1327  (INT t.var) = <Var_To_JBC t.var>;
1328  e.expr = <Infix_To_JBC &Expr_Int_To_JBC "+" <Paren e.expr>>;
1329};
1330
1331Infix_To_JBC s.arg2java s.op (e.arg) e.args =
1332  s.op : \{
1333    "+" = <IADD>;
1334    "-" = <ISUB>;
1335    "%" = <IREM>;
1336    "*" = <IMUL>;
1337    "/" = <IDIV>;
1338  } :: s.jbcop,
1339  <Apply s.arg2java e.arg> : e,
1340  {
1341    e.args : e (e.arg2) e,
1342      <Apply s.arg2java e.arg2> : e,
1343      <IIMVvisitInsn <MV> s.jbcop>,
1344      $fail;;
1345  };
1346
1347Cond_To_JBC {
1348  ("CALL-FAILS" (CALL (e.module s.name) (e.args) (e.ress))) =
1349    <Function_Description (e.args) (e.ress) "Z"> :: s.desc,
1350    {
1351      e.args : e (e.arg) e,
1352        <Expr_Ref_To_JBC e.arg>,
1353        $fail;;
1354    },
1355    {
1356      e.ress : e t.var e, <Lookup_Var t.var> :
1357        {
1358          Expr s =
1359            <Bind_TMP_Var t.var> :: s.j,
1360            <IIMVvisitTypeInsn <MV> <NEW> "org/refal/plus/Result">,
1361            <IIMVvisitInsn <MV> <DUP>>,
1362            <IIMVvisitInsn <MV> <DUP>>,
1363            <IIMVvisitMethodInsn <MV> <INVOKESPECIAL> "org/refal/plus/Result" "<init>" "()V">,
1364            <IIMVvisitVarInsn <MV> <ASTORE> s.j>;
1365          Result s.i =
1366            <IIMVvisitVarInsn <MV> <ALOAD> s.i>;
1367        }, $fail;;
1368    },
1369    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> <GetJBCQName e.module s.name> s.desc>,
1370    {
1371      e.ress : e t.var e, <Lookup_Var t.var> : Expr s.i,
1372        <Lookup_TMP_Var t.var> :: s.j,
1373        <IIMVvisitVarInsn <MV> <ALOAD> s.j>
1374        <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Result" "getExpr" "()Lorg/refal/plus/Expr;">,
1375        <IIMVvisitVarInsn <MV> <ASTORE> s.i>,
1376        $fail;;
1377    },
1378    <IFNE>;
1379  ("ITER-FAILS" e.expr) =
1380    <Lookup_Iter_Var e.expr> :: s.i s s,
1381    <IIMVvisitVarInsn <MV> <ALOAD> s.i>,
1382    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr$SplitIterator" "isValid" "()Z">,
1383    <IFNE>;
1384  ("SYMBOL?" e.expr (e.pos)) =
1385    <Expr_Ref_To_JBC e.expr>,
1386    <Expr_Int_To_JBC e.pos>,
1387    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "isSymbolAt" "(I)Z">,
1388    <IFEQ>;
1389  (EQ e.expr1 (e.expr2) (e.pos)) =
1390    <Expr_Ref_To_JBC e.expr1>,
1391    <Expr_Ref_To_JBC e.expr2>,
1392    <Expr_Int_To_JBC e.pos>,
1393    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "equals" "(Lorg/refal/plus/Expr;I)Z">,
1394    <IFEQ>;
1395  ("TERM-EQ" e.expr1 (e.expr2) (e.pos)) =
1396    <Expr_Ref_To_JBC e.expr1>,
1397    <Expr_Ref_To_JBC e.expr2>,
1398    <Expr_Int_To_JBC e.pos>,
1399    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "termEquals" "(Lorg/refal/plus/Expr;I)Z">,
1400    <IFEQ>;
1401  (NOT t.cond) =
1402    <IFEQ> :: s.IFEQ,
1403    <IFNE> :: s.IFNE,
1404    <Cond_To_JBC t.cond> : {
1405      s.IFEQ = s.IFNE;
1406      s.IFNE = s.IFEQ;
1407    };
1408};
1409
1410
1411Step_To_JBC {
1412  /*empty*/ = /*empty*/;
1413  (s.tag e.expr),
1414    s.tag : {
1415      "INC-ITER" = "next";
1416      "DEC-ITER" = "prev";
1417    } :: s.m =
1418    <Lookup_Iter_Var e.expr> :: s.i s s,
1419    <IIMVvisitVarInsn <MV> <ALOAD> s.i>,
1420    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr$SplitIterator" s.m "()Lorg/refal/plus/Expr$SplitIterator;">,
1421    <IIMVvisitInsn <MV> <POP>>;
1422};
1423
1424$func Const_Term_To_JBC t.term = ;
1425$func Get_String_From_Const_Expr e.expr = (e.chars) e.expr;
1426$func Convert_Const_Expr e.expr = e.expr;
1427
1428Const_Expr_To_JBC {
1429  /*empty*/ = <IIMVvisitFieldInsn <MV> <GETSTATIC> "org/refal/plus/Expr" "empty" "Lorg/refal/plus/Expr;">;
1430  (SUBEXPR t.name s.pos s.len) =
1431    t.name : \{
1432      (REF (e.module s.obj_name)) = e.module s.obj_name;
1433      (STATIC (e)) = <Get &Module_Name> t.name;
1434    } :: e.module t.name =
1435    <IIMVvisitFieldInsn <MV> <GETSTATIC> <GetJBCQName e.module t.name> "Lorg/refal/plus/Expr;">,
1436    <IIMVvisitLdcInsn <MV> <Integer s.pos>>,
1437    <IIMVvisitLdcInsn <MV> <Integer s.len>>,
1438    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "subexpr" "(II)Lorg/refal/plus/Expr;">;
1439                  //FIXME: It is needed to check that s.pos and s.len
1440                  //       are in allowable bounds.
1441                  //       Set this bounds by options.
1442  e.expr = <Convert_Const_Expr e.expr> :: e.expr,
1443    <IIMVvisitLdcInsn <MV> <Integer <Length e.expr>>>,
1444    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Expr" "getConcatenator" "(I)Lorg/refal/plus/Expr$Concatenator;">,
1445    {
1446      e.expr : e t.term e,
1447        <Const_Term_To_JBC t.term>,
1448        <IIMVvisitMethodInsn <MV> <INVOKEINTERFACE> "org/refal/plus/Expr$Concatenator" "toRight" "(Lorg/refal/plus/Expr;)Lorg/refal/plus/Expr$Concatenator;">,
1449        $fail;;
1450    },
1451    <IIMVvisitMethodInsn <MV> <INVOKEINTERFACE> "org/refal/plus/Expr$Concatenator" "yield" "()Lorg/refal/plus/Expr;">;
1452
1453  /*e.expr =
1454    <Const-Expr-Aux () e.expr> : {
1455      (e.arrays) (e1)      = e.arrays (e1);
1456      (e.arrays) (e1) (e2) = e.arrays ('new Expr ('e1', 'e2')');
1457      (e.arrays) e.concat  =
1458        '_va_' :: e.new-var,
1459        e.arrays
1460        ('static private final Expr[] 'e.new-var' = { '<Concat <Intersperse (', ') e.concat>>' };')
1461        ('Expr.concat ('e.new-var')');
1462    };*/
1463};
1464
1465Get_String_From_Const_Expr e.expr,
1466  () e.expr F $iter {
1467    e.expr : s.sym e.rest, <IsChar s.sym> = (e.chars s.sym) e.rest F;
1468    (e.chars) e.expr T;
1469  } :: (e.chars) e.expr s.flag, s.flag : T,
1470  (e.chars) e.expr;
1471
1472Convert_Const_Expr e.expr,
1473  () e.expr $iter {
1474    <Get_String_From_Const_Expr e.expr> :: (e.chars) e.expr,
1475      {
1476        e.chars : v = (e.res (CHARS e.chars)) e.expr;
1477        e.expr : t.term e.rest, (e.res t.term) e.rest;
1478      };
1479  } :: (e.res) e.expr, e.expr : /*empry*/,
1480  e.res;
1481
1482Const_Term_To_JBC {
1483  (CHARS e.chars) =
1484    <IIMVvisitLdcInsn <MV> <ToWord e.chars>>,
1485    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Expr" "fromSequence" "(Ljava/lang/CharSequence;)Lorg/refal/plus/Expr;">;
1486  (PAREN e.expr) =
1487    <Const_Expr_To_JBC e.expr>,
1488    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Expr" "create" "(Ljava/lang/Comparable;)Lorg/refal/plus/Expr;">;
1489  t.term, t.term : \{
1490    (REF (e.module s.name)) = e.module s.name;
1491    (STATIC (e)) = <Get &Module_Name> t.term;
1492  } :: e.module t.name =
1493    <IIMVvisitFieldInsn <MV> <GETSTATIC> <GetJBCQName e.module t.name> "Lorg/refal/plus/Expr;">;
1494  (s.func (e.module s.name)), s.func : \{ FUNC; "FUNC?"; TFUNC; } =
1495    <ToWord <Get &Class_Name> '$' <Length <Get &Func_Refs>>> :: s.cl_name,
1496    <Put &Func_Refs (<Length <Get &Func_Refs>> <GetJBCQName e.module s.name> s.func)>,
1497    <IIMVvisitLdcInsn <MV> s.name>,
1498    <IIMVvisitTypeInsn <MV> <NEW> s.cl_name>,
1499    <IIMVvisitInsn <MV> <DUP>>,
1500    <IIMVvisitMethodInsn <MV> <INVOKESPECIAL> s.cl_name "<init>" "()V">,
1501    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Symbol" "newFunc" "(Ljava/lang/String;Lorg/refal/plus/Func;)Ljava/lang/Comparable;">,
1502    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Expr" "create" "(Ljava/lang/Comparable;)Lorg/refal/plus/Expr;">;
1503  s.sym =
1504    {
1505      <IsInt s.sym> = "newInt";
1506      <IsWord s.sym> = "newWord";
1507    } :: s.meth,
1508    <IIMVvisitLdcInsn <MV> <ToWord s.sym>>,
1509    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Symbol" s.meth "(Ljava/lang/String;)Ljava/lang/Comparable;">,
1510    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Expr" "create" "(Ljava/lang/Comparable;)Lorg/refal/plus/Expr;">;
1511};
1512
1513Var_To_JBC t.var =
1514  <Lookup_Var t.var> :: s.type s.i,
1515  s.type : {
1516    Result =
1517      <IIMVvisitVarInsn <MV> <ALOAD> s.i>,
1518      <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Result" "getExpr" "()Lorg/refal/plus/Expr;">;
1519    Expr =
1520      <IIMVvisitVarInsn <MV> <ALOAD> s.i>;
1521    Int =
1522      <IIMVvisitVarInsn <MV> <ILOAD> s.i>;
1523  };
1524
1525Access_Mode {
1526  EXPORT = <ACC_PUBLIC>;
1527  s = 0;
1528};
1529
1530$func PutArgToStack s.javaArgType e.rfArgTypes s.num = ;
1531PutArgToStack s.javaArgType e.rfArgTypes s.num =
1532  <IIMVvisitVarInsn <MV> <ALOAD> s.num>,
1533  <L s.num e.rfArgTypes> s.javaArgType : {
1534    \{
1535      (SVAR e) Z = "toBoolean";
1536      (SVAR e) C = "toChar";
1537      (SVAR e) B = "toByte";
1538      (SVAR e) S = "toShort";
1539      (SVAR e) I = "toShort";
1540      (SVAR e) J = "toLong";
1541      (EVAR e) "[Z" = "toBooleanArray";
1542      (EVAR e) "[C" = "toCharArray";
1543      (EVAR e) "[B" = "toByteArray";
1544      (EVAR e) "[S" = "toShortArray";
1545      (EVAR e) "[I" = "toShortArray";
1546      (EVAR e) "[J" = "toLongArray";
1547    } :: s.methodName,
1548      <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Native" s.methodName  <ToWord "(Lorg/refal/plus/Expr;)"s.javaArgType>>;
1549    {
1550      (SVAR e) s =
1551        <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Native" "toObject" "(Lorg/refal/plus/Expr;)Ljava/lang/Object;">;
1552      (EVAR e) s =
1553        <ToChars s.javaArgType> : '[' e.elemType, { e.elemType : 'L' e.intName ';', <ToWord e.intName>; <ToWord e.elemType>; } :: s.javaElemType,
1554        <IIMVvisitInsn <MV> <DUP>>,
1555        <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Expr" "length" "()I">,
1556        <IIMVvisitTypeInsn <MV> <ANEWARRAY> s.javaElemType>,
1557        <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Native" "toObjectArray" "(Lorg/refal/plus/Expr;[Ljava/lang/Object;)[Ljava/lang/Object;">;
1558    },
1559      { <ToChars s.javaArgType> : 'L' e.intName ';', <ToWord e.intName>; s.javaArgType; } :: s.javaArgType,
1560      <IIMVvisitTypeInsn <MV> <CHECKCAST> s.javaArgType>;
1561  };
1562
1563$func GetResFromStack s.javaResType e.rfResTypes s.num = ;
1564GetResFromStack s.javaResType e.rfResTypes s.num = {
1565  e.rfResTypes : /**/ = ;
1566  <IIMVvisitVarInsn <MV> <ALOAD> s.num>,
1567    <IIMVvisitInsn <MV> <SWAP>>,
1568    e.rfResTypes (<ToChars s.javaResType>) : {
1569      (SVAR e) ('L'  e) = "Ljava/lang/Object;"; // Object
1570      (SVAR e) ('['  e) = "Ljava/lang/Object;"; // Array
1571      (SVAR e) (     e) = s.javaResType; // Primitive type
1572      (EVAR e) ('[L' e) = "[Ljava/lang/Object;"; // Array of objects
1573      (EVAR e) ('[[' e) = "[Ljava/lang/Object;"; // Array of arrays
1574      (EVAR e) ('['  e) = s.javaResType; // Array of primitive type
1575    } :: s.javaResType,
1576    <IIMVvisitMethodInsn <MV> <INVOKESTATIC> "org/refal/plus/Native" "toExpr" <ToWord "("s.javaResType")Lorg/refal/plus/Expr;">>,
1577    <IIMVvisitMethodInsn <MV> <INVOKEVIRTUAL> "org/refal/plus/Result" "assign" "(Lorg/refal/plus/Expr;)V">;
1578};
1579
1580$func ConvertType s.javaType = s.typeDesc;
1581$func ConvertResType s.javaResType = s.resDesc;
1582
1583ConvertResType {
1584  "" = V;
1585  s.javaType = <ConvertType s.javaType>;
1586};
1587
1588ConvertType {
1589  "void" = V;
1590  "int" = I;
1591  "boolean" = Z;
1592  "char" = C;
1593  "byte" = B;
1594  "short" = S;
1595  "int" = I;
1596  "float" = F;
1597  "long" = J;
1598  "double" = D;
1599  s.javaType, <ToChars s.javaType> : e.head '[]' = <ToWord "[" <ConvertType <ToWord e.head>>>;
1600  s.javaType = <ToWord L s.javaType ";">;
1601};
1602
1603$func ReplaceDots s = s;
1604ReplaceDots s.str = <ToWord <Subst ('.') (('/')) <ToChars s.str>>>;
1605
1606WrapGen s.linkage FUNC t.qname (e.in) (e.out) e.native =
1607  t.qname : (e s.functionName),
1608  { <Get &Entry> : e t.qname e = <Store &EntryName s.functionName>;; },
1609  <DeclarationReader <ToWord e.native>> :: s.static s.javaResType s.className s.methodName e.javaArgTypes,
1610  <ReplaceDots s.javaResType> :: s.javaResType,
1611  <ReplaceDots s.className> :: s.className,
1612  <Add <ACC_STATIC> <Access_Mode s.linkage>> :: s.access,
1613  <Vars e.in> :: e.rfArgTypes,
1614  <Vars e.out> :: e.rfResTypes,
1615  <Function_Description (e.rfArgTypes) (e.rfResTypes) 'V'> :: s.desc,
1616  <Store &MVbox <CWvisitMethod <CW> s.access s.functionName s.desc <Null> ("org/refal/plus/RefalException")>>,
1617  {
1618    <PrintFunctionFormat t.qname> :: s.format =
1619      <IIMVvisitAnnotation <MV> "Lorg/refal/plus/RefalFormat;" False> :: s.aw,
1620      <IIAVvisit s.aw "value" s.format>,
1621      <IIAVvisitEnd s.aw>;;
1622  },
1623  <IIMVvisitCode <MV>>,
1624  {
1625    s.methodName : "" =
1626      <IIMVvisitTypeInsn <MV> <NEW> s.className>,
1627      <IIMVvisitInsn <MV> <DUP>>, 0;
1628    s.static : "" =
1629      <PutArgToStack <ConvertType s.className> e.rfArgTypes 0>, 1;
1630    0;
1631  } :: s.shift,
1632  {
1633    e.javaArgTypes : /**/ =
1634      {
1635        s.static : "" = <GETFIELD>;
1636        <GETSTATIC>;
1637      } :: s.opcode,
1638      <IIMVvisitFieldInsn <MV> s.opcode s.className s.methodName <ConvertType s.javaResType>>;
1639    e.javaArgTypes : (e.javaArgTypes2),
1640      <Map &ReplaceDots (e.javaArgTypes2)> :: e.javaArgTypes,
1641      {
1642        e.javaArgTypes : e.head s.javaArgType e,
1643          <PutArgToStack <ConvertType s.javaArgType> e.rfArgTypes <Add s.shift <Length e.head>>>, $fail;;
1644      },
1645      {
1646        s.methodName : "" = <INVOKESPECIAL> "<init>";
1647        s.static : "" = {
1648          <ToChars s.functionName> : 'II' e,
1649            <INVOKEINTERFACE> s.methodName;
1650          <INVOKEVIRTUAL> s.methodName;
1651        };
1652        = <INVOKESTATIC> s.methodName;
1653      } :: s.opcode s.methodName,
1654      <ToWord "(" <Map &ConvertType (e.javaArgTypes)> ")" <ConvertResType s.javaResType>> :: s.methodDesc,
1655      <IIMVvisitMethodInsn <MV> s.opcode s.className s.methodName s.methodDesc>;
1656  },
1657  {
1658    s.javaResType : "" = s.className;
1659    s.javaResType;
1660  } :: s.javaResType,   
1661  <GetResFromStack <ConvertType s.javaResType> e.rfResTypes <Length e.rfArgTypes>>,
1662  <IIMVvisitInsn <MV> <RETURN>>,
1663  <IIMVvisitMaxs <MV> 0 0>,
1664  <IIMVvisitEnd <MV>>;
Note: See TracBrowser for help on using the repository browser.