28 private readonly List<BadExpression>
m_Body;
45 IEnumerable<BadExpression> body,
65 public void SetBody(IEnumerable<BadExpression> body)
77 for (
int i = 0; i <
m_Body.Count; i++)
88 yield
return expression;
93 yield
return descendant;
152 target = newTarget.Dereference();
194 foreach (
BadObject? o
in action(() => bBreak =
true, loopContext, current.Dereference()))
216 "Enumerator MoveNext did not return a boolean",
233 target = target.Dereference();
244 current = current.Dereference();
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.
IEnumerable< BadExpression > GetDescendantsAndSelf()
Returns all Descendants of the Expression and the Expression itself.
BadSourcePosition Position
The source Position of the Expression.
IEnumerable< BadObject > Execute(BadExecutionContext context)
Evaluates the Expression within the current Execution Context.
Implements the For Each Expression.
override void Optimize()
Uses the Constant Folding Optimizer to optimize the expression.
readonly BadWordToken LoopVariable
The Variable Name of the Current Loop iteration.
void SetBody(IEnumerable< BadExpression > body)
Sets the Body of the Loop.
BadExpression Target
The Enumerable/Enumerator Expression of the Loop.
static IEnumerable< BadObject > Enumerate(BadExecutionContext context, BadObject target, BadSourcePosition position, Func< Action, BadExecutionContext, BadObject, IEnumerable< BadObject > > action)
static BadFunction BadFunction getCurrent FindEnumerator(BadObject target, BadExecutionContext context, BadSourcePosition position)
static BadFunction moveNext
Helper Function that returns the MoveNext/GetCurrent function of the Target.
IEnumerable< BadExpression > Body
The Loop Body.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
readonly List< BadExpression > m_Body
The Loop Body.
BadForEachExpression(BadExpression target, BadWordToken loopVariable, IEnumerable< BadExpression > body, BadSourcePosition position)
Constructor of the For Each Expression.
override IEnumerable< BadExpression > GetDescendants()
IEnumerable< BadObject > LoopBody(Action breakLoop, BadExecutionContext loopContext, BadObject current)
string Text
The Text Representation of the Token.
The Execution Context. Every execution of a script needs a context the script is running in....
IEnumerable< BadObject > Execute(IEnumerable< BadExpression > expressions)
Executes an enumeration of expressions.
BadScope Scope
The Root Scope of the Context.
BadScope CreateChild(string name, BadScope? caller, bool? useVisibility, BadScopeFlags flags=BadScopeFlags.RootScope)
Creates a subscope of the current scope.
bool IsBreak
Is true if the Break Keyword was set.
BadObject? ReturnValue
The Return value of the scope.
void DefineVariable(string name, BadObject value, BadScope? caller=null, BadPropertyInfo? info=null, BadObject[]? attributes=null)
Defines a new Variable in the current scope.
Gets thrown by the runtime.
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
The Base Class for all BadScript Objects.
virtual BadObjectReference GetProperty(string propName, BadScope? caller=null)
Returns a Reference to the Property with the given Name.
virtual bool HasProperty(string propName, BadScope? caller=null)
Returns true if the object contains a given property or there exists an extension for the current Ins...
static readonly BadObject Null
The Null Value for the BadScript Language.
Implements a function that can be called from the script.
IEnumerable< BadObject > Invoke(BadObject[] args, BadExecutionContext caller)
Invokes the function with the specified arguments.
Implements the Interface for Native Boolean.
new bool Value
The Boolean Value.
Contains Shared Data Structures and Functionality.
Contains the BadScript2 Constant Folding Optimizations.
Contains the Loop Expressions for the BadScript2 Language.
Contains the Reader Tokens for the BadScript2 Language.
Contains the Error Objects for the BadScript2 Language.
Contains Runtime Function Objects.
Contains the Native Runtime Objects.
Contains the Runtime Objects.
Contains the Runtime Implementation.
BadScopeFlags
Defines Different Behaviours for the Current Scope.