diff options
author | Ed Willink | 2016-04-26 10:36:39 +0000 |
---|---|---|
committer | Ed Willink | 2016-05-02 20:46:18 +0000 |
commit | 4ff4bdd234d5d8242a7a0e50fa55b998c3d6f5ac (patch) | |
tree | c53070ef8dbfed42c3e2d2511c083bc9e8d60ffb /plugins | |
parent | ced03f45eca743fdba3cebb107f446e8dc21a9c5 (diff) | |
download | org.eclipse.qvtd-4ff4bdd234d5d8242a7a0e50fa55b998c3d6f5ac.tar.gz org.eclipse.qvtd-4ff4bdd234d5d8242a7a0e50fa55b998c3d6f5ac.tar.xz org.eclipse.qvtd-4ff4bdd234d5d8242a7a0e50fa55b998c3d6f5ac.zip |
[cs2as] Generate valid code for operations returning invalid
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java index 879cfdce8..6e7cf672b 100644 --- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java +++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java @@ -1003,26 +1003,35 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato js.appendClassReference(ReflectiveOperationException.class); js.append(" {\n"); js.pushIndentation(null); - js.append("try {\n"); - js.pushIndentation(null); - String savedLocalPrefix = localPrefix; - try { - localPrefix = cgMapping.getTransformation().getName(); - js.append("// predicates and unrealized variables\n"); - cgBody.accept(this); - js.append("return "); - js.appendValueName(cgBody); - js.append(";\n"); - } - finally { - localPrefix = savedLocalPrefix; - } - js.popIndentation(); - js.append("} catch (Throwable e) {\n"); + if (cgBody.isInvalid()) { + js.append("return handleExecutionFailure(\"" + getMappingName(cgMapping) + "\", "); + js.appendValueName(cgBody); + js.append(");\n"); + } + else { + js.append("try {\n"); js.pushIndentation(null); - js.append("return handleExecutionFailure(\"" + getMappingName(cgMapping) + "\", e);\n"); + String savedLocalPrefix = localPrefix; + try { + localPrefix = cgMapping.getTransformation().getName(); + js.append("// predicates and unrealized variables\n"); + if (!cgBody.isInlined()) { + cgBody.accept(this); + } + js.append("return "); + js.appendValueName(cgBody); + js.append(";\n"); + } + finally { + localPrefix = savedLocalPrefix; + } + js.popIndentation(); + js.append("} catch (Throwable e) {\n"); + js.pushIndentation(null); + js.append("return handleExecutionFailure(\"" + getMappingName(cgMapping) + "\", e);\n"); js.popIndentation(); js.append("}\n"); + } js.popIndentation(); js.append("}\n"); js.append("\n"); @@ -1076,19 +1085,28 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato js.appendClassReference(ReflectiveOperationException.class); js.append(" {\n"); js.pushIndentation(null); - js.append("try {\n"); - js.pushIndentation(null); - js.append("// predicates and unrealized variables\n"); - cgBody.accept(this); - js.append("return "); + if (cgBody.isInvalid()) { + js.append("return handleExecutionFailure(\"" + getMappingName(cgMapping) + "\", "); js.appendValueName(cgBody); - js.append(";\n"); - js.popIndentation(); - js.append("} catch (Throwable e) {\n"); - js.pushIndentation(null); - js.append("return handleExecutionFailure(\"" + getMappingName(cgMapping) + "\", e);\n"); - js.popIndentation(); - js.append("}\n"); + js.append(");\n"); + } + else { + js.append("try {\n"); + js.pushIndentation(null); + js.append("// predicates and unrealized variables\n"); + if (!cgBody.isInlined()) { + cgBody.accept(this); + } + js.append("return "); + js.appendValueName(cgBody); + js.append(";\n"); + js.popIndentation(); + js.append("} catch (Throwable e) {\n"); + js.pushIndentation(null); + js.append("return handleExecutionFailure(\"" + getMappingName(cgMapping) + "\", e);\n"); + js.popIndentation(); + js.append("}\n"); + } js.popIndentation(); js.append("}\n"); } |