[ClavaLaraApi] StatementDecomposer experiment
@@ -140,13 +140,14 @@ class StatementDecomposer {
decomposeExpr($expr) {
if($expr.instanceOf("binaryOp")) {
+
return this.decomposeBinaryOp($expr);
}
if($expr.numChildren === 0) {
//if($expr.instanceOf("varref") || $expr.instanceOf("literal")) {
let stmts = [];
- let dec = new DecomposeResult(stmts, $expr);
+ //let dec = new DecomposeResult(stmts, $expr);
return new DecomposeResult(stmts, $expr);
}
@@ -159,6 +160,7 @@ class StatementDecomposer {
let kind = $binaryOp.kind;
if(kind === "assign") {
+
let stmts = [];
// Get statements of right hand-side
@@ -172,7 +174,7 @@ class StatementDecomposer {
return new DecomposeResult(stmts, $binaryOp.left);
}
// TODO: Not taking into account += and other cases
- else {
+
// Apply decompose to both sides
let leftResult = this.decomposeExpr($binaryOp.left);
@@ -191,10 +193,21 @@ class StatementDecomposer {
stmts.push(tempVarDecl.stmt);
return new DecomposeResult(stmts, ClavaJoinPoints.varRefFromDecl(tempVarDecl));
- }
- this._throwNotImplemented("binary operators", kind);
+
+ //this._throwNotImplemented("binary operators", kind);
}
}
+
+
+
+
+// Tried to remove redundant decompositions, but it seems to be a very specific case
+//
+// Special case: if both sides have no children, do nothing
+//if($expr.left.numChildren === 0 && $expr.right.numChildren === 0) {
+// let stmts = [];
+// return new DecomposeResult(stmts, $expr);
+//}
\ No newline at end of file
