BadScript 2
Loading...
Searching...
No Matches
BadRuntimeApi.cs
Go to the documentation of this file.
1using System.Globalization;
2using System.Reflection;
3using System.Runtime.InteropServices;
4
6using BadScript2.IO;
24
26
30[BadInteropApi("Runtime")]
31internal partial class BadRuntimeApi
32{
36 public static IEnumerable<string>? StartupArguments { get; set; }
37
38 protected override void AdditionalData(BadTable target)
39 {
40 target.SetProperty("Native", MakeNative());
41 }
42
48 {
49 BadTable table = new BadTable();
50
51 new BadNativeApi().LoadRawApi(table);
52
53 return table;
54 }
55
56 [BadMethod(description: "Creates a default scope based off of the root scope of the caller")]
57 [return: BadReturn("The created scope")]
59 {
60 return ctx.Scope.GetRootScope().CreateChild("<customscope>", ctx.Scope, null);
61 }
62
63 [BadMethod(description: "Evaluates a BadScript Source String")]
64 [return: BadReturn("An Awaitable Task")]
67 [BadParameter(description: "The Source of the Script")]
68 string source,
69 [BadParameter(description: "An (optional but recommended) file path, it will be used to determine the working directory of the script.")]
70 string? file = null,
71 [BadParameter(description: "If true, any optimizations that are activated in the settings will be applied.")]
72 bool optimize = true,
73 [BadParameter(
74 description:
75 "An (optional) scope that the execution takes place in, if not specified, an Instance of BadRuntime will get searched and a scope will be created from it, if its not found, a scope will be created from the root scope of the caller."
76 )]
77 BadScope? scope = null,
78 [BadParameter(
79 description:
80 "If true, the last element that was returned from the enumeration will be the result of the task. Otherwise the result will be the exported objects of the script."
81 )]
82 bool setLastAsReturn = false)
83 {
84 file = BadFileSystem.Instance.GetFullPath(file ?? "<eval>");
85
86
87 bool optimizeConstantFolding =
88 BadNativeOptimizationSettings.Instance.UseConstantFoldingOptimization && optimize;
89 bool optimizeConstantSubstitution =
90 BadNativeOptimizationSettings.Instance.UseConstantSubstitutionOptimization && optimize;
91
93 BadRuntime? runtime = caller.Scope.GetSingleton<BadRuntime>();
94 if (runtime != null && scope == null)
95 {
96 // If the runtime is available, we can use the context builder to create a new context.
97 // This is cleaner and also works better with the use of the Export Expressions.
98 ctx = runtime.CreateContext(Path.GetDirectoryName(file) ?? "/");
99 }
100 else
101 {
102 // The Old way of doing it. This was a hack initially to ensure the configured interop apis are available in the scope,
103 // even if we dont have a way to access the context builder.
104 ctx =
105 scope == null
107 caller.Scope.GetRootScope()
108 .CreateChild("<EvaluateAsync>", caller.Scope, null, BadScopeFlags.CaptureThrow)
109 )
110 : new BadExecutionContext(scope);
111 }
112
113 IEnumerable<BadExpression> exprs = BadSourceParser.Create(file, source).Parse();
114
115 if (optimizeConstantFolding)
116 {
118 }
119
120 if (optimizeConstantSubstitution)
121 {
123 }
124
125 BadTask task = null!;
126
127 IEnumerable<BadObject> executor;
128 if (setLastAsReturn) //If we want the last object as the return value, we just execute
129 {
130 executor = ctx.Execute(exprs);
131 }
132 else //Otherwise we return the exported variables of the script
133 {
134 executor = ExecuteScriptWithExports(ctx, exprs);
135 }
136
137 task = new BadTask(
139 // ReSharper disable once AccessToModifiedClosure
140 SafeExecute(executor, ctx, () => task).GetEnumerator(),
141 true
142 ),
143 "EvaluateAsync"
144 );
145
146 return task;
147 }
148
149 [BadMethod(description: "Returns the Stack Trace of the current Execution Context")]
150 [return: BadReturn("The Stack Trace")]
152 {
153 return ctx.Scope.GetStackTrace();
154 }
155
156
157 [BadMethod]
159 {
160 return ctx.Scope.GetRootScope();
161 }
162
163
164 [BadMethod(description: "Returns all Native Types")]
165 [return: BadReturn("An Array containing all Native Types")]
167 {
168 return new BadArray(BadNativeClassBuilder.NativeTypes.Cast<BadObject>().ToList());
169 }
170
171 [BadMethod(description: "Returns the Assembly Path of the current Runtime")]
172 [return: BadReturn("The Assembly Path")]
173 private string GetRuntimeAssemblyPath()
174 {
175 string path = Path.ChangeExtension(Assembly.GetEntryAssembly()!.Location, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "exe" : "");
176
177 return path;
178 }
179
180 [BadMethod(description: "Returns a new Guid")]
181 [return: BadReturn("A new Guid")]
182 private string NewGuid()
183 {
184 return Guid.NewGuid().ToString();
185 }
186
187 [BadMethod(description: "Returns true if an api with that name is registered")]
188 [return: BadReturn("True if the api is registered")]
189 private BadObject IsApiRegistered(BadExecutionContext ctx, [BadParameter(description: "The Api Name")] string api)
190 {
191 return ctx.Scope.RegisteredApis.Contains(api);
192 }
193
194 [BadMethod(description:"Creates a new Reference Object")]
195 [return: BadReturn("The Reference Object")]
198 [BadParameter(description: "The Text for the Reference")] string refText,
199 [BadParameter(description: "The getter Function")]BadFunction get,
200 [BadParameter(description: "The setter Function")]BadFunction? set = null,
201 [BadParameter(description: "The delete Function")]BadFunction? delete = null)
202 {
203 if(set == null && delete == null)
204 {
205 return BadObjectReference.Make(refText, () => GetReferenceValue(ctx, get));
206 }
207
208 if (delete == null && set != null)
209 {
210 return BadObjectReference.Make(refText,
211 () => GetReferenceValue(ctx, get),
212 (value, _) => SetReferenceValue(ctx, set, value));
213 }
214
215 if (delete != null && set == null)
216 {
217 return BadObjectReference.Make(refText,
218 () => GetReferenceValue(ctx, get),
219 (Action<BadObject, BadPropertyInfo?>?)null,
220 () => SetReferenceValue(ctx, delete, BadObject.Null));
221 }
222
223 return BadObjectReference.Make(refText,
224 () => GetReferenceValue(ctx, get),
225 (value, _) => SetReferenceValue(ctx, set!, value),
226 () => DeleteReference(ctx, delete!));
227 }
228
230 {
231 foreach (BadObject? o in func.Invoke(Array.Empty<BadObject>(), ctx))
232 {
233 }
234 }
236 {
237 BadObject? result = BadObject.Null;
238 foreach (BadObject? o in func.Invoke(Array.Empty<BadObject>(), ctx))
239 {
240 result = o;
241 }
242 return result.Dereference();
243 }
245 {
246 foreach (BadObject? o in func.Invoke(new []{value}, ctx))
247 {
248 }
249 }
250
251 [BadMethod(description: "Returns all registered apis")]
252 [return: BadReturn("An Array containing all registered apis")]
254 {
255 return new BadArray(ctx.Scope.RegisteredApis.Select(x => (BadObject)x).ToList());
256 }
257
265 [BadMethod(description: "Registers an Import Handler")]
266 private static void RegisterImportHandler(
268 [BadParameter(description: "An Import handler implementing the IImportHandler Interface", nativeType: "IImportHandler")]
269 BadClass cls)
270 {
271 BadClassPrototype proto = cls.GetPrototype();
272 if (!BadNativeClassBuilder.ImportHandler.IsSuperClassOf(proto))
273 {
274 throw BadRuntimeException.Create(ctx.Scope, "Invalid Import Handler");
275 }
276
277 BadModuleImporter? importer = ctx.Scope.GetSingleton<BadModuleImporter>();
278 if (importer == null)
279 {
280 throw BadRuntimeException.Create(ctx.Scope, "Module Importer not found");
281 }
282
283 BadInteropImportHandler handler = new BadInteropImportHandler(ctx, cls);
284 importer.AddHandler(handler);
285 }
286
293 [BadMethod("Validate", "Validates a source string")]
294 [return: BadReturn("Validation Result")]
295 private static BadTable ValidateSource([BadParameter(description: "The Source to Validate")] string source, [BadParameter(description: "The File Name")] string file)
296 {
299 BadTable ret = new BadTable();
300 ret.SetProperty("IsError", result.IsError);
301 ret.SetProperty(
302 "Messages",
303 new BadArray(
304 result.Messages.Select(
305 x =>
306 {
307 BadTable msg = new BadTable();
308 msg.SetProperty("Message", x.Message);
309 msg.SetProperty("Validator", x.Validator.ToString());
310 msg.SetProperty("Type", x.Type.ToString());
311 msg.SetProperty("Position", x.Expression.Position.ToString());
312
313 return (BadObject)msg;
314 }
315 )
316 .ToList()
317 )
318 );
319 ret.SetFunction("GetMessageString", () => result.ToString(), BadNativeClassBuilder.GetNative("string"));
320
321 return ret;
322 }
323
329 [BadMethod(description: "Parses a date string")]
330 [return: BadReturn("Bad Table with the parsed date")]
331 private static BadObject ParseDate([BadParameter(description: "The date string")] string date)
332 {
333 DateTimeOffset d = DateTimeOffset.Parse(date);
334
335 return GetDateTime(d);
336 }
337
343 private static BadTable GetDateTime(DateTimeOffset time)
344 {
345 BadTable table = new BadTable();
346 table.SetProperty("Year", time.Year, new BadPropertyInfo(BadNativeClassBuilder.GetNative("num"), true));
347 table.SetProperty("Month", time.Month, new BadPropertyInfo(BadNativeClassBuilder.GetNative("num"), true));
348 table.SetProperty("Day", time.Day, new BadPropertyInfo(BadNativeClassBuilder.GetNative("num"), true));
349 table.SetProperty("Hour", time.Hour, new BadPropertyInfo(BadNativeClassBuilder.GetNative("num"), true));
350 table.SetProperty("Minute", time.Minute, new BadPropertyInfo(BadNativeClassBuilder.GetNative("num"), true));
351 table.SetProperty("Second", time.Second, new BadPropertyInfo(BadNativeClassBuilder.GetNative("num"), true));
352 table.SetProperty("Millisecond", time.Millisecond, new BadPropertyInfo(BadNativeClassBuilder.GetNative("num"), true));
353 table.SetProperty("WeekOfYear", new BadInteropFunction("WeekOfYear", (_, args) =>
354 {
355 var c = CultureInfo.InvariantCulture;
356 if (args.Length == 1 && args[0] is IBadString str)
357 {
358 c = new CultureInfo(str.Value);
359 }
360
361 return c.Calendar.GetWeekOfYear(time.DateTime, c.DateTimeFormat.CalendarWeekRule,
362 c.DateTimeFormat.FirstDayOfWeek);
363 },
364 false,
366 new BadFunctionParameter("culture", true, false, false, null,
369 table.SetProperty("UnixTimeMilliseconds", time.ToUnixTimeMilliseconds(), new BadPropertyInfo(BadNativeClassBuilder.GetNative("num"), true));
370 table.SetProperty("UnixTimeSeconds", time.ToUnixTimeSeconds(), new BadPropertyInfo(BadNativeClassBuilder.GetNative("num"), true));
371 table.SetProperty("Offset", time.Offset.ToString(), new BadPropertyInfo(BadFunction.Prototype, true));
372
373 table.SetProperty(
374 "ToShortTimeString",
376 "ToShortTimeString",
377 args => CreateDate(
378 table,
379 args.Length < 1 ? null : ((IBadString)args[0]).Value
380 )
381 .ToShortTimeString(),
382 false,
385 "timeZone",
386 true,
387 false,
388 false,
389 null,
391 )
392 ),
394 );
395 table.SetProperty(
396 "ToShortDateString",
398 "ToShortDateString",
399 args => CreateDate(
400 table,
401 args.Length < 1 ? null : ((IBadString)args[0]).Value
402 )
403 .ToShortDateString(),
404 false,
407 "timeZone",
408 true,
409 false,
410 false,
411 null,
413 )
414 ),
416 );
417 table.SetProperty(
418 "ToLongTimeString",
420 "ToLongTimeString",
421 args => CreateDate(
422 table,
423 args.Length < 1 ? null : ((IBadString)args[0]).Value
424 )
425 .ToLongTimeString(),
426 false,
429 "timeZone",
430 true,
431 false,
432 false,
433 null,
435 )
436 ),
438 );
439 table.SetProperty(
440 "ToLongDateString",
442 "ToLongDateString",
443 args => CreateDate(
444 table,
445 args.Length < 1 ? null : ((IBadString)args[0]).Value
446 )
447 .ToLongDateString(),
448 false,
451 "timeZone",
452 true,
453 false,
454 false,
455 null,
457 )
458 ),
460 );
461
462 table.SetProperty(
463 "Format",
465 "Format",
466 args =>
467 {
468 string format = ((IBadString)args[0]).Value;
469 var c = CultureInfo.InvariantCulture;
470 if (args.Length == 3 && args[2] is IBadString str)
471 {
472 c = new CultureInfo(str.Value);
473 }
474
475 string? timeZone = args.Length < 2 ? null : (args[1] as IBadString)?.Value;
476
477 return CreateDate(
478 table,
479 timeZone
480 )
481 .ToString(format, c);
482 },
483 false,
486 "format",
487 false,
488 true,
489 false,
490 null,
492 ),
494 "timeZone",
495 true,
496 false,
497 false,
498 null,
500 ),
502 "culture",
503 true,
504 false,
505 false,
506 null,
508 )
509 ),
511 );
512
513 table.SetFunction<decimal>("AddYears", d => GetDateTime(time.AddYears((int)d)));
514 table.SetFunction<decimal>("AddMonths", d => GetDateTime(time.AddMonths((int)d)));
515 table.SetFunction<decimal>("AddDays", d => GetDateTime(time.AddDays((double)d)));
516 table.SetFunction<decimal>("AddHours", d => GetDateTime(time.AddHours((double)d)));
517 table.SetFunction<decimal>("AddMinutes", d => GetDateTime(time.AddMinutes((double)d)));
518 table.SetFunction<decimal>("AddSeconds", d => GetDateTime(time.AddSeconds((double)d)));
519 table.SetFunction<decimal>("AddMilliseconds", d => GetDateTime(time.AddMilliseconds((double)d)));
520 table.SetFunction<decimal>("AddTicks", d => GetDateTime(time.AddTicks((long)d)));
521
522 return table;
523 }
524
531 private static DateTime CreateDate(BadTable dateTable, string? timeZone = null)
532 {
533 //Convert Year, Month,Day, Hour,Minute, Second, Millisecond from IBadNumber to int
534 int year = (int)((IBadNumber)dateTable.InnerTable["Year"]).Value;
535 int month = (int)((IBadNumber)dateTable.InnerTable["Month"]).Value;
536 int day = (int)((IBadNumber)dateTable.InnerTable["Day"]).Value;
537 int hour = (int)((IBadNumber)dateTable.InnerTable["Hour"]).Value;
538 int minute = (int)((IBadNumber)dateTable.InnerTable["Minute"]).Value;
539 int second = (int)((IBadNumber)dateTable.InnerTable["Second"]).Value;
540 int millisecond = (int)((IBadNumber)dateTable.InnerTable["Millisecond"]).Value;
541 string offset = ((IBadString)dateTable.InnerTable["Offset"]).Value;
542
543 //Create Date Time from the given values
544 DateTimeOffset dtOffset =
545 new DateTimeOffset(year, month, day, hour, minute, second, millisecond, TimeSpan.Parse(offset));
546
547 DateTime dateTime = dtOffset.DateTime;
548
549 if (timeZone != null)
550 {
551 dateTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dateTime, timeZone);
552 }
553
554 return dateTime;
555 }
556
561 [BadMethod(description: "Returns the Current Time")]
562 [return: BadReturn("The Current Time")]
563 private static BadTable GetTimeNow()
564 {
565 return GetDateTime(DateTime.Now);
566 }
567
574 [BadMethod(description: "Lists all extension names of the given object")]
575 [return: BadReturn("An Array containing all Extension Names")]
576 private static BadArray GetExtensionNames(BadExecutionContext ctx, [BadParameter(description: "Object")] BadObject o)
577 {
578 return new BadArray(ctx.Scope.Provider.GetExtensionNames(o).ToList());
579 }
580
585 [BadMethod(description: "Lists all global extension names")]
586 [return: BadReturn("An Array containing all Extension Names")]
588 {
589 return new BadArray(ctx.Scope.Provider.GetExtensionNames().ToList());
590 }
591
596 [BadMethod(description: "Gets the Commandline Arguments")]
597 [return: BadReturn("An Array containing all Commandline Arguments")]
598 private static BadArray GetArguments()
599 {
600 return StartupArguments == null ? new BadArray() : new BadArray(StartupArguments.Select(x => (BadObject)x).ToList());
601 }
602
603
604 [BadMethod(description: "Gets the Attributes of the given objects members")]
605 [return: BadReturn("A Table containing the Attributes of the given objects members.")]
606 private static BadArray GetMembers(BadObject obj)
607 {
608 if (obj is BadClass cls)
609 {
610 return cls.Scope.GetMemberInfos();
611 }
612
613 return new BadArray();
614 }
615
622 private IEnumerable<BadObject> ExecuteScriptWithExports(BadExecutionContext ctx, IEnumerable<BadExpression> exprs)
623 {
624 foreach (BadObject o in ctx.Execute(exprs))
625 {
626 yield return o;
627 }
628
629 yield return ctx.Scope.GetExports();
630 }
631
639 private static IEnumerable<BadObject> SafeExecute(
640 IEnumerable<BadObject> script,
642 Func<BadTask> getTask)
643 {
644 using IEnumerator<BadObject>? enumerator = script.GetEnumerator();
645 while (true)
646 {
647 try
648 {
649 if (!enumerator.MoveNext())
650 {
651 break;
652 }
653 }
655 {
656 getTask().Runnable.SetError(e.Error);
657 break;
658 }
659 catch (Exception e)
660 {
661 getTask().Runnable.SetError(BadRuntimeError.FromException(e, ctx.Scope.GetStackTrace()));
662 break;
663 }
664 yield return enumerator.Current ?? BadObject.Null;
665 }
666 }
667}
Exposes the BadScript Runtime Functionality to Consumers.
Definition BadRuntime.cs:28
BadExecutionContext CreateContext(string workingDirectory)
Creates a new Context with the configured Options.
Public interface for the filesystem abstraction of the BadScript Engine.
static IFileSystem Instance
File System implementation.
static BadArray GetMembers(BadObject obj)
BadScope GetRootScope(BadExecutionContext ctx)
static IEnumerable< BadObject > SafeExecute(IEnumerable< BadObject > script, BadExecutionContext ctx, Func< BadTask > getTask)
Wrapper that will execute a script and catch any errors that occur.
BadObject MakeReference(BadExecutionContext ctx, [BadParameter(description:"The Text for the Reference")] string refText, [BadParameter(description:"The getter Function")]BadFunction get, [BadParameter(description:"The setter Function")]BadFunction? set=null, [BadParameter(description:"The delete Function")]BadFunction? delete=null)
static BadObject ParseDate([BadParameter(description:"The date string")] string date)
Parses a date string.
BadArray GetRegisteredApis(BadExecutionContext ctx)
static DateTime CreateDate(BadTable dateTable, string? timeZone=null)
Creates a DateTime from a BadTable.
static BadTable GetDateTime(DateTimeOffset time)
Converts a DateTimeOffset to a Bad Table.
IEnumerable< BadObject > ExecuteScriptWithExports(BadExecutionContext ctx, IEnumerable< BadExpression > exprs)
Executes a script and returns the exported variables.
static BadTable ValidateSource([BadParameter(description:"The Source to Validate")] string source, [BadParameter(description:"The File Name")] string file)
Validates a source string.
static BadTable GetTimeNow()
Returns the Current Time.
BadObject IsApiRegistered(BadExecutionContext ctx, [BadParameter(description:"The Api Name")] string api)
void DeleteReference(BadExecutionContext ctx, BadFunction func)
static ? IEnumerable< string > StartupArguments
The Startup Arguments that were passed to the Runtime.
string GetStackTrace(BadExecutionContext ctx)
void SetReferenceValue(BadExecutionContext ctx, BadFunction func, BadObject value)
BadObject GetReferenceValue(BadExecutionContext ctx, BadFunction func)
override void AdditionalData(BadTable target)
BadScope CreateDefaultScope(BadExecutionContext ctx)
static void RegisterImportHandler(BadExecutionContext ctx, [BadParameter(description:"An Import handler implementing the IImportHandler Interface", nativeType:"IImportHandler")] BadClass cls)
Registers an Import Handler.
BadTask EvaluateAsync(BadExecutionContext caller, [BadParameter(description:"The Source of the Script")] string source, [BadParameter(description:"An (optional but recommended) file path, it will be used to determine the working directory of the script.")] string? file=null, [BadParameter(description:"If true, any optimizations that are activated in the settings will be applied.")] bool optimize=true, [BadParameter(description:"An (optional) scope that the execution takes place in, if not specified, an Instance of BadRuntime will get searched and a scope will be created from it, if its not found, a scope will be created from the root scope of the caller.")] BadScope? scope=null, [BadParameter(description:"If true, the last element that was returned from the enumeration will be the result of the task. Otherwise the result will be the exported objects of the script.")] bool setLastAsReturn=false)
static BadArray GetExtensionNames(BadExecutionContext ctx, [BadParameter(description:"Object")] BadObject o)
Returns all Extension Names of the given object.
static BadArray GetArguments()
Returns the arguments passed to the script.
BadTable MakeNative()
Creates the "Native" Table.
static BadObject GetGlobalExtensionNames(BadExecutionContext ctx)
Lists all global extension names.
Implements a Runnable that can return a value.
Implements a Task Object.
Definition BadTask.cs:17
static BadExpression Optimize(BadExpression expr)
Optimizes the given expression.
Contains the Implementation of the Constant Substitution Optimization This optimization replaces expr...
static IEnumerable< BadExpression > Optimize(BadConstantSubstitutionOptimizerScope scope, IEnumerable< BadExpression > expressions)
Substitutes all variables in the expressions with their constant value.
The Parser of the Language. It turns Source Code into an Expression Tree.
static BadSourceParser Create(string fileName, string source)
Creates a BadSourceParser Instance based on the source and filename provided.
static IEnumerable< BadExpression > Parse(string fileName, string source)
Parses a BadExpression from the Source Reader.
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.
Implements the Scope for the Script Engine.
Definition BadScope.cs:238
BadScope GetRootScope()
Returns the Root Scope of the Scope.
Definition BadScope.cs:521
BadScope CreateChild(string name, BadScope? caller, bool? useVisibility, BadScopeFlags flags=BadScopeFlags.RootScope)
Creates a subscope of the current scope.
Definition BadScope.cs:792
string GetStackTrace()
Returns the Stack Trace of the Current scope.
Definition BadScope.cs:633
Gets thrown if the runtime encounters an error.
Implements the Error Object Type.
static BadRuntimeError FromException(Exception e, string? scriptStackTrace=null)
Creates a BadRuntimeError from an Exception.
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
Implements an Interop API for the BS2 Language.
Interop Function taking an array of arguments.
The Class that manages the importing of modules.
BadModuleImporter AddHandler(BadImportHandler handler)
Adds a new Import Handler to the Importer.
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17
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
Implements the base functionality for a BadScript Reference.
static BadObjectReference Make(string refText, Func< BadObject > getter, Action< BadObject, BadPropertyInfo?>? setter=null, Action? delete=null)
Creates a new Reference Object.
Stores Meta Information about a Property.
Implements a Table Structure for the BadScript Language.
Definition BadTable.cs:14
Dictionary< string, BadObject > InnerTable
The Inner Table for this Object.
Definition BadTable.cs:60
Implements a function that can be called from the script.
static readonly BadClassPrototype Prototype
The Prototype for the Function Object.
Implements a Type Instance in the BadScript Language.
Definition BadClass.cs:11
Implements a Class Prototype for the BadScript Language.
Helper Class that Builds a Native Class from a Prototype.
static BadClassPrototype GetNative(string name)
Returns a Native Class Prototype for the given Native Type.
static IEnumerable< BadClassPrototype > NativeTypes
Enumeration of all Native Class Prototypes.
string GetFullPath(string path)
Returns the full path of the given path.
Implements the Interface for Native Numbers.
Definition IBadNumber.cs:7
Implements the Interface for Native Strings.
Definition IBadString.cs:7
Contains IO Implementation for the BadScript2 Runtime.
Contains Common Interop APIs for the BadScript2 Runtime.
Contains task/async Extensions and Integrations for the BadScript2 Runtime.
Contains the BadScript2 Constant Folding Optimizations.
Contains the BadScript2 Constant Substitution Optimizations.
Contains the Expressions for the BadScript2 Language.
Contains the Comparison Operators for the BadScript2 Language.
Contains the Parser for the BadScript2 Language.
Contains the Error Objects for the BadScript2 Language.
Contains the Extension Classes for Functions.
Contains the Interop Function Classes for the BadScript2 Language.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains Runtime Function Objects.
Contains the Native Runtime Objects.
Definition BadBoolean.cs:6
Contains the Runtime Objects.
Definition BadArray.cs:10
Contains Runtime Settings Objects.
Contains the Runtime Implementation.
BadScopeFlags
Defines Different Behaviours for the Current Scope.
bool IsError
Indicates whether there are any messages of type Error.
static BadExpressionValidatorContext Validate(IEnumerable< BadExpression > expressions)
Validates the given expressions.
override string ToString()
Returns a string representation of the validation results.
IReadOnlyList< BadExpressionValidatorMessage > Messages
The messages generated by the validators.