/** * Deep clone statement to produce a new identical block. * @return Deep clone */ public Block clone() { Block copy = new Block(); copy.setAtomic(atomic); copy.statements = LanguageObject.Util.deepClone(statements, Statement.class); if (exceptionStatements != null) { copy.exceptionStatements = LanguageObject.Util.deepClone(exceptionStatements, Statement.class); } copy.exceptionGroup = this.exceptionGroup; copy.setLabel(label); return copy; }
/** * Deep clone statement to produce a new identical block. * @return Deep clone */ public Block clone() { Block copy = new Block(); copy.setAtomic(atomic); copy.statements = LanguageObject.Util.deepClone(statements, Statement.class); if (exceptionStatements != null) { copy.exceptionStatements = LanguageObject.Util.deepClone(exceptionStatements, Statement.class); } copy.exceptionGroup = this.exceptionGroup; copy.setLabel(label); return copy; }
/** * Deep clone statement to produce a new identical block. * @return Deep clone */ public Block clone() { Block copy = new Block(); copy.setAtomic(atomic); copy.statements = LanguageObject.Util.deepClone(statements, Statement.class); if (exceptionStatements != null) { copy.exceptionStatements = LanguageObject.Util.deepClone(exceptionStatements, Statement.class); } copy.exceptionGroup = this.exceptionGroup; copy.setLabel(label); return copy; }
@Test public void testWhileStatement1() throws Exception { ElementSymbol x = new ElementSymbol("x", false); //$NON-NLS-1$ Function f = new Function("+", new Expression[] { x, new Constant(new Integer(1)) }); //$NON-NLS-1$ Statement assignmentStmt = new AssignmentStatement(x, f); Block block = new Block(); block.setAtomic(true); block.setLabel("1y"); block.addStatement(assignmentStmt); BranchingStatement bs = new BranchingStatement(BranchingMode.CONTINUE); bs.setLabel("1y"); block.addStatement(bs); Criteria crit = new CompareCriteria(x, CompareCriteria.LT, new Constant(new Integer(100))); WhileStatement whileStmt = new WhileStatement(crit, block); helpStmtTest("WHILE (x < 100) \"1y\": BEGIN ATOMIC x=x+1; CONTINUE \"1y\"; END", //$NON-NLS-1$ "WHILE(x < 100)"+"\n"+ "\"1y\" : BEGIN ATOMIC"+"\n"+"x = (x + 1);\nCONTINUE \"1y\";" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ +"\n"+"END", whileStmt); //$NON-NLS-1$ //$NON-NLS-2$ }