BadScript 2
Loading...
Searching...
No Matches
BadExpressionPath.cs
Go to the documentation of this file.
2
4
8public class BadExpressionPath
9{
13 private readonly List<BadExpressionPath> m_ChildPaths = new List<BadExpressionPath>();
14
18 public readonly BadExpression Parent;
19
24
30 {
31 Parent = parent;
32 }
33
37 public bool IsValid => m_HasReturnStatement || m_ChildPaths.Count > 0 && m_ChildPaths.All(p => p.IsValid);
38
43 public IEnumerable<BadExpressionPath> GetInvalidPaths()
44 {
45 if (!m_HasReturnStatement && m_ChildPaths.Count == 0)
46 {
47 yield return this;
48 }
49 else
50 {
51 foreach (BadExpressionPath invalidPath in m_ChildPaths.SelectMany(childPath => childPath.GetInvalidPaths()))
52 {
53 yield return invalidPath;
54 }
55 }
56 }
57
63 {
64 m_ChildPaths.Add(path);
65 }
66
71 {
73 m_ChildPaths.Clear();
74 }
75}
Base Implementation for all Expressions used inside the Script.
Implements a path in a BadExpression Syntax Tree.
readonly BadExpression Parent
The Parent of this Path.
void SetHasReturnStatement()
Sets this Path to have a Return Statement.
void AddChildPath(BadExpressionPath path)
Adds a Child Path to this Path.
IEnumerable< BadExpressionPath > GetInvalidPaths()
Returns all invalid paths in this Path.
bool IsValid
Indicates whether this Path is valid(e.g. all paths have a return statement)
readonly List< BadExpressionPath > m_ChildPaths
The Child Paths of this Path.
BadExpressionPath(BadExpression parent)
Creates a new Path for the given Parent.
bool m_HasReturnStatement
Indicates whether this Path has a Return Statement.
Contains the Expressions for the BadScript2 Language.
Contains the Expression Validators for the BadScript2 Language.