01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.rule.metaconstruct;
12:
13: import de.uka.ilkd.key.java.ProgramElement;
14: import de.uka.ilkd.key.java.Services;
15: import de.uka.ilkd.key.java.Statement;
16: import de.uka.ilkd.key.java.StatementBlock;
17: import de.uka.ilkd.key.java.statement.For;
18: import de.uka.ilkd.key.java.statement.LoopInit;
19: import de.uka.ilkd.key.rule.inst.SVInstantiations;
20: import de.uka.ilkd.key.util.Debug;
21:
22: public class Unpack extends ProgramMetaConstruct {
23:
24: /** creates a typeof ProgramMetaConstruct
25: * @param expr the instance of expression contained by
26: * the meta construct
27: */
28: public Unpack(For loop) {
29: super ("unpack", loop);
30: }
31:
32: /**
33: * performs the program transformation needed for symbolic
34: * program transformation
35: * @return the transformated program
36: */
37: public ProgramElement symbolicExecution(ProgramElement pe,
38: Services services, SVInstantiations svInst) {
39: Debug.assertTrue(pe instanceof For, "Unpack cannot handle "
40: + pe);
41: final For astFor = (For) pe;
42: final Statement[] loopInitStatementList = new Statement[astFor
43: .getInitializers().size() + 1];
44: for (int i = 0; i < loopInitStatementList.length - 1; i++) {
45: loopInitStatementList[i] = astFor.getInitializers()
46: .getLoopInitializer(i);
47: }
48:
49: loopInitStatementList[loopInitStatementList.length - 1] = new For(
50: (LoopInit) null, astFor.getGuard(), astFor
51: .getIForUpdates(), astFor.getBody());
52: return new StatementBlock(loopInitStatementList);
53: }
54: }
|