import edu.uci.eecs.specCompiler.specExtraction.GlobalConstruct;
import edu.uci.eecs.specCompiler.specExtraction.InterfaceConstruct;
import edu.uci.eecs.specCompiler.specExtraction.PotentialCPDefineConstruct;
+import edu.uci.eecs.specCompiler.specExtraction.SequentialDefineSubConstruct;
import edu.uci.eecs.specCompiler.specExtraction.SpecConstruct;
import edu.uci.eecs.specCompiler.specExtraction.SpecExtractor;
import edu.uci.eecs.specCompiler.specExtraction.SpecNotMatchException;
GlobalConstruct construct = (GlobalConstruct) inst.construct;
ArrayList<String> newCode = new ArrayList<String>();
+ // Generate the inner class definition
+ newCode.add("class Sequential {\n");
+ newCode.add("public:\n");
+
// Generate the code in global construct first
- String globalCode = construct.code;
- int begin = 0, end = 0;
- while (end < globalCode.length()) {
- if (globalCode.charAt(end) == '\n') {
- String line = globalCode.substring(begin, end);
- newCode.add(line);
- begin = end + 1;
- }
- end++;
- }
+ SequentialDefineSubConstruct globalCode = construct.code;
+ breakCodeLines(newCode, globalCode.declareVar);
+ breakCodeLines(newCode, globalCode.defineFunc);
- // Generate code from the DefineVar and __COND_SAT__
+ // Generate code from the DefineVar, __COND_SAT__ and __ID__
+ // Generate the end of the inner class definition
+ newCode.add("};\n");
+// printCode(newCode);
+
CodeAddition addition = new CodeAddition(lineNum, newCode);
if (!codeAdditions.containsKey(inst.file)) {
codeAdditions.put(inst.file, new ArrayList<CodeAddition>());
}
codeAdditions.get(inst.file).add(addition);
}
+
+ private void breakCodeLines(ArrayList<String> newCode, String code) {
+ int begin = 0, end = 0;
+ while (end < code.length()) {
+ if (code.charAt(end) == '\n') {
+ String line = code.substring(begin, end);
+ newCode.add(line);
+ begin = end + 1;
+ }
+ end++;
+ }
+ }
+
+ private void printCode(ArrayList<String> code) {
+ for (int i = 0; i < code.size(); i++) {
+ System.out.println(code.get(i));
+ }
+ }
private void interface2Code(SpecConstruct inst) {
int lineNum = inst.endLineNum + 1;