Skip to content

Commit

Permalink
Update VarShadowingRenameCollector to handle iota #645
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwvj committed Sep 12, 2017
1 parent 400ccb0 commit 0839eb2
Showing 1 changed file with 35 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package org.overture.codegen.analysis.vdm;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.util.Vector;
import java.util.*;

import org.apache.log4j.Logger;
import org.overture.ast.analysis.AnalysisException;
Expand All @@ -25,23 +19,14 @@
import org.overture.ast.definitions.SFunctionDefinition;
import org.overture.ast.definitions.SOperationDefinition;
import org.overture.ast.definitions.traces.ALetBeStBindingTraceDefinition;
import org.overture.ast.expressions.ACaseAlternative;
import org.overture.ast.expressions.ACasesExp;
import org.overture.ast.expressions.AExistsExp;
import org.overture.ast.expressions.AForAllExp;
import org.overture.ast.expressions.ALambdaExp;
import org.overture.ast.expressions.ALetBeStExp;
import org.overture.ast.expressions.ALetDefExp;
import org.overture.ast.expressions.AMapCompMapExp;
import org.overture.ast.expressions.ASetCompSetExp;
import org.overture.ast.expressions.AVariableExp;
import org.overture.ast.expressions.PExp;
import org.overture.ast.expressions.*;
import org.overture.ast.intf.lex.ILexLocation;
import org.overture.ast.intf.lex.ILexNameToken;
import org.overture.ast.lex.LexNameList;
import org.overture.ast.modules.AModuleModules;
import org.overture.ast.node.INode;
import org.overture.ast.patterns.AIdentifierPattern;
import org.overture.ast.patterns.PBind;
import org.overture.ast.patterns.PMultipleBind;
import org.overture.ast.patterns.PPattern;
import org.overture.ast.statements.ABlockSimpleBlockStm;
Expand Down Expand Up @@ -279,6 +264,19 @@ public void caseAForAllExp(AForAllExp node) throws AnalysisException
handleMultipleBindConstruct(node, node.getBindList(), null, node.getPredicate());
}

@Override
public void caseAIotaExp(AIotaExp node) throws AnalysisException {

if(!proceed(node))
{
return;
}

PBind bind = node.getBind();

handleBindConstruct(node, node.getBind(), null, node.getPredicate());
}

@Override
public void caseAExistsExp(AExistsExp node) throws AnalysisException
{
Expand Down Expand Up @@ -648,12 +646,24 @@ private void handleCase(LinkedList<PDefinition> localDefs, PPattern pattern,
}
}

private void handleBindConstruct(INode node, PBind bind, PExp first, PExp pred) throws AnalysisException
{
List<PDefinition> defs = getBindDefinitions(bind);

handleBinds(node, first, pred, defs);
}

private void handleMultipleBindConstruct(INode node,
LinkedList<PMultipleBind> bindings, PExp first, PExp pred)
throws AnalysisException
{
List<PDefinition> multipleBindDefs = getMultipleBindDefs(bindings);

DefinitionInfo defInfo = new DefinitionInfo(getMultipleBindDefs(bindings), af);
handleBinds(node, first, pred, multipleBindDefs);
}

private void handleBinds(INode node, PExp first, PExp pred, List<PDefinition> multipleBindDefs) throws AnalysisException {
DefinitionInfo defInfo = new DefinitionInfo(multipleBindDefs, af);

openScope(defInfo, node);

Expand Down Expand Up @@ -685,6 +695,12 @@ private List<PDefinition> getMultipleBindDefs(List<PMultipleBind> bindings)
return defs;
}

private List<PDefinition> getBindDefinitions(PBind bind)
{
List<PMultipleBind> binds = af.createPBindAssistant().getMultipleBindList(bind);
return getMultipleBindDefs(binds);
}

public String computeNewName(String original)
{
String prefix = original + "_";
Expand Down

0 comments on commit 0839eb2

Please sign in to comment.