BadScript 2
Loading...
Searching...
No Matches
BadEnumerableInteropFunction.cs
Go to the documentation of this file.
5
7
12{
16 private readonly Func<BadExecutionContext, BadObject[], IEnumerable<BadObject>> m_Func;
17
27 BadWordToken? name,
28 Func<BadObject[], IEnumerable<BadObject>> func,
29 bool isStatic,
30 BadClassPrototype returnType,
31 params BadFunctionParameter[] parameters) : base(name, false, isStatic, returnType, false, parameters)
32 {
33 m_Func = (_, args) => func(args);
34 }
35
45 BadWordToken? name,
46 Func<BadExecutionContext, BadObject[], IEnumerable<BadObject>> func,
47 bool isStatic,
48 BadClassPrototype returnType,
49 params BadFunctionParameter[] parameters) : base(name, false, isStatic, returnType, false,parameters)
50 {
51 m_Func = func;
52 }
53
54
63 Func<BadObject[], IEnumerable<BadObject>> func,
64 bool isStatic,
65 BadClassPrototype returnType,
66 params string[] names)
67 {
69 null,
70 func,
71 isStatic,
72 returnType,
73 names.Select(x => (BadFunctionParameter)x).ToArray()
74 );
75
76 return function;
77 }
78
79
81 protected override IEnumerable<BadObject> InvokeBlock(BadObject[] args, BadExecutionContext caller)
82 {
83 CheckParameters(args, caller);
84
85 return m_Func.Invoke(caller, args);
86 }
87}
The Execution Context. Every execution of a script needs a context the script is running in....
readonly Func< BadExecutionContext, BadObject[], IEnumerable< BadObject > > m_Func
The Function Lambda.
BadEnumerableInteropFunction(BadWordToken? name, Func< BadObject[], IEnumerable< BadObject > > func, bool isStatic, BadClassPrototype returnType, params BadFunctionParameter[] parameters)
Creates a new BadInteropFunction.
static BadEnumerableInteropFunction Create(Func< BadObject[], IEnumerable< BadObject > > func, bool isStatic, BadClassPrototype returnType, params string[] names)
Creates a new BadInteropFunction.
BadEnumerableInteropFunction(BadWordToken? name, Func< BadExecutionContext, BadObject[], IEnumerable< BadObject > > func, bool isStatic, BadClassPrototype returnType, params BadFunctionParameter[] parameters)
Creates a new BadInteropFunction.
override IEnumerable< BadObject > InvokeBlock(BadObject[] args, BadExecutionContext caller)
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
Implements a function that can be called from the script.
void CheckParameters(BadObject[] args, BadExecutionContext caller, BadSourcePosition? position=null)
Checks Parameters for the given function call.
Implements a Class Prototype for the BadScript Language.
Contains the Reader Tokens for the BadScript2 Language.
Contains the Interop Function Classes for the BadScript2 Language.
Contains Runtime Function Objects.
Contains the Runtime Objects.
Definition BadArray.cs:10