Skip to content

Commit

Permalink
Improved Java-to-UML mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlano authored Dec 1, 2024
1 parent 3591810 commit bfddb6d
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 48 deletions.
Binary file modified ASTCompositeTerm.class
Binary file not shown.
117 changes: 69 additions & 48 deletions ASTCompositeTerm.java
Original file line number Diff line number Diff line change
Expand Up @@ -23625,8 +23625,9 @@ public String featureAccess(ASTTerm arg, ASTTerm call, String args, String calls
Expression argexpr = arg.expression;
// assumes already defined

System.out.println(">>> Featureaccess: " + args + " . " + calls);
System.out.println(">>> literal forms: " + argliteral);
// JOptionPane.showInputDialog(">>> Featureaccess: " + args +
// " . " + calls + "\n" +
// ">>> literal forms: " + argliteral);


if (call instanceof ASTCompositeTerm)
Expand All @@ -23643,8 +23644,8 @@ public String featureAccess(ASTTerm arg, ASTTerm call, String args, String calls
"explicitGenericInvocationSuffix"))
{ Vector callterms = callterm.terms;
String called = callterms.get(0) + "";
System.out.println(">> Method call " + args +
" . " + called + " " + callterms);
// JOptionPane.showInputDialog(">> Method call " + args +
// " . " + called + " " + callterms);

ASTTerm callargs;
if (callterm.tag.equals(
Expand Down Expand Up @@ -23779,7 +23780,7 @@ else if ("println".equals(called) ||
else
{ sideEffect = null; }

JOptionPane.showInputDialog(">>> Side effect of println is: " + sideEffect);
// JOptionPane.showInputDialog(">>> Side effect of println is: " + sideEffect);

String res = arg1.queryForm();

Expand Down Expand Up @@ -23835,7 +23836,8 @@ else if ("toRadians".equals(called) && "Math".equals(args))
ASTTerm.setType(thisliteral,"double");

if (callarg1.expression != null)
{ BasicExpression conver = new BasicExpression(0.017453292519943295);
{ BasicExpression conver =
new BasicExpression(0.017453292519943295);
expression =
new BinaryExpression("*", conver, callarg1.expression);
expression.setBrackets(true);
Expand Down Expand Up @@ -24883,7 +24885,8 @@ else if ("valueOf".equals(called) && "Boolean".equals(argliteral))

return "((" + callp1 + ") + \"\")->toBoolean()";
}
else if ("valueOf".equals(called) && "BigInteger".equals(argliteral))
else if ("valueOf".equals(called) &&
"BigInteger".equals(argliteral))
{ ASTTerm callarg1 = (ASTTerm) cargs.get(0);
String callp1 = callarg1.toKM3();

Expand Down Expand Up @@ -24934,7 +24937,8 @@ else if (("decode".equals(called) ||
}
else if (("decode".equals(called) ||
"valueOf".equals(called) ||
"parseLong".equals(called)) &&
calls.startsWith("parseLong(")) &&
cargs.size() > 0 &&
"Long".equals(argliteral))
{ ASTTerm callarg1 = (ASTTerm) cargs.get(0);
String callp1 = callarg1.toKM3();
Expand All @@ -24946,6 +24950,8 @@ else if (("decode".equals(called) ||
expression = new UnaryExpression("->toLong", callarg1.expression);
}

JOptionPane.showInputDialog(">>> " + expression);

return "(" + callp1 + ")->toLong()";
}
else if ("rotateRight".equals(called) &&
Expand Down Expand Up @@ -25075,7 +25081,8 @@ else if (("decode".equals(called) ||

return "(" + callp1 + ")->toInteger()";
}
else if ("toBinaryString".equals(called) &&
else if ("toBinaryString".equals(called) &&
cargs.size() > 0 &&
("Integer".equals(argliteral) ||
"Long".equals(argliteral)))
{ ASTTerm callarg1 = (ASTTerm) cargs.get(0);
Expand All @@ -25092,6 +25099,8 @@ else if ("toBinaryString".equals(called) &&
"decimal2binary", "MathLib", parms);
}

// JOptionPane.showInputDialog(">> " + expression);

return "MathLib.decimal2binary(" + callp1 + ")";
}
else if ("toHexString".equals(called) &&
Expand Down Expand Up @@ -31215,7 +31224,7 @@ public String creatorQueryForm()
}


System.out.println(">>::: Constructor " + this + " for " + clsname + " " + clsliteral + " has " + cargs.size() + " arguments: " + cargs);
// JOptionPane.showInputDialog(">>::: Constructor " + this + " for " + clsname + " " + clsliteral + " has " + cargs.size() + " arguments: " + cargs);

// String basicres = clsname + ".new" + clsname + "()";

Expand Down Expand Up @@ -32341,6 +32350,46 @@ else if ("StringTokenizer".equals(cls.literalForm()) && cargs.size() == 2)

// JOptionPane.showInputDialog("**** clsname = " + clsname);

// JOptionPane.showInputDialog(">>> creation of " + clsliteral + " with " + cargs);

if (clsliteral.startsWith("BitSet") && cargs.size() == 0)
{ ASTTerm.setType(this,"Sequence(boolean)");

Vector pars = new Vector();
pars.add(unitExpression);
pars.add(new BasicExpression(64));

Expression subr =
BasicExpression.newStaticCallBasicExpression(
"subrange", "Integer", pars);
expression =
new BinaryExpression("->collect", subr,
new BasicExpression(false));

return "Integer.subrange(1,64)->collect(false)";
}

if (clsliteral.startsWith("BitSet") && cargs.size() > 0)
{ ASTTerm.setType(this,"Sequence(boolean)");
ASTTerm strarg = (ASTTerm) cargs.get(0);
String argocl = strarg.toKM3();

if (strarg.expression != null)
{ Vector pars = new Vector();
pars.add(unitExpression);
pars.add(strarg.expression);

Expression subr =
BasicExpression.newStaticCallBasicExpression(
"subrange", "Integer", pars);
expression =
new BinaryExpression("->collect", subr,
new BasicExpression(false));
}

return "Integer.subrange(1," + argocl + ")->collect(false)";
}

if (("Set".equals(clsname) ||
clsname.startsWith("Set(")) && cargs.size() == 0)
{ ASTTerm.setType(this,"Set");
Expand Down Expand Up @@ -32444,43 +32493,6 @@ else if (strarg.expression != null)
return "Sequence{}->union" + args1;
}

if ("BitSet".equals(cls.literalForm()) && cargs.size() == 0)
{ ASTTerm.setType(this,"Sequence(boolean)");

Vector pars = new Vector();
pars.add(unitExpression);
pars.add(new BasicExpression(64));

Expression subr =
BasicExpression.newStaticCallBasicExpression(
"subrange", "Integer", pars);
expression =
new BinaryExpression("->collect", subr,
new BasicExpression(false));

return "Integer.subrange(1,64)->collect(false)";
}

if ("BitSet".equals(cls.literalForm()) && cargs.size() > 0)
{ ASTTerm.setType(this,"Sequence(boolean)");
ASTTerm strarg = (ASTTerm) cargs.get(0);
String argocl = strarg.toKM3();

if (strarg.expression != null)
{ Vector pars = new Vector();
pars.add(unitExpression);
pars.add(strarg.expression);

Expression subr =
BasicExpression.newStaticCallBasicExpression(
"subrange", "Integer", pars);
expression =
new BinaryExpression("->collect", subr,
new BasicExpression(false));
}

return "Integer.subrange(1," + argocl + ")->collect(false)";
}

if (clsliteral.startsWith("Pair") &&
("Map".equals(clsname) ||
Expand Down Expand Up @@ -36531,7 +36543,16 @@ else if (terms.size() > 2 && "try".equals(terms.get(0) + ""))
else
{ statement = new TryStatement(new SequenceStatement()); }

for (int i = 2; i < terms.size(); i++)
int clausesStart = 2;

if (tbody.hasTag("resourceSpecification"))
{ ASTTerm ttbody = (ASTTerm) terms.get(2);
res = res + " " + ttbody.toKM3();
((TryStatement) statement).addBody(ttbody.statement);
clausesStart = 3;
}

for (int i = clausesStart; i < terms.size(); i++)
{ ASTTerm tt = (ASTTerm) terms.get(i);
res = res + " " + tt.toKM3();
System.out.println(">>> Statement of " + tt + " is: " + tt.statement);
Expand Down
Binary file modified AssertStatement.class
Binary file not shown.
Binary file modified AssignStatement.class
Binary file not shown.
Binary file modified BreakStatement.class
Binary file not shown.
Binary file modified CaseStatement.class
Binary file not shown.
Binary file modified CatchStatement.class
Binary file not shown.
Binary file modified ConditionalStatement.class
Binary file not shown.
Binary file modified ContinueStatement.class
Binary file not shown.
Binary file modified CreationStatement.class
Binary file not shown.
Binary file modified ErrorStatement.class
Binary file not shown.
Binary file modified FinalStatement.class
Binary file not shown.
Binary file modified IfCase.class
Binary file not shown.
Binary file modified IfStatement.class
Binary file not shown.
Binary file modified ImplicitInvocationStatement.class
Binary file not shown.
Binary file modified InvocationStatement.class
Binary file not shown.
Binary file modified ReturnStatement.class
Binary file not shown.
Binary file modified SequenceStatement.class
Binary file not shown.
Binary file modified Statement.class
Binary file not shown.
16 changes: 16 additions & 0 deletions Statement.java
Original file line number Diff line number Diff line change
Expand Up @@ -10818,6 +10818,22 @@ else if (ends.size() == 1)
}
}

public void addBody(Statement stat)
{ if (stat == null)
{ return; }

if (body == null)
{ body = stat; }
else if (body instanceof SequenceStatement)
{ ((SequenceStatement) body).addStatement(stat); }
else
{ SequenceStatement ss = new SequenceStatement();
ss.addStatement(body);
ss.addStatement(stat);
body = ss;
}
}

public void setClauses(Vector stats)
{ catchClauses = stats; }

Expand Down
Binary file modified TryStatement.class
Binary file not shown.
Binary file modified WhileStatement.class
Binary file not shown.

0 comments on commit bfddb6d

Please sign in to comment.