Skip to content

Commit 8fbf5e3

Browse files
committed
bug fix: update spec and unsimpagationize
1 parent c994adc commit 8fbf5e3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/compile/RulesetCompiler.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public static void processMembrane(Membrane mem) {
154154
InterpretedRuleset ruleset = new InterpretedRuleset();
155155
// guard or 用に and のみを含むように分割したルールを合成する
156156
// -O3 前提
157+
int maxlocals = 0;
157158
for (int itr = 0; itr < mem.or_pairs.size(); itr++) {
158159
LinkedList<Integer> pair = (LinkedList) mem.or_pairs.get(itr);
159160
if (pair.size() > 1) { // guard or を含む場合
@@ -162,6 +163,9 @@ public static void processMembrane(Membrane mem) {
162163
notAdd.add(pair.get(i));
163164
InstructionList orlist = new InstructionList();
164165
orlist.insts = InstructionList.cloneInstructions(rules.get(pair.get(i)).memMatch);
166+
if(orlist.insts.get(0).getIntArg2() > maxlocals){
167+
maxlocals = orlist.insts.get(0).getIntArg2();
168+
}
165169
for (Instruction instr : rules.get(pair.get(i)).memMatch) {
166170
if (instr.getKind() == Instruction.ORDUMMY) { // ordummy 以降の命令をすべて branch で囲む
167171
orlist.insts.remove(0);
@@ -174,6 +178,11 @@ public static void processMembrane(Membrane mem) {
174178
}
175179
// ordummy を guard or を表す branch 命令の列に置き換える
176180
List<Instruction> replace = rules.get(pair.get(0)).memMatch;
181+
Instruction spec = replace.get(0);
182+
if(spec.getIntArg2() > maxlocals){
183+
maxlocals = spec.getIntArg2();
184+
}
185+
spec.updateSpec(spec.getIntArg1(), maxlocals);
177186
for (int i = 0; i < replace.size(); i++) {
178187
if (replace.get(i).getKind() == Instruction.ORDUMMY) {
179188
replace.addAll(i + 1, orlists.insts);

src/compile/parser/SrcRule.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,18 @@ public void addTypeConstraint(LinkedList l) {
226226
*/
227227
private void unSimpagationize(List head2) {
228228
// head を全てbodyへコピー (前に追加のほうが再利用の上でも都合がいい?)
229-
body.addAll(copySrcs(head));
229+
if(body.get(0) instanceof LinkedList){
230+
for (int i=0; i<body.size(); i++) {
231+
if(body.get(i) instanceof LinkedList){
232+
LinkedList b = (LinkedList)body.get(i);
233+
b.addAll(copySrcs(head));
234+
}
235+
}
236+
}
237+
else{
238+
body.addAll(copySrcs(head));
239+
}
240+
230241
// head2をheadの後ろに連結
231242
head.addAll(head2);
232243
}

0 commit comments

Comments
 (0)