X-Git-Url: http://plrg.eecs.uci.edu/git/?p=cdsspec-compiler.git;a=blobdiff_plain;f=src%2Fedu%2Fuci%2Feecs%2FspecCompiler%2FcodeGenerator%2FSemanticsChecker.java;h=cb5792a892eb0a37d7444503fc3419e0d79d222c;hp=74b48a237fdee48b6aec848736e0bb6ef5416f05;hb=b870b2732f7a88f0804510bd5c88d0b5d6d4ddd3;hpb=01b38b1079dea8b5d197bc246d7aced60496edff diff --git a/src/edu/uci/eecs/specCompiler/codeGenerator/SemanticsChecker.java b/src/edu/uci/eecs/specCompiler/codeGenerator/SemanticsChecker.java index 74b48a2..cb5792a 100644 --- a/src/edu/uci/eecs/specCompiler/codeGenerator/SemanticsChecker.java +++ b/src/edu/uci/eecs/specCompiler/codeGenerator/SemanticsChecker.java @@ -31,8 +31,11 @@ public class SemanticsChecker { public final HashMap> CPLabel2InterfaceConstruct; public final HashMap interface2Num; + public final HashMap num2Interface; public final HashMap hbLabel2Num; + public final HashMap num2HBLabel; public final HashMap commitPointLabel2Num; + public final HashMap num2CommitPointLabel; private HashMap options; private HashMap> hbConditions; @@ -40,7 +43,7 @@ public class SemanticsChecker { private ClassBeginConstruct classBeginConstruct; private ClassEndConstruct classEndConstruct; private GlobalConstruct globalConstruct; - + private String templateStr; private String templateFullStr; private String className; @@ -62,41 +65,45 @@ public class SemanticsChecker { this.classEndConstruct = null; this.interface2Num = new HashMap(); + this.num2Interface = new HashMap(); this.hbLabel2Num = new HashMap(); + this.num2HBLabel = new HashMap(); // Immediately init the true HB-condition to be 0 hbLabel2Num.put("", 0); + num2HBLabel.put(0, ""); this.commitPointLabel2Num = new HashMap(); + this.num2CommitPointLabel = new HashMap(); _interfaceNum = 0; _hbLabelNum = 0; _commitPointNum = 0; - + templateStr = null; templateFullStr = null; className = null; } - + public ClassBeginConstruct getClassBeginConstruct() { return this.classBeginConstruct; } - + public ClassEndConstruct getClassEndConstruct() { return this.classEndConstruct; } - + public String getTemplateFullStr() { return this.templateFullStr; } - + public String getTemplateStr() { return this.templateStr; } - + public String getClassName() { return this.className; } - + public GlobalConstruct getGlobalConstruct() { return this.globalConstruct; } @@ -104,13 +111,15 @@ public class SemanticsChecker { public HashMap> getHBConditions() { return this.hbConditions; } - + /** * Check if the conditional interface is in the HB checking list + * * @param condInterface * @return */ - public boolean containsConditionalInterface(ConditionalInterface condInterface) { + public boolean containsConditionalInterface( + ConditionalInterface condInterface) { if (hbConditions.containsKey(condInterface)) return true; for (ConditionalInterface key : hbConditions.keySet()) { @@ -142,6 +151,7 @@ public class SemanticsChecker { // Number the HB-condition label hbLabel2Num.put(label, _hbLabelNum++); + num2HBLabel.put(_hbLabelNum, label); } } @@ -194,6 +204,7 @@ public class SemanticsChecker { } // Number the interface label interface2Num.put(iConstruct.name, _interfaceNum++); + num2Interface.put(_interfaceNum, iConstruct.name); interfaceName2Construct.put(iConstruct.name, (InterfaceConstruct) constructs.get(i)); @@ -238,8 +249,9 @@ public class SemanticsChecker { PotentialCPDefineConstruct theConstruct = (PotentialCPDefineConstruct) construct; label = theConstruct.label; checkLabelDuplication(construct, label); - // Number the commit_point label + // Number the commit point potential commit point label commitPointLabel2Num.put(label, _commitPointNum++); + num2CommitPointLabel.put(_commitPointNum, label); potentialCPLabel2Construct.put(label, (PotentialCPDefineConstruct) construct); @@ -247,16 +259,18 @@ public class SemanticsChecker { CPDefineCheckConstruct theConstruct = (CPDefineCheckConstruct) construct; label = theConstruct.label; checkLabelDuplication(construct, label); - // Number the commit_point label + // Number the commit point define check label commitPointLabel2Num.put(label, _commitPointNum++); + num2CommitPointLabel.put(_commitPointNum, label); CPLabel2Construct.put(label, construct); } else if (construct instanceof CPDefineConstruct) { CPDefineConstruct theConstruct = (CPDefineConstruct) construct; label = theConstruct.label; checkLabelDuplication(construct, label); - // Number the commit_point label + // Number the commit point define label commitPointLabel2Num.put(label, _commitPointNum++); + num2CommitPointLabel.put(_commitPointNum, label); CPLabel2Construct.put(label, construct); } else if (construct instanceof EntryPointConstruct) { @@ -271,17 +285,20 @@ public class SemanticsChecker { interfaceName2DefineConstruct.put(name, theConstruct); } else if (construct instanceof ClassBeginConstruct) { classBeginConstruct = (ClassBeginConstruct) construct; - ArrayList content = srcFilesInfo.get(classBeginConstruct.file).content; - String firstLine = content.get(classBeginConstruct.beginLineNum), secondLine; + ArrayList content = srcFilesInfo + .get(classBeginConstruct.file).content; + String firstLine = content + .get(classBeginConstruct.beginLineNum + 1), secondLine; if (firstLine.startsWith("template")) { - secondLine = content.get(classBeginConstruct.beginLineNum + 1); + secondLine = content + .get(classBeginConstruct.beginLineNum + 1); templateFullStr = firstLine; templateStr = ParserUtils.getTemplateStr(firstLine); className = ParserUtils.getClassName(secondLine); } else { className = ParserUtils.getClassName(firstLine); } - + } else if (construct instanceof ClassEndConstruct) { classEndConstruct = (ClassEndConstruct) construct; className = getOption("CLASS");