diff --git a/ASTCompositeTerm.class b/ASTCompositeTerm.class index f2679f57..80312af3 100644 Binary files a/ASTCompositeTerm.class and b/ASTCompositeTerm.class differ diff --git a/ASTCompositeTerm.java b/ASTCompositeTerm.java index bc63e7ca..17675d95 100644 --- a/ASTCompositeTerm.java +++ b/ASTCompositeTerm.java @@ -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) @@ -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( @@ -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(); @@ -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); @@ -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(); @@ -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(); @@ -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) && @@ -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); @@ -25092,6 +25099,8 @@ else if ("toBinaryString".equals(called) && "decimal2binary", "MathLib", parms); } + // JOptionPane.showInputDialog(">> " + expression); + return "MathLib.decimal2binary(" + callp1 + ")"; } else if ("toHexString".equals(called) && @@ -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 + "()"; @@ -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"); @@ -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) || @@ -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); diff --git a/AssertStatement.class b/AssertStatement.class index 56ec2f59..2a1449db 100644 Binary files a/AssertStatement.class and b/AssertStatement.class differ diff --git a/AssignStatement.class b/AssignStatement.class index f7439bfe..cd03f7a5 100644 Binary files a/AssignStatement.class and b/AssignStatement.class differ diff --git a/BreakStatement.class b/BreakStatement.class index a7dabd48..47ca8f32 100644 Binary files a/BreakStatement.class and b/BreakStatement.class differ diff --git a/CaseStatement.class b/CaseStatement.class index fbe2ea6f..f3dce180 100644 Binary files a/CaseStatement.class and b/CaseStatement.class differ diff --git a/CatchStatement.class b/CatchStatement.class index 01b64817..c58e4fd9 100644 Binary files a/CatchStatement.class and b/CatchStatement.class differ diff --git a/ConditionalStatement.class b/ConditionalStatement.class index d5e898a9..553334c9 100644 Binary files a/ConditionalStatement.class and b/ConditionalStatement.class differ diff --git a/ContinueStatement.class b/ContinueStatement.class index 000dd636..46ae69d4 100644 Binary files a/ContinueStatement.class and b/ContinueStatement.class differ diff --git a/CreationStatement.class b/CreationStatement.class index adad0954..73a0f4b3 100644 Binary files a/CreationStatement.class and b/CreationStatement.class differ diff --git a/ErrorStatement.class b/ErrorStatement.class index 7636335b..fd282a5a 100644 Binary files a/ErrorStatement.class and b/ErrorStatement.class differ diff --git a/FinalStatement.class b/FinalStatement.class index e05fbc13..46d536b9 100644 Binary files a/FinalStatement.class and b/FinalStatement.class differ diff --git a/IfCase.class b/IfCase.class index 3361fd2c..6b82d48c 100644 Binary files a/IfCase.class and b/IfCase.class differ diff --git a/IfStatement.class b/IfStatement.class index 8915145b..d14937d3 100644 Binary files a/IfStatement.class and b/IfStatement.class differ diff --git a/ImplicitInvocationStatement.class b/ImplicitInvocationStatement.class index 3d76e8f0..b06155a6 100644 Binary files a/ImplicitInvocationStatement.class and b/ImplicitInvocationStatement.class differ diff --git a/InvocationStatement.class b/InvocationStatement.class index 322bf9e5..c2865a81 100644 Binary files a/InvocationStatement.class and b/InvocationStatement.class differ diff --git a/ReturnStatement.class b/ReturnStatement.class index 91ec5c2d..b2fb6d90 100644 Binary files a/ReturnStatement.class and b/ReturnStatement.class differ diff --git a/SequenceStatement.class b/SequenceStatement.class index 297901d1..aeaaffb0 100644 Binary files a/SequenceStatement.class and b/SequenceStatement.class differ diff --git a/Statement.class b/Statement.class index 049e07c3..fde4f1f4 100644 Binary files a/Statement.class and b/Statement.class differ diff --git a/Statement.java b/Statement.java index d59cdc93..c92fe180 100644 --- a/Statement.java +++ b/Statement.java @@ -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; } diff --git a/TryStatement.class b/TryStatement.class index 9e44e2a0..c7373f2e 100644 Binary files a/TryStatement.class and b/TryStatement.class differ diff --git a/WhileStatement.class b/WhileStatement.class index d73b9e9a..b5b43d8b 100644 Binary files a/WhileStatement.class and b/WhileStatement.class differ