Skip to content

Commit 45d8770

Browse files
committed
ORDINAL-A-ONLY等の実装と,isNumeric()の修正
1 parent ceba5d0 commit 45d8770

File tree

4 files changed

+211
-146
lines changed

4 files changed

+211
-146
lines changed

cobc/codegen.c

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5519,6 +5519,72 @@ joutput_main_function (struct cb_program *prog)
55195519
joutput_indent ("}\n");
55205520
}
55215521

5522+
/*
5523+
* Class definition
5524+
*/
5525+
5526+
static void
5527+
joutput_class_name_definition (struct cb_class_name *p)
5528+
{
5529+
cb_tree l;
5530+
cb_tree x;
5531+
unsigned char *data;
5532+
size_t i;
5533+
size_t size;
5534+
int lower;
5535+
int upper;
5536+
5537+
joutput_line ("static boolean");
5538+
joutput_line ("%s (AbstractCobolField f)", p->cname);
5539+
joutput_indent ("{");
5540+
joutput_line ("for (int i = 0; i < f.getSize(); i++)");
5541+
joutput_prefix ();
5542+
joutput (" if (!( ");
5543+
for (l = p->list; l; l = CB_CHAIN (l)) {
5544+
x = CB_VALUE (l);
5545+
if (CB_PAIR_P (x)) {
5546+
lower = literal_value (CB_PAIR_X (x));
5547+
upper = literal_value (CB_PAIR_Y (x));
5548+
if (!lower) {
5549+
joutput ("f.getDataStorage().getByte(i) <= %d", upper);
5550+
} else {
5551+
joutput ("(%d <= f.getDataStorage().getByte(i) && f.getDataStorage().getByte(i) <= %d)", lower, upper);
5552+
}
5553+
} else {
5554+
if (CB_TREE_CLASS (x) == CB_CLASS_NUMERIC) {
5555+
joutput ("f.getDataStorage().getByte(i) == %d", literal_value(x));
5556+
} else if (x == cb_space) {
5557+
joutput ("f.getDataStorage().getByte(i) == %d", ' ');
5558+
} else if (x == cb_zero) {
5559+
joutput ("f.getDataStorage().getByte(i) == %d", '0');
5560+
} else if (x == cb_quote) {
5561+
joutput ("f.getDataStorage().getByte(i) == %d", '"');
5562+
} else if (x == cb_null) {
5563+
joutput ("f.getDataStorage().getByte(i) == 0");
5564+
} else {
5565+
size = CB_LITERAL (x)->size;
5566+
data = CB_LITERAL (x)->data;
5567+
for (i = 0; i < size; i++) {
5568+
joutput ("f.getDataStorage().getByte(i) == %d", data[i]);
5569+
if (i + 1 < size) {
5570+
joutput (" || ");
5571+
}
5572+
}
5573+
}
5574+
}
5575+
if (CB_CHAIN (l)) {
5576+
joutput ("\n");
5577+
joutput_prefix ();
5578+
joutput (" || ");
5579+
}
5580+
}
5581+
joutput (" ))\n");
5582+
joutput_line (" return false;");
5583+
joutput_line ("return true;");
5584+
joutput_indent ("}");
5585+
joutput_newline ();
5586+
}
5587+
55225588
void
55235589
codegen (struct cb_program *prog, const int nested, char** program_id_list)
55245590
{
@@ -5621,13 +5687,13 @@ codegen (struct cb_program *prog, const int nested, char** program_id_list)
56215687
joutput("\n");
56225688

56235689
joutput_line("public class %s implements CobolRunnable {", prog->program_id);
5624-
joutput_indent_level += 2;
5690+
joutput_indent_level += 2;
56255691
joutput("\n");
56265692

56275693
joutput_line("private boolean initialized = false;");
56285694
joutput_line("private CobolModule cobolCurrentModule;");
5629-
joutput_line("private int frameIndex;");
5630-
joutput_line("private CobolModule module;");
5695+
joutput_line("private int frameIndex;");
5696+
joutput_line("private CobolModule module;");
56315697
joutput_line("private CobolFrame frame;");
56325698
joutput_line("private CobolFrame[] frameStack;");
56335699
joutput_line("private static boolean cobolInitialized = false;");
@@ -5657,9 +5723,9 @@ codegen (struct cb_program *prog, const int nested, char** program_id_list)
56575723

56585724
/* Class-names */
56595725
if (!prog->nested_level && prog->class_name_list) {
5660-
//output ("/* Class names */\n");
5726+
joutput ("/* Class names */\n");
56615727
for (l = prog->class_name_list; l; l = CB_CHAIN (l)) {
5662-
//output_class_name_definition (CB_CLASS_NAME (CB_VALUE (l)));
5728+
joutput_class_name_definition (CB_CLASS_NAME (CB_VALUE (l)));
56635729
}
56645730
}
56655731

libcobj/src/jp/osscons/opensourcecobol/libcobj/call/CobolResolve.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,45 +190,38 @@ static public CobolRunnable resolve(AbstractCobolField cobolField) throws CobolC
190190
static public CobolRunnable resolve(String name) throws CobolCallException {
191191
String fullName;
192192
CobolRunnable runnable = null;
193-
System.out.println("[dbg in lib] 0");
194193

195194
/* encode program name */
196195
char c1 = name.charAt(0);
197196
if(c1 >= '0' && c1 <= '9') {
198197
name = "_" + name;
199198
}
200-
System.out.println("[dbg in lib] 1");
201199
name = name.replaceAll("-", "__");
202-
System.out.println("[dbg in lib] 2");
203200

204201
/* search the cache */
205202
if(callTable.containsKey(name)) {
206203
return callTable.get(name);
207204
}
208205

209-
System.out.println("[dbg in lib] 3");
210206
if(name_convert == 1) {
211207
name = name.toLowerCase();
212208
}else if(name_convert == 2) {
213209
name = name.toUpperCase();
214210
}
215211

216-
System.out.println("[dbg in lib] 4");
217212
if(defaultPackageName != null) {
218213
fullName = defaultPackageName + "." + name;
219214
}else {
220215
fullName = name;
221216
}
222217

223-
System.out.println("[dbg in lib] 5");
224218
/* search the main program */
225219
runnable = getInstance(fullName);
226220
if(runnable != null) {
227221
callTable.put(name, runnable);
228222
return runnable;
229223
}
230224

231-
System.out.println("[dbg in lib] 6");
232225
/* search external modules */
233226
for (String package_path : package_paths) {
234227
fullName = package_path + "." + name;
@@ -239,7 +232,6 @@ static public CobolRunnable resolve(String name) throws CobolCallException {
239232
}
240233
}
241234

242-
System.out.println("[dbg in lib] 7");
243235
//Not found
244236
throw new CobolCallException();
245237
}

libcobj/src/jp/osscons/opensourcecobol/libcobj/data/AbstractCobolField.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ public boolean isNumeric() {
10401040
int size = this.getFieldSize();
10411041
int firstIndex = this.getFirstDataIndex();
10421042
sign = this.getSign();
1043+
this.putSign(1);
10431044
for(i=0; i < size; ++i) {
10441045
c = (char)this.getDataStorage().getByte(i + firstIndex);
10451046
if(!Character.isDigit(c)) {

0 commit comments

Comments
 (0)