BadScript 2
Loading...
Searching...
No Matches
BadNamedExportExpression.cs
Go to the documentation of this file.
6
8
13{
20 public BadNamedExportExpression(string? name, BadExpression expression, BadSourcePosition position) : base(false, position)
21 {
22 Expression = expression;
23 Name = name;
24 }
25
29 public BadExpression Expression { get; private set; }
30
34 public string? Name { get; }
35
37 public override IEnumerable<BadExpression> GetDescendants()
38 {
40 }
41
43 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
44 {
45 if (string.IsNullOrEmpty(Name))
46 {
47 throw BadRuntimeException.Create(context.Scope, "Exported objects must have a name", Position);
48 }
49
50 BadObject? result = BadObject.Null;
51 foreach (BadObject o in Expression.Execute(context))
52 {
53 result = o;
54
55 yield return o;
56 }
57
58 result = result.Dereference();
59
60 context.Scope.AddExport(Name!, result);
61
62 yield return result;
63 }
64
66 public override void Optimize()
67 {
69 }
70
72 public override string ToString()
73 {
74 return $"export {Expression}";
75 }
76}
Describes a specific position inside a source file.
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.
BadNamedExportExpression(string? name, BadExpression expression, BadSourcePosition position)
Creates a new Named Export Expression.
override void Optimize()
Uses the Constant Folding Optimizer to optimize the expression.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
The Execution Context. Every execution of a script needs a context the script is running in....
BadScope Scope
The Root Scope of the Context.
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
static readonly BadObject Null
The Null Value for the BadScript Language.
Definition BadObject.cs:28
Contains Shared Data Structures and Functionality.
Contains the BadScript2 Constant Folding Optimizations.
Contains the Error Objects for the BadScript2 Language.
Contains the Runtime Objects.
Definition BadArray.cs:10
Contains the Runtime Implementation.