Skip to content

Commit 9d72b9c

Browse files
authored
Updates preparing for version 2.3
1 parent 395d51d commit 9d72b9c

16 files changed

+478
-101
lines changed

ASTBasicTerm.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2894,6 +2894,13 @@ public Type cobolDataType()
28942894
return null;
28952895
}
28962896

2897+
public boolean cobolIsSigned()
2898+
{ if ("S".equals(value))
2899+
{ return true; }
2900+
2901+
return false;
2902+
}
2903+
28972904
public Vector cobolDataDefinitions(java.util.Map context, Vector invs)
28982905
{ // Each immediately higher level item becomes an attribute
28992906
// of container. If composite, it also becomes a class

ASTCompositeTerm.java

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,9 @@ public ASTTerm replaceAmbiguousCobolNames(Vector rnames)
355355

356356
String rname = (String) rnames.get(0);
357357

358-
JOptionPane.showMessageDialog(null, this +
358+
/* JOptionPane.showMessageDialog(null, this +
359359
" Basic data item: " + fld + " in " + rname,
360-
" ", JOptionPane.INFORMATION_MESSAGE);
360+
" ", JOptionPane.INFORMATION_MESSAGE); */
361361

362362
if (ASTTerm.cobolAmbiguousDataNames.contains(fld))
363363
{ ASTTerm newname =
@@ -381,9 +381,9 @@ else if ("dataDescriptionEntryFormat1".equals(tag) &&
381381
ASTTerm rec = (ASTTerm) terms.get(1);
382382
String ename = rec.literalForm();
383383

384-
JOptionPane.showMessageDialog(null, this +
384+
/* JOptionPane.showMessageDialog(null, this +
385385
" Record data: " + ename,
386-
" ", JOptionPane.INFORMATION_MESSAGE);
386+
" ", JOptionPane.INFORMATION_MESSAGE); */
387387

388388
Vector newterms = new Vector();
389389
newterms.add(terms.get(0));
@@ -41338,6 +41338,36 @@ else if (res == intType && typ == longType)
4133841338
return stringType;
4133941339
}
4134041340

41341+
public boolean cobolIsSigned()
41342+
{ if ("dataPictureClause".equals(tag))
41343+
{ // (PIC | PICTURE) IS? pictureString
41344+
41345+
int sze = terms.size();
41346+
ASTTerm ptrm = (ASTTerm) terms.get(sze-1);
41347+
System.out.println(">> " + ptrm + " is signed: " + ptrm.cobolIsSigned());
41348+
return ptrm.cobolIsSigned();
41349+
}
41350+
41351+
if ("pictureString".equals(tag))
41352+
{ boolean res = false;
41353+
for (int i = 0; i < terms.size(); i++)
41354+
{ ASTTerm tt = (ASTTerm) terms.get(i);
41355+
boolean bb = tt.cobolIsSigned();
41356+
if (bb == true)
41357+
{ return true; }
41358+
}
41359+
41360+
return res;
41361+
}
41362+
41363+
if ("pictureChars".equals(tag))
41364+
{ ASTTerm val = (ASTTerm) terms.get(0);
41365+
return "S".equals(val.literalForm());
41366+
}
41367+
41368+
return false;
41369+
}
41370+
4134141371
public int cobolOccursTimes()
4134241372
{ if ("dataOccursClause".equals(tag))
4134341373
{ // OCCURS integerLiteral dataOccursTo? TIMES?
@@ -41582,6 +41612,7 @@ public Vector cobolDataDefinitions(java.util.Map context, Vector invs)
4158241612
int fractwidth = pictureClause.cobolFractionWidth();
4158341613
Type typ = pictureClause.cobolDataType();
4158441614
int wdth = pictureClause.cobolDataWidth();
41615+
boolean isSigned = pictureClause.cobolIsSigned();
4158541616

4158641617
ASTTerm t2 = (ASTTerm) terms.get(1);
4158741618
if (t2.getTag().equals("dataName"))
@@ -41662,12 +41693,14 @@ public Vector cobolDataDefinitions(java.util.Map context, Vector invs)
4166241693
typ.setElementType(elemT);
4166341694
}
4166441695

41696+
boolean isSigned = pictureClause.cobolIsSigned();
4166541697
integerWidth = pictureClause.cobolIntegerWidth();
4166641698
fractionalWidth =
4166741699
pictureClause.cobolFractionWidth();
4166841700

4166941701
JOptionPane.showMessageDialog(null,
4167041702
"Type of " + fieldName + " is " + typ +
41703+
" Signed: " + isSigned +
4167141704
" Width: " + wdth + " " + integerWidth + " " +
4167241705
fractionalWidth,
4167341706
"",
@@ -41985,13 +42018,14 @@ else if (levelNumber >= prevLevel)
4198542018
}
4198642019
}
4198742020

41988-
JOptionPane.showMessageDialog(null,
42021+
/* JOptionPane.showMessageDialog(null,
4198942022
fieldName +
4199042023
" is subrecord of " + ownername +
4199142024
" from " + startPos,
4199242025
"",
4199342026
JOptionPane.INFORMATION_MESSAGE);
41994-
42027+
*/
42028+
4199542029
context.put("container", newent);
4199642030
context.put("previousLevel", new Integer(levelNumber));
4199742031
context.put("startPosition", new Integer(1));
@@ -42187,6 +42221,7 @@ public static boolean is88Entry(ASTTerm trm)
4218742221
int fractwidth =
4218842222
pictureClause.cobolFractionWidth();
4218942223
Type typ = pictureClause.cobolDataType();
42224+
boolean isSigned = pictureClause.cobolIsSigned();
4219042225

4219142226
ASTTerm t2 = (ASTTerm) ctrm.terms.get(1);
4219242227
if (t2.getTag().equals("dataName"))
@@ -42202,16 +42237,25 @@ public static boolean is88Entry(ASTTerm trm)
4220242237

4220342238
JOptionPane.showMessageDialog(null,
4220442239
"Type of " + fname + " is " + typ +
42205-
" Width " + wdth +
42206-
" Integer width " + intwidth +
42207-
" Fract width " + fractwidth,
42240+
" Signed: " + isSigned +
42241+
" Width: " + wdth +
42242+
" Integer width: " + intwidth +
42243+
" Fract width: " + fractwidth,
4220842244
"",
4220942245
JOptionPane.INFORMATION_MESSAGE);
4221042246

4221142247
if (typ != null)
4221242248
{ String dval = typ.defaultValue();
4221342249
ASTTerm.setTaggedValue(fname, "defaultValue",
42214-
dval);
42250+
dval);
42251+
Constraint consV =
42252+
Constraint.getDataConstraint(fname,
42253+
typ,intwidth,fractwidth,
42254+
isSigned);
42255+
if (consV != null)
42256+
{ consV.ownerName = progname;
42257+
invs.add(consV);
42258+
}
4221542259
}
4221642260
}
4221742261
else
@@ -42290,7 +42334,8 @@ public static boolean is88Entry(ASTTerm trm)
4229042334
if (pictureClause != null)
4229142335
{ wdth = pictureClause.cobolDataWidth() * multiplicity;
4229242336
typ = pictureClause.cobolDataType();
42293-
42337+
boolean isSigned = pictureClause.cobolIsSigned();
42338+
4229442339
if (multiplicity > 1)
4229542340
{ Type elemT = typ;
4229642341
typ = new Type("Sequence", null);
@@ -42309,6 +42354,7 @@ public static boolean is88Entry(ASTTerm trm)
4230942354

4231042355
JOptionPane.showMessageDialog(null,
4231142356
"Type of " + fieldName + " is " + typ +
42357+
" Signed: " + isSigned +
4231242358
" Width: " + wdth +
4231342359
" Integer width: " + integerWidth +
4231442360
" Fraction width: " + fractionalWidth +
@@ -42334,7 +42380,15 @@ public static boolean is88Entry(ASTTerm trm)
4233442380
ASTTerm.setTaggedValue(
4233542381
fieldName, "defaultValue",
4233642382
dval);
42337-
42383+
Constraint consV =
42384+
Constraint.getDataConstraint(fieldName,
42385+
typ,integerWidth,fractionalWidth,
42386+
isSigned);
42387+
42388+
if (multiplicity == 1 && consV != null)
42389+
{ consV.ownerName = progname;
42390+
invs.add(consV);
42391+
}
4233842392
}
4233942393

4234042394
int dIndex = fieldName.lastIndexOf("$");
@@ -42778,15 +42832,15 @@ else if (multiplicity > 1 & contMult > 1)
4277842832
cent.addAttribute(att);
4277942833
ownername =
4278042834
cname.substring(0,cname.length()-6);
42781-
42835+
/*
4278242836
JOptionPane.showMessageDialog(null,
4278342837
fieldName +
4278442838
" is subrecord of " + ownername +
4278542839
" from " + startPos +
4278642840
" multiplicity " + multiplicity,
4278742841
"",
4278842842
JOptionPane.INFORMATION_MESSAGE);
42789-
42843+
*/
4279042844
// context.put("container", newent);
4279142845
// context.put("previousLevel", new Integer(levelNumber));
4279242846
// context.put("startPosition", new Integer(1));

ASTSymbolTerm.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,13 @@ public Type cobolDataType()
10461046
return null;
10471047
}
10481048

1049+
public boolean cobolIsSigned()
1050+
{ if ("S".equals(symbol))
1051+
{ return true; }
1052+
1053+
return false;
1054+
}
1055+
10491056
public Vector cobolDataDefinitions(java.util.Map context, Vector invs)
10501057
{ Vector res = new Vector();
10511058
return res;

ASTTerm.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4158,6 +4158,8 @@ public static Vector randomCompositeASTTermsForTag(
41584158

41594159
public abstract Type cobolDataType();
41604160

4161+
public abstract boolean cobolIsSigned();
4162+
41614163
public static String coefficientOfPower(ASTTerm var, int n,
41624164
ASTTerm expr)
41634165
{ // coefficient of n-th power of v in expr, n > 0

BasicExpression.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,8 @@ public boolean isExecutable()
13771377
} // d.isDeleted not valid syntax.
13781378

13791379
public boolean isPrimitive() // A number, boolean or enumeration value
1380-
{ if (umlkind == ROLE || umlkind == CLASSID) { return false; }
1380+
{ if (umlkind == ROLE || umlkind == CLASSID)
1381+
{ return false; }
13811382
// if (arrayIndex != null)
13821383
// { return (elementType != null && elementType.isPrimitive()); }
13831384

@@ -1437,10 +1438,12 @@ else if (data.equals("max") || data.equals("min") || data.equals("last") ||
14371438
} // not prim if objectRef multiple and data : {sqr, sqrt, floor, exp, sqrt,
14381439
// abs, toLower, toUpper
14391440

1440-
if (umlkind == VALUE || umlkind == VARIABLE || umlkind == CONSTANT)
1441+
if (umlkind == VALUE || umlkind == VARIABLE ||
1442+
umlkind == CONSTANT)
14411443
{ return Type.primitiveType(type); }
14421444

1443-
if (umlkind == ATTRIBUTE || umlkind == QUERY || umlkind == UPDATEOP)
1445+
if (umlkind == ATTRIBUTE || umlkind == QUERY ||
1446+
umlkind == UPDATEOP)
14441447
{ // Look it up
14451448

14461449
if (objectRef == null)
@@ -1463,6 +1466,7 @@ else if (entity != null)
14631466

14641467
// if objectRef not multiple
14651468
}
1469+
14661470
return false;
14671471
}
14681472

@@ -7876,11 +7880,11 @@ public String queryFormJava7(java.util.Map env, boolean local)
78767880
"OclDate".equals(objectRef + ""))
78777881
{ return "Ocl.getTime()"; }
78787882

7879-
if (data.startsWith("new"))
7883+
/* if (data.startsWith("new"))
78807884
{ String createdClass = data.substring(3);
78817885
if ("OclDate".equals(createdClass))
78827886
{ return "new Date()"; }
7883-
}
7887+
} */
78847888

78857889
if (data.equals("formattedString") &&
78867890
"StringLib".equals(objectRef + ""))

BehaviouralFeature.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,7 @@ public Vector formMutantCallsPython(
12691269

12701270
String testcode =
12711271
" def " + nme + "_mutation_tests_" + j + "(_self, _counts, _totals) :\n" +
1272+
" pass\n" +
12721273
code + "\n" +
12731274
" try :\n" +
12741275
call +

BinaryExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12531,7 +12531,7 @@ else if (rprim)
1253112531
{ String ll = left.unwrap(lqf);
1253212532
res = ll + " " + operator + " " + rqf;
1253312533
}
12534-
else // includes case of Strings
12534+
else // includes case of Strings and dates
1253512535
{ res = "(" + lqf + ".compareTo(" + rqf + ") " + operator + " 0)"; }
1253612536
// System.out.println("Comparitor query form: " + this + " is " + res);
1253712537
return res;

Constraint.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,75 @@ public static Constraint getConstraint(Expression inv)
138138
{ return new Constraint(new BasicExpression(true), inv); }
139139
}
140140

141+
public static Constraint getDataConstraint(String dname,
142+
Type typ, int intwidth, int fracwidth,
143+
boolean isSigned)
144+
{ if (typ == null)
145+
{ return null; }
146+
147+
if ("int".equals(typ.getName()))
148+
{ // 0 <= dname & dname <= 9999..999 for intwidth 9's
149+
BasicExpression dvar =
150+
BasicExpression.newAttributeBasicExpression(
151+
dname,typ);
152+
Expression conj1 =
153+
new BinaryExpression("<=", new BasicExpression(0),
154+
dvar);
155+
int n_nines = 9;
156+
for (int i = 2; i <= intwidth; i++)
157+
{ n_nines = n_nines*10 + 9; }
158+
159+
if (isSigned)
160+
{ conj1 =
161+
new BinaryExpression("<=",
162+
new BasicExpression(-n_nines),
163+
dvar);
164+
}
165+
166+
Expression conj2 =
167+
new BinaryExpression("<=", dvar,
168+
new BasicExpression(n_nines));
169+
Expression conj = new BinaryExpression("&", conj1, conj2);
170+
return new Constraint(new BasicExpression(true), conj);
171+
}
172+
173+
if ("double".equals(typ.getName()))
174+
{ // 0 <= dname & dname <= 9*9.9* for intwidth and
175+
// fracwidth 9's
176+
177+
BasicExpression dvar =
178+
BasicExpression.newAttributeBasicExpression(
179+
dname,typ);
180+
Expression conj1 =
181+
new BinaryExpression("<=", new BasicExpression(0.0),
182+
dvar);
183+
184+
int n_nines = 0;
185+
for (int i = 1; i <= intwidth; i++)
186+
{ n_nines = n_nines*10 + 9; }
187+
188+
double m_nines = 0.0;
189+
for (int i = 1; i <= fracwidth; i++)
190+
{ m_nines = m_nines + 9/Math.pow(10,i); }
191+
192+
193+
if (isSigned)
194+
{ conj1 =
195+
new BinaryExpression("<=",
196+
new BasicExpression(-(n_nines + m_nines)),
197+
dvar);
198+
}
199+
200+
Expression conj2 =
201+
new BinaryExpression("<=", dvar,
202+
new BasicExpression(n_nines + m_nines));
203+
Expression conj = new BinaryExpression("&", conj1, conj2);
204+
return new Constraint(new BasicExpression(true), conj);
205+
}
206+
207+
return null;
208+
}
209+
141210
public Constraint(Expression scond, Expression succdt)
142211
{ Expression ante = scond;
143212
succ = succdt;

0 commit comments

Comments
 (0)