19 private readonly Dictionary<BadExpression, BadExpression[]>
m_Cases;
36 List<BadExpression>? defaultCase) : base(false, position)
51 public IDictionary<BadExpression, BadExpression[]>
Cases =>
m_Cases;
65 yield
return branch.Key;
69 yield
return valueExpr;
86 KeyValuePair<BadExpression, BadExpression[]>[] branches =
m_Cases.ToArray();
113 if (defaultCase ==
null)
138 valueResult = valueResult.Dereference(
Position);
147 bool executeNextBlock =
false;
151 if (!executeNextBlock)
155 foreach (
BadObject o
in switchContext.Execute(branch.Key))
160 keyResult = keyResult.Dereference(
Position);
172 result = result.Dereference(
Position);
179 executeNextBlock = b.Value;
182 if (executeNextBlock && branch.Value.Length > 0)
184 foreach (
BadObject o
in switchContext.Execute(branch.Value))
188 if (switchContext.Scope.IsBreak)
204 if (switchContext.Scope.IsBreak)
Describes a specific position inside a source file.
Implements a simple constant folding optimization.
static BadExpression Optimize(BadExpression expr)
Optimizes the given expression.
Base Implementation for all Expressions used inside the Script.
BadSourcePosition Position
The source Position of the Expression.
Implements the Equality Expression LEFT == RIGHT.
static IEnumerable< BadObject > EqualWithOverride(BadExecutionContext? caller, BadObject left, BadObject right, BadSourcePosition position)
Executes the operator override for the given operator name.
Implements the Switch Statement Expression.
override void Optimize()
Uses the Constant Folding Optimizer to optimize the expression.
readonly Dictionary< BadExpression, BadExpression[]> m_Cases
The Cases.
IDictionary< BadExpression, BadExpression[]> Cases
The Cases.
void SetDefaultCase(IEnumerable< BadExpression >? defaultCase)
Sets the Default Case.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
BadSwitchExpression(BadSourcePosition position, BadExpression value, Dictionary< BadExpression, BadExpression[]> cases, List< BadExpression >? defaultCase)
Constructs a new BadSwitchExpression.
override IEnumerable< BadExpression > GetDescendants()
IEnumerable< BadExpression >? DefaultCase
The (optional) Default Case.
List< BadExpression >? m_DefaultCase
The (optional) Default Case.
BadExpression Value
The Value to switch on.
The Execution Context. Every execution of a script needs a context the script is running in....
Gets thrown by the runtime.
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
The Base Class for all BadScript Objects.
static readonly BadObject Null
The Null Value for the BadScript Language.
Implements the Interface for Native Boolean.
Contains Shared Data Structures and Functionality.
Contains the BadScript2 Constant Folding Optimizations.
Contains the Comparison Expressions for the BadScript2 Language.
Contains the Block Expressions for the BadScript2 Language.
Contains the Error Objects for the BadScript2 Language.
Contains the Native Runtime Objects.
Contains the Runtime Objects.
Contains the Runtime Implementation.
BadScopeFlags
Defines Different Behaviours for the Current Scope.