Skip to content
Snippets Groups Projects
Commit d65fe7c2 authored by Mikhail Chernousov's avatar Mikhail Chernousov
Browse files

Module7: kinda fixed

parent 837d44b5
No related merge requests found
Pipeline #5884 passed with warnings with stages
in 6 minutes and 56 seconds
......@@ -37,6 +37,16 @@ namespace SimpleLang.Visitors
if(inCycle > 0) opsInCycles++;
base.VisitAssignNode(n);
}
public override void VisitWriteNode(WriteNode n)
{
if (inCycle > 0) opsInCycles++;
base.VisitWriteNode(n);
}
public override void VisitVarDefNode(VarDefNode n)
{
if (inCycle > 0) opsInCycles++;
base.VisitVarDefNode(n);
}
}
}
......@@ -9,6 +9,7 @@ namespace SimpleLang.Visitors
public class ExprComplexityVisitor : AutoVisitor
{
List<int> Complex = new List<int>();
bool stop = false;
bool inner = false;
public List<int> getComplexityList()
{
......@@ -41,12 +42,35 @@ namespace SimpleLang.Visitors
inner = newValue;
}
public override void VisitIdNode(IdNode num)
{
if (!stop && !inner)
{
Complex.Add(0);
}
base.VisitIdNode(num);
}
public override void VisitVarDefNode(VarDefNode w)
{
stop = true;
base.VisitVarDefNode(w);
stop = false;
}
public override void VisitAssignNode(AssignNode num)
{
stop = true;
base.VisitAssignNode(num);
stop = false;
}
public override void VisitIntNumNode(IntNumNode num)
{
if (!inner)
{
Complex.Add(0);
}
base.VisitIntNumNode(num);
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment