-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added logical operators (
and
, or
, not
)
- Added a lot more parts of CFG reduction and analysis (not yet completed)
- Loading branch information
1 parent
f57018f
commit b0efca6
Showing
54 changed files
with
1,551 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Yolol.Execution; | ||
using Yolol.Grammar.AST.Expressions; | ||
|
||
namespace Yolol.Analysis.ControlFlowGraph.AST | ||
{ | ||
public class ErrorExpression | ||
: BaseExpression | ||
{ | ||
public override bool IsConstant => true; | ||
public override bool IsBoolean => false; | ||
public override bool CanRuntimeError => true; | ||
public override Value Evaluate(MachineState state) | ||
{ | ||
throw new ExecutionException("Static error"); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return "error()"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Yolol.Execution; | ||
using Yolol.Grammar.AST.Statements; | ||
|
||
namespace Yolol.Analysis.ControlFlowGraph.AST | ||
{ | ||
public class ErrorStatement | ||
: BaseStatement | ||
{ | ||
public override bool CanRuntimeError => true; | ||
public override ExecutionResult Evaluate(MachineState state) | ||
{ | ||
throw new ExecutionException("Static error"); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return "error()"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Yolol.Analysis/ControlFlowGraph/Extensions/AnalysisExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using JetBrains.Annotations; | ||
using Yolol.Analysis.TreeVisitor.Inspection; | ||
using Yolol.Grammar; | ||
using Yolol.Grammar.AST.Statements; | ||
|
||
namespace Yolol.Analysis.ControlFlowGraph.Extensions | ||
{ | ||
public static class AnalysisExtensions | ||
{ | ||
[NotNull] public static IReadOnlyCollection<VariableName> FindUnreadAssignments([NotNull] this IControlFlowGraph cfg) | ||
{ | ||
var assigned = new FindAssignedVariables(); | ||
var read = new FindReadVariables(); | ||
|
||
foreach (var bb in cfg.Vertices) | ||
{ | ||
var p = new Program(new[] {new Line(new StatementList(bb.Statements))}); | ||
assigned.Visit(p); | ||
read.Visit(p); | ||
} | ||
|
||
var result = new HashSet<VariableName>(assigned.Names.Where(n => !n.IsExternal)); | ||
result.ExceptWith(read.Names); | ||
|
||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.